public void TestCalculate_BitFingerprint() { IAtomContainer mol1 = TestMoleculeFactory.MakeIndole(); IAtomContainer mol2 = TestMoleculeFactory.MakePyrrole(); Fingerprinter fp = new Fingerprinter(1024, 8); double similarity = Tanimoto.Calculate(fp.GetBitFingerprint(mol1), fp.GetBitFingerprint(mol2)); Assert.AreEqual(0.3939, similarity, 0.01 * 2); }
public void TestICountFingerprintComparison() { var mol1 = TestMoleculeFactory.MakeIndole(); var mol2 = TestMoleculeFactory.MakeIndole(); var fingerprinter = new SignatureFingerprinter(); var fp1 = fingerprinter.GetCountFingerprint(mol1); var fp2 = fingerprinter.GetCountFingerprint(mol2); var tanimoto = Tanimoto.Calculate(fp1, fp2); Assert.AreEqual(1.0, tanimoto, 0.001); }
void Main() { IAtomContainer molecule1 = null; IAtomContainer molecule2 = null; Fingerprinter fingerprinter = null; #region 1 BitArray fingerprint1 = fingerprinter.GetBitFingerprint(molecule1).AsBitSet(); BitArray fingerprint2 = fingerprinter.GetBitFingerprint(molecule2).AsBitSet(); double tanimoto_coefficient = Tanimoto.Calculate(fingerprint1, fingerprint2); #endregion }
public void TestRawTanimotoBetween0and1() { var smilesParser = CDK.SmilesParser; var mol1 = smilesParser.ParseSmiles("Cc1nc(C(=O)NC23CC4CC(CC(C4)C2)C3)c(C)n1C5CCCCC5"); var mol2 = smilesParser.ParseSmiles("CS(=O)(=O)Nc1ccc(Cc2onc(n2)c3ccc(cc3)S(=O)(=O)Nc4ccc(CCNC[C@H](O)c5cccnc5)cc4)cc1"); var fingerprinter = new SignatureFingerprinter(0); var fp1 = fingerprinter.GetRawFingerprint(mol1); var fp2 = fingerprinter.GetRawFingerprint(mol2); var tanimoto = Tanimoto.Calculate(fp1, fp2); Assert.IsTrue(tanimoto > 0 && tanimoto < 1, $"Tanimoto expected to be between 0 and 1, was:{tanimoto}"); }
public void Method2() { ICountFingerprint fp1 = new IntArrayCountFingerprint(new Dictionary <string, int>() { { "A", 3 } }); ICountFingerprint fp2 = new IntArrayCountFingerprint(new Dictionary <string, int>() { { "A", 4 } }); Assert.AreEqual(0.75, Tanimoto.Method2(fp1, fp2), 0.001); }
public void CompareCountFingerprintAndRawFingerprintTanimoto() { var mol1 = TestMoleculeFactory.Make123Triazole(); var mol2 = TestMoleculeFactory.MakeImidazole(); var fingerprinter = new SignatureFingerprinter(1); var countFp1 = fingerprinter.GetCountFingerprint(mol1); var countFp2 = fingerprinter.GetCountFingerprint(mol2); var feat1 = fingerprinter.GetRawFingerprint(mol1); var feat2 = fingerprinter.GetRawFingerprint(mol2); var rawTanimoto = Tanimoto.Calculate(feat1, feat2); var countTanimoto = Tanimoto.Method1(countFp1, countFp2); Assert.AreEqual(rawTanimoto, countTanimoto, 0.001); }
public void TestTanimoto3() { double[] f1 = { 1, 2, 3, 4, 5, 6, 7 }; double[] f2 = { 1, 2, 3, 4, 5, 6, 7 }; var tanimoto = Tanimoto.Calculate(f1, f2); if (standAlone) { System.Console.Out.WriteLine("Tanimoto: " + tanimoto); } if (!standAlone) { Assert.AreEqual(1.0, tanimoto, 0.001); } }
public void TestExactMatch() { IAtomContainer mol1 = TestMoleculeFactory.MakeIndole(); IAtomContainer mol2 = TestMoleculeFactory.MakeIndole(); AddImplicitHydrogens(mol1); AddImplicitHydrogens(mol2); var fingerprinter = new LingoFingerprinter(); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2); var feat1 = fingerprinter.GetRawFingerprint(mol1); var feat2 = fingerprinter.GetRawFingerprint(mol2); var tanimoto = Tanimoto.Calculate(feat1, feat2); Assert.AreEqual(1.0, tanimoto, 0.001); }
public void TestTanimoto2() { IAtomContainer mol1 = TestMoleculeFactory.MakeIndole(); IAtomContainer mol2 = TestMoleculeFactory.MakeIndole(); Fingerprinter fingerprinter = new Fingerprinter(); BitArray bs1 = fingerprinter.GetBitFingerprint(mol1).AsBitSet(); BitArray bs2 = fingerprinter.GetBitFingerprint(mol2).AsBitSet(); var tanimoto = Tanimoto.Calculate(bs1, bs2); if (standAlone) { System.Console.Out.WriteLine("Tanimoto: " + tanimoto); } if (!standAlone) { Assert.AreEqual(1.0, tanimoto, 0.001); } }
public void TestCompaRingBitFingerprintAndCountBehavingAsBit() { var mol1 = TestMoleculeFactory.Make123Triazole(); var mol2 = TestMoleculeFactory.MakeImidazole(); var fingerprinter = new SignatureFingerprinter(1); ICountFingerprint countFp1 = fingerprinter.GetCountFingerprint(mol1); ICountFingerprint countFp2 = fingerprinter.GetCountFingerprint(mol2); countFp1.SetBehaveAsBitFingerprint(true); countFp2.SetBehaveAsBitFingerprint(true); var bitFp1 = fingerprinter.GetBitFingerprint(mol1); var bitFp2 = fingerprinter.GetBitFingerprint(mol2); var bitTanimoto = Tanimoto.Calculate(bitFp1, bitFp2); var countTanimoto1 = Tanimoto.Method1(countFp1, countFp2); var countTanimoto2 = Tanimoto.Method2(countFp1, countFp2); Assert.AreEqual(countTanimoto1, countTanimoto2, 0.001); Assert.AreEqual(bitTanimoto, countTanimoto1, 0.001); }
public void TestCompareBitSetandBitFingerprintTanimoto() { IAtomContainer mol1 = TestMoleculeFactory.Make123Triazole(); IAtomContainer mol2 = TestMoleculeFactory.MakeImidazole(); Fingerprinter fingerprinter = new Fingerprinter(1024, 8); BitArray bs1 = fingerprinter.GetBitFingerprint(mol1).AsBitSet(); BitArray bs2 = fingerprinter.GetBitFingerprint(mol2).AsBitSet(); var tanimoto = Tanimoto.Calculate(bs1, bs2); BitSetFingerprint fp1 = new BitSetFingerprint(bs1); BitSetFingerprint fp2 = new BitSetFingerprint(bs2); double tanimoto2 = Tanimoto.Calculate(fp1, fp2); Assert.AreEqual(tanimoto, tanimoto2, 0.01); IntArrayFingerprint ifp1 = new IntArrayFingerprint(fp1); IntArrayFingerprint ifp2 = new IntArrayFingerprint(fp2); tanimoto2 = Tanimoto.Calculate(ifp1, ifp2); Assert.AreEqual(tanimoto, tanimoto2, 0.01); }
public void TestCountMethod1and2() { ICountFingerprint fp1 = new IntArrayCountFingerprint(new Dictionary <string, int>() { { "A", 3 } }); ICountFingerprint fp2 = new IntArrayCountFingerprint(new Dictionary <string, int>() { { "A", 4 } }); Assert.AreEqual(0.923, Tanimoto.Method1(fp1, fp2), 0.001); Assert.AreEqual(0.75, Tanimoto.Method2(fp1, fp2), 0.001); var mol1 = TestMoleculeFactory.MakeIndole(); var mol2 = TestMoleculeFactory.MakeIndole(); var fingerprinter = new SignatureFingerprinter(); fp1 = fingerprinter.GetCountFingerprint(mol1); fp2 = fingerprinter.GetCountFingerprint(mol2); Assert.AreEqual(1.0, Tanimoto.Method1(fp1, fp2), 0.001); Assert.AreEqual(1.0, Tanimoto.Method2(fp1, fp2), 0.001); }
public void KeggR00258() { var sp = CDK.SmilesParser; string smiles1 = "O=C(O)CCC(=O)C(=O)O"; string smiles2 = "O=C(O)C(N)CCC(=O)O"; string smiles3 = "O=C(O)C(N)C"; string smiles4 = "CC(=O)C(=O)O"; var molecule1 = sp.ParseSmiles(smiles1); var molecule2 = sp.ParseSmiles(smiles2); var molecule3 = sp.ParseSmiles(smiles3); var molecule4 = sp.ParseSmiles(smiles4); Fingerprinter fingerprinter = new Fingerprinter(1024, 6); BitArray bs1 = fingerprinter.GetBitFingerprint(molecule1).AsBitSet(); BitArray bs2 = fingerprinter.GetBitFingerprint(molecule2).AsBitSet(); BitArray bs3 = fingerprinter.GetBitFingerprint(molecule3).AsBitSet(); BitArray bs4 = fingerprinter.GetBitFingerprint(molecule4).AsBitSet(); Assert.AreEqual(0.75, (double)Tanimoto.Calculate(bs1, bs2), 0.1); Assert.AreEqual(0.46, (double)Tanimoto.Calculate(bs1, bs3), 0.1); Assert.AreEqual(0.52, (double)Tanimoto.Calculate(bs1, bs4), 0.1); Assert.AreEqual(0.53, (double)Tanimoto.Calculate(bs2, bs3), 0.1); Assert.AreEqual(0.42, (double)Tanimoto.Calculate(bs2, bs4), 0.1); Assert.AreEqual(0.8, (double)Tanimoto.Calculate(bs3, bs4), 0.1); }