Tversky error

User 73531e86ff

29-06-2010 14:24:08

Hi,


We have some code which is calculating the tversky similarity between 2 structures.  It has been working in the past but version 5.3.4 gives an error.  I have extracted the code into the code snippet below:


 


		CFParameters params = new CFParameters();
params.setLength(1024);
params.setBondCount(7);
params.setBitCount(4);
params.setNormalized(true);
ChemicalFingerprint fp1 = new ChemicalFingerprint(params);
ChemicalFingerprint fp2 = new ChemicalFingerprint(params);
fp1.generate(MolImporter.importMol("c1ccccc1", "smiles"));
fp2.generate(MolImporter.importMol("c1ccncc1", "smiles"));

final SimilarityCalculator sc = SimilarityCalculatorFactory.create("TVERSKY,0.5,0.5");
final int[] query = TverskyChemaxonInlineSimilarityFunction.byte2int(fp1.toData()) ; // bitstring represented as int array.
final int[] target = TverskyChemaxonInlineSimilarityFunction.byte2int(fp2.toData()); // bitstring represented as int array.
sc.setQueryFingerprint(query);
float sim = sc.getSimilarity(target);


 


The stack trace is:



java.lang.IllegalArgumentException: No enum const class chemaxon.descriptors.MetricsType.TVERSKY,0.5,0.5
at java.lang.Enum.valueOf(Enum.java:192)
at chemaxon.descriptors.MetricsType.valueOf(MetricsType.java:17)
at chemaxon.descriptors.SimilarityCalculatorFactory.setMetricsType(SimilarityCalculatorFactory.java:73)
at chemaxon.descriptors.SimilarityCalculatorFactory.(SimilarityCalculatorFactory.java:107)
at chemaxon.descriptors.SimilarityCalculatorFactory.create(SimilarityCalculatorFactory.java:180)
at chemaxon.descriptors.SimilarityCalculatorFactory.create(SimilarityCalculatorFactory.java:166)
at ...

ChemAxon 1b9e90b2e7

29-06-2010 15:03:26

Hi Shane,


this issue is caused by the parameter line:  "TVERSKY,0.5,0.5" .


In the older versions "," was used as the field separator char as written in the apidoc.


Currently  the value at chemaxon.descriptors.SimilarityCalculatorFactory.SEPARATOR , which default is  ";"  , used for parameter field separation. The API doc will be modified accordingly in the next release.


Thank you for your report.


Adrian

User 73531e86ff

29-06-2010 15:07:47

Hi Adrian,


Thanks for the quick response.  Our unit tests are all passing again now :)


Cheers,


Shane