19package denoptim.fitness.descriptors;
21import static org.junit.jupiter.api.Assertions.assertTrue;
23import java.lang.reflect.Constructor;
25import org.junit.jupiter.api.BeforeEach;
26import org.junit.jupiter.api.Test;
27import org.openscience.cdk.DefaultChemObjectBuilder;
28import org.openscience.cdk.fingerprint.IBitFingerprint;
29import org.openscience.cdk.fingerprint.PubchemFingerprinter;
30import org.openscience.cdk.interfaces.IAtomContainer;
31import org.openscience.cdk.qsar.result.DoubleResult;
32import org.openscience.cdk.smiles.SmilesParser;
45 public void setUp() throws Exception
47 Constructor<TanimotoMolSimilarity> defaultConstructor =
49 this.descriptor = defaultConstructor.newInstance();
50 this.descriptor.initialise(DefaultChemObjectBuilder.getInstance());
58 SmilesParser sp =
new SmilesParser(DefaultChemObjectBuilder.getInstance());
59 IAtomContainer ref = sp.parseSmiles(
"CNC(=O)c1cc(OC)ccc1");
60 PubchemFingerprinter fpMaker =
new PubchemFingerprinter(
61 DefaultChemObjectBuilder.getInstance());
62 IBitFingerprint fpRef = fpMaker.getBitFingerprint(ref);
64 Object[] params = {
"PubchemFingerprinter", fpRef};
67 IAtomContainer mol1 = sp.parseSmiles(
"COc1ccccc1");
70 assertTrue(
closeEnough(0.6,value),
"Tanimoto similarity with mol1: "
73 IAtomContainer mol2 = sp.parseSmiles(
"P");
76 assertTrue(
closeEnough(0.0,value),
"Tanimoto similarity with mol2: "
79 IAtomContainer mol3 = sp.parseSmiles(
"COc1cc(C(=O)NC)ccc1");
82 assertTrue(
closeEnough(1.0,value),
"Tanimoto similarity with mol3: "
90 double threshold = 0.0001;
91 double delta = Math.abs(expected-actual);
92 return delta < threshold;
Calculates the molecular similarity against a target compound the fingerprint of which is given as pa...
DescriptorValue calculate(IAtomContainer mol)
void setParameters(Object[] params)
Set the parameters attribute of TanimotoMolSimilarity object.
Unit test for descriptor TanimotoMolSimilarity.
TanimotoMolSimilarity descriptor
boolean closeEnough(double expected, double actual)
void testTanimotoMolSimilarity()