Ejemplo 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);
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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());
 }