Exemplo n.º 1
0
        public void TestBasicAmineOnDrugs()
        {
            var filename = "drugs.smi";
            var ins      = ResourceLoader.GetAsStream(GetType(), filename);

            SMARTSQueryTool sqt = new SMARTSQueryTool("[NX3;H2,H1;!$(NC=O)]", ChemObjectBuilder.Instance);

            // iterating SMILES reader doesn't allow us to turn off automatic aromaticity
            // perception
            var sp = CDK.SmilesParser;

            int nmatch = 0;
            int nmol   = 0;

            using (var reader = new StreamReader(ins))
            {
                string smi;
                while ((smi = reader.ReadLine()) != null)
                {
                    var container = sp.ParseSmiles(smi.Split('\t')[0]);
                    if (sqt.Matches(container))
                    {
                        nmatch++;
                    }
                    nmol++;
                }
                Assert.AreEqual(141, nmol);
                Assert.AreEqual(0, nmatch);
            }
        }
Exemplo n.º 2
0
        public void TestRecursive29()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("Cc1cc(=O)c(c[nH]1)C(=O)NC(c1ccc(cc1)O)C(=O)NC1C(=O)N2C1SCC(=C2C(=O)O)CSc1nnnn1C");

            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(0, result[0]);
            Assert.AreEqual(0, result[1]);
        }
Exemplo n.º 3
0
        public void TestRecursive28()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("Cc1ccc[n+]2c1[nH]cc(c2=O)c1n[nH]nn1");

            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(0, result[0]);
            Assert.AreEqual(0, result[1]);
        }
Exemplo n.º 4
0
        public void TestRecursiveSmarts27()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("CCCc1nc(c2n1[nH]c(nc2=O)c1cc(ccc1OCC)S(=O)(=O)N1CCN(CC1)CC)C");

            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(0, result[0]);
            Assert.AreEqual(0, result[1]);
        }
Exemplo n.º 5
0
        public void TestRecursiveSmarts26()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("CCCc1cc(=O)nc([nH]1)S");

            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(0, result[0]);
            Assert.AreEqual(0, result[1]);
        }
Exemplo n.º 6
0
        public void TestRecursive29_cdkAromaticModel()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("Cc1cc(=O)c(c[nH]1)C(=O)NC(c1ccc(cc1)O)C(=O)NC1C(=O)N2C1SCC(=C2C(=O)O)CSc1nnnn1C");

            sqt.SetAromaticity(new Aromaticity(ElectronDonation.CDKModel, Cycles.CDKAromaticSetFinder));
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(smi);
            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(1, result[0]);
            Assert.AreEqual(1, result[1]);
        }
Exemplo n.º 7
0
        public void TestRecursiveSmarts27_cdkAromaticModel()
        {
            SMARTSQueryTool sqt = CreateFromSmarts("[NX3;H2,H1;!$(NC=O)]");
            IAtomContainer  smi = CreateFromSmiles("CCCc1nc(c2n1[nH]c(nc2=O)c1cc(ccc1OCC)S(=O)(=O)N1CCN(CC1)CC)C");

            sqt.SetAromaticity(new Aromaticity(ElectronDonation.CDKModel, Cycles.CDKAromaticSetFinder));
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(smi);
            int[] result = SMARTSSearchTest.Match(sqt, smi);
            Assert.AreEqual(1, result[0]);
            Assert.AreEqual(1, result[1]);
        }
Exemplo n.º 8
0
        public void Match(string smarts, string smiles)
        {
            SMARTSQueryTool sqt           = new SMARTSQueryTool(smarts, ChemObjectBuilder.Instance);
            var             sp            = CDK.SmilesParser;
            var             atomContainer = sp.ParseSmiles(smiles);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(atomContainer);
            Aromaticity.CDKLegacy.Apply(atomContainer);
            bool status = sqt.Matches(atomContainer);

            if (status)
            {
                nmatch  = sqt.MatchesCount;
                nqmatch = sqt.GetUniqueMatchingAtoms().Count();
            }
            else
            {
                nmatch  = 0;
                nqmatch = 0;
            }
        }
Exemplo n.º 9
0
        public void TestBasicAmineOnDrugs_cdkAromaticModel()
        {
            var filename = "drugs.smi";
            var ins      = ResourceLoader.GetAsStream(GetType(), filename);

            using (EnumerableSMILESReader reader = new EnumerableSMILESReader(ins, ChemObjectBuilder.Instance))
            {
                SMARTSQueryTool sqt = new SMARTSQueryTool("[NX3;H2,H1;!$(NC=O)]", ChemObjectBuilder.Instance);
                sqt.SetAromaticity(new Aromaticity(ElectronDonation.CDKModel, Cycles.CDKAromaticSetFinder));
                int nmatch = 0;
                int nmol   = 0;
                foreach (var container in reader)
                {
                    AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(container);

                    // skip un-typed atoms, they can't be run through the CDK aromatic
                    // model
                    foreach (var atom in container.Atoms)
                    {
                        if (atom.AtomTypeName == null)
                        {
                            goto continue_READ;
                        }
                    }

                    if (sqt.Matches(container))
                    {
                        nmatch++;
                    }
                    nmol++;
continue_READ:
                    ;
                }
                Assert.AreEqual(141, nmol);
                Assert.AreEqual(4, nmatch);
            }
        }
Exemplo n.º 10
0
 static void AssertMatch(SMARTSQueryTool sqt, IAtomContainer m, int hits, int usaHits)
 {
     sqt.Matches(m);
     Assert.AreEqual(hits, sqt.GetMatchingAtoms().Count());
     Assert.AreEqual(usaHits, sqt.GetUniqueMatchingAtoms().Count());
 }