Example #1
0
        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
        }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }