Tversky error

User 73531e86ff

29-06-2010 14:24:08


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();
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.
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(
at chemaxon.descriptors.MetricsType.valueOf(
at chemaxon.descriptors.SimilarityCalculatorFactory.setMetricsType(
at chemaxon.descriptors.SimilarityCalculatorFactory.(
at chemaxon.descriptors.SimilarityCalculatorFactory.create(
at chemaxon.descriptors.SimilarityCalculatorFactory.create(
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.


User 73531e86ff

29-06-2010 15:07:47

Hi Adrian,

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