コード例 #1
0
        public void TestGetFunctionalGroupSubstructureSet()
        {
            var smarts = StandardSubstructureSets.GetFunctionalGroupSMARTS();

            Assert.IsNotNull(smarts);
            Assert.AreEqual(307, smarts.Count());
        }
コード例 #2
0
        public void TestGetCountableMACCSSMARTSSubstructureSet()
        {
            var smarts = StandardSubstructureSets.GetCountableMACCSSMARTS();

            Assert.IsNotNull(smarts);
            Assert.AreEqual(142, smarts.Count()); // currently fragment pattern is ignored
        }
コード例 #3
0
 /// <summary>
 /// Set up the fingerprinter to use the fragments from <see cref="StandardSubstructureSets"/>.
 /// </summary>
 public SubstructureFingerprinter()
 {
     try
     {
         SetSmarts(StandardSubstructureSets.GetFunctionalGroupSMARTS());
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException("Could not load SMARTS patterns", ex);
     }
 }
コード例 #4
0
        public void TestSize()
        {
            SubstructureFingerprinter fp;

            fp = new SubstructureFingerprinter();
            Assert.AreEqual(307, fp.Length);

            fp = new SubstructureFingerprinter(StandardSubstructureSets.GetFunctionalGroupSMARTS());
            Assert.AreEqual(307, fp.Length);

            fp = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());
            Assert.AreEqual(142, fp.Length);
        }
コード例 #5
0
        public void TestCountableMACCSBinary_Rings()
        {
            var            parser  = CDK.SmilesParser;
            var            printer = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());
            IAtomContainer mol;
            BitArray       bs;

            // Aromatic 6-rings
            mol = parser.ParseSmiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[128]); // 6-ring
            Assert.IsTrue(bs[111]); // aromaticity
            Assert.IsFalse(bs[7]);  // 7-ring
            Assert.IsFalse(bs[82]); // 5-ring
                                    // Non-aromatic 6-rings
            mol = parser.ParseSmiles("C1CC(CCC1)CCCCC2CCCCC2");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[128]);  // 6-ring
            Assert.IsFalse(bs[111]); // aromaticity
            Assert.IsFalse(bs[7]);   // 7-ring
            Assert.IsFalse(bs[82]);  // 5-ring
                                     // Aromatic 6-ring, 3-ring and 4-ring
            mol = parser.ParseSmiles("C1CC1C(CCC2CCC2)CC3=CC=CC=C3");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[128]); // 6-ring
            Assert.IsTrue(bs[111]); // aromaticity
            Assert.IsTrue(bs[10]);  // 3-ring
            Assert.IsTrue(bs[1]);   // 4-ring
            Assert.IsFalse(bs[7]);  // 7-ring
            Assert.IsFalse(bs[82]); // 5-ring
                                    // Aromatic 6-ring, 3-ring and 4-ring
            mol = parser.ParseSmiles("C1(CC1C(CCC2CCC2)CC3=CC=CC=C3)C(C(C(C4CC4)C5CC5)C6CC6)C7CC7");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[128]); // 6-ring
            Assert.IsTrue(bs[111]); // aromaticity
            Assert.IsTrue(bs[10]);  // 3-ring
            Assert.IsTrue(bs[1]);   // 4-ring
            Assert.IsFalse(bs[7]);  // 7-ring
            Assert.IsFalse(bs[82]); // 5-ring
        }
コード例 #6
0
        public void TestCountableMACCSCount_Rings()
        {
            var               parser  = CDK.SmilesParser;
            var               printer = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());
            IAtomContainer    mol;
            ICountFingerprint cfp;

            // Aromatic 6-rings
            mol = parser.ParseSmiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(128) == 2); // 6-ring
            Assert.IsTrue(cfp.GetCountForHash(111) == 2); // aromaticity
            Assert.IsTrue(cfp.GetCountForHash(7) == 0);   // 7-ring
            Assert.IsTrue(cfp.GetCountForHash(82) == 0);  // 5-ring
                                                          // Non-aromatic 6-rings
            mol = parser.ParseSmiles("C1CC(CCC1)CCCCC2CCCCC2");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(128) == 2); // 6-ring
            Assert.IsTrue(cfp.GetCountForHash(111) == 0); // aromaticity
            Assert.IsTrue(cfp.GetCountForHash(7) == 0);   // 7-ring
            Assert.IsTrue(cfp.GetCountForHash(82) == 0);  // 5-ring
                                                          // Aromatic 6-ring, 3-ring and 4-ring
            mol = parser.ParseSmiles("C1CC1C(CCC2CCC2)CC3=CC=CC=C3");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(128) == 1); // 6-ring
            Assert.IsTrue(cfp.GetCountForHash(111) == 1); // aromaticity
            Assert.IsTrue(cfp.GetCountForHash(10) == 1);  // 3-ring
            Assert.IsTrue(cfp.GetCountForHash(1) == 1);   // 4-ring
            Assert.IsTrue(cfp.GetCountForHash(7) == 0);   // 7-ring
            Assert.IsTrue(cfp.GetCountForHash(82) == 0);  // 5-ring
                                                          // Aromatic 6-ring, 3-ring and 4-ring
            mol = parser.ParseSmiles("C1(CC1C(CCC2CCC2)CC3=CC=CC=C3)C(C(C(C4CC4)C5CC5)C6CC6)C7CC7");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(128) == 1); // 6-ring
            Assert.IsTrue(cfp.GetCountForHash(111) == 1); // aromaticity
            Assert.IsTrue(cfp.GetCountForHash(10) == 5);  // 3-ring
            Assert.IsTrue(cfp.GetCountForHash(1) == 1);   // 4-ring
            Assert.IsTrue(cfp.GetCountForHash(7) == 0);   // 7-ring
            Assert.IsTrue(cfp.GetCountForHash(82) == 0);  // 5-ring
        }
コード例 #7
0
        public void TestCountableMACCSBinary()
        {
            // Tests are modified copy of the test included in the MACCS-FPs class
            var parser  = CDK.SmilesParser;
            var printer = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());

            Assert.AreEqual(142, printer.Length);
            var mol0 = parser.ParseSmiles("CC(N)CCCN");
            var mol1 = parser.ParseSmiles("c1ccccc1CCc1ccccc1");
            var mol2 = parser.ParseSmiles("c1ccccc1CC");
            var mol3 = parser.ParseSmiles("CC(N)CCC");
            var mol4 = parser.ParseSmiles("CCCC");

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol0);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol3);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol4);
            Aromaticity.CDKLegacy.Apply(mol0);
            Aromaticity.CDKLegacy.Apply(mol1);
            Aromaticity.CDKLegacy.Apply(mol2);
            Aromaticity.CDKLegacy.Apply(mol3);
            Aromaticity.CDKLegacy.Apply(mol4);
            var bs0 = printer.GetBitFingerprint(mol0).AsBitSet();
            var bs1 = printer.GetBitFingerprint(mol1).AsBitSet();
            var bs2 = printer.GetBitFingerprint(mol2).AsBitSet();
            var bs3 = printer.GetBitFingerprint(mol3).AsBitSet();
            var bs4 = printer.GetBitFingerprint(mol4).AsBitSet();

            // Check for the aromatic 6M rings
            Assert.IsFalse(bs0[111]);
            Assert.IsTrue(bs1[111]);
            Assert.IsTrue(bs2[111]);
            Assert.IsFalse(bs3[111]);
            Assert.IsFalse(bs4[111]);
            // Check for the fingerprints being subsets
            Assert.IsFalse(FingerprinterTool.IsSubset(bs1, bs2));
            Assert.IsFalse(FingerprinterTool.IsSubset(bs0, bs3));
            Assert.IsTrue(FingerprinterTool.IsSubset(bs3, bs4));
        }
コード例 #8
0
        public void TestCountableMACCSCount2()
        {
            var               parser  = CDK.SmilesParser;
            var               printer = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());
            IAtomContainer    mol;
            ICountFingerprint cfp;

            // Test molecule 1
            mol = parser.ParseSmiles("C([S](O)(=O)=O)C1=C(C=CC=C1)CCCC[N+](=O)[O-]");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(46) == 2);
            Assert.IsTrue(cfp.GetCountForHash(27) == 1);
            Assert.IsTrue(cfp.GetCountForHash(59) == 2);
            Assert.IsTrue(cfp.GetCountForHash(49) == 1);
            Assert.IsTrue(cfp.GetCountForHash(111) == 1);
            Assert.IsTrue(cfp.GetCountForHash(129) == 3);
            Assert.IsTrue(cfp.GetCountForHash(115) == 2);
            Assert.IsTrue(cfp.GetCountForHash(120) == 3);
            Assert.IsTrue(cfp.GetCountForHash(41) == 3);
            Assert.IsTrue(cfp.GetCountForHash(93) == 0);
            Assert.IsTrue(cfp.GetCountForHash(91) == 0);
            Assert.IsTrue(cfp.GetCountForHash(24) == 0);
            // Test molecule 2: Diatrizoic acid
            mol = parser.ParseSmiles("CC(=O)NC1=C(C(=C(C(=C1I)C(=O)O)I)NC(=O)C)I");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            cfp = printer.GetCountFingerprint(mol);
            Assert.IsTrue(cfp.GetCountForHash(15) == 3);
            Assert.IsTrue(cfp.GetCountForHash(135) == 3);
            Assert.IsTrue(cfp.GetCountForHash(139) == 4);
            Assert.IsTrue(cfp.GetCountForHash(93) == 3);
            Assert.IsTrue(cfp.GetCountForHash(73) == 6);
            Assert.IsTrue(cfp.GetCountForHash(91) == 0);
        }
コード例 #9
0
        public void TestCountableMACCSBinary2()
        {
            var            parser  = CDK.SmilesParser;
            var            printer = new SubstructureFingerprinter(StandardSubstructureSets.GetCountableMACCSSMARTS());
            IAtomContainer mol;
            BitArray       bs;

            // Test molecule 1
            mol = parser.ParseSmiles("C([S](O)(=O)=O)C1=C(C=CC=C1)CCCC[N+](=O)[O-]");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[46]);
            Assert.IsTrue(bs[27]);
            Assert.IsTrue(bs[59]);
            Assert.IsTrue(bs[49]);
            Assert.IsTrue(bs[111]);
            Assert.IsTrue(bs[129]);
            Assert.IsTrue(bs[115]);
            Assert.IsTrue(bs[120]);
            Assert.IsTrue(bs[41]);
            Assert.IsFalse(bs[93]);
            Assert.IsFalse(bs[91]);
            Assert.IsFalse(bs[24]);
            // Test molecule 2: Diatrizoic acid
            mol = parser.ParseSmiles("CC(=O)NC1=C(C(=C(C(=C1I)C(=O)O)I)NC(=O)C)I");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);
            bs = printer.GetBitFingerprint(mol).AsBitSet();
            Assert.IsTrue(bs[15]);
            Assert.IsTrue(bs[135]);
            Assert.IsTrue(bs[139]);
            Assert.IsTrue(bs[93]);
            Assert.IsTrue(bs[73]);
            Assert.IsFalse(bs[91]);
        }