Exemple #1
0
        public void TestCyclopropaneNotASubgraphOfIsoButane()
        {
            IAtomContainer cycloPropane = CreateCyclopropane();
            IAtomContainer isobutane    = CreateIsobutane();

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(cycloPropane);
            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(isobutane);

            IAtomContainer source = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(cycloPropane);
            IAtomContainer target = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(isobutane);

            Aromaticity.CDKLegacy.Apply(source);
            Aromaticity.CDKLegacy.Apply(target);

            bool bondSensitive        = false;
            bool removeHydrogen       = true;
            bool stereoMatch          = true;
            bool fragmentMinimization = true;
            bool energyMinimization   = true;

            //    Calling the main algorithm to perform MCS cearch
            Isomorphism comparison = new Isomorphism(Algorithm.SubStructure, bondSensitive);

            comparison.Init(source, target, removeHydrogen, true);
            comparison.SetChemFilters(stereoMatch, fragmentMinimization, energyMinimization);

            //        Cyclopropane is not a subgraph of Isobutane
            Assert.IsFalse(comparison.IsSubgraph());
            Assert.AreEqual(0.625, comparison.GetTanimotoSimilarity());
        }
Exemple #2
0
        public void TestQueryAtomContainerSubstructure()
        {
            var sp     = CDK.SmilesParser;
            var query  = sp.ParseSmiles("CC");
            var target = sp.ParseSmiles("C1CCC12CCCC2");

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(query);
            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(target);

            //    Calling the main algorithm to perform MCS cearch

            Aromaticity.CDKLegacy.Apply(query);
            Aromaticity.CDKLegacy.Apply(target);

            Isomorphism smsd = new Isomorphism(Algorithm.SubStructure, true);

            smsd.Init(query, target, false, true);
            bool foundMatches = smsd.IsSubgraph();

            Assert.IsTrue(foundMatches);

            //        IQueryAtomContainer queryContainer = QueryAtomContainerCreator.CreateSymbolAndBondOrderQueryContainer(query);
            //
            //        Isomorphism smsd1 = new Isomorphism(Algorithm.SubStructure, true);
            //        smsd1.Init(queryContainer, target, true, true);
            //        smsd1.SetChemFilters(true, true, true);
            //        foundMatches = smsd1.IsSubgraph();
            //        Assert.IsFalse(foundMatches);
        }
Exemple #3
0
        public void TestSMSDAdpAtpSubgraph()
        {
            var    sp   = CDK.SmilesParser;
            string adp  = "NC1=NC=NC2=C1N=CN2[C@@H]1O[C@H](COP(O)(=O)OP(O)(O)=O)[C@@H](O)[C@H]1O";
            string atp  = "NC1=NC=NC2=C1N=CN2[C@@H]1O[C@H](COP(O)(=O)OP(O)(=O)OP(O)(O)=O)[C@@H](O)[C@H]1O";
            var    mol1 = sp.ParseSmiles(adp);
            var    mol2 = sp.ParseSmiles(atp);

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);

            //    Calling the main algorithm to perform MCS cearch

            Aromaticity.CDKLegacy.Apply(mol1);
            Aromaticity.CDKLegacy.Apply(mol2);

            bool bondSensitive        = true;
            bool removeHydrogen       = true;
            bool stereoMatch          = true;
            bool fragmentMinimization = true;
            bool energyMinimization   = true;

            Isomorphism comparison = new Isomorphism(Algorithm.Default, bondSensitive);

            comparison.Init(mol1, mol2, removeHydrogen, true);
            comparison.SetChemFilters(stereoMatch, fragmentMinimization, energyMinimization);

            //      Get modified Query and Target Molecules as Mappings will correspond to these molecules
            Assert.IsTrue(comparison.IsSubgraph());
            Assert.AreEqual(2, comparison.GetAllMapping().Count);
            Assert.AreEqual(27, comparison.GetFirstMapping().Count);
        }
Exemple #4
0
        public void TestSMSDFragHetSubgraph()
        {
            var    sp    = CDK.SmilesParser;
            string file1 = "O=C1NC(=O)C2=C(N1)NC(=O)C=N2";
            string file2 = "OC[C@@H](O)[C@@H](O)[C@@H](O)CN1C(O)C(CCC(O)O)NC2C(O)NC(O)NC12";

            var mol1 = sp.ParseSmiles(file1);
            var mol2 = sp.ParseSmiles(file2);

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);

            IAtomContainer source = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(mol1);
            IAtomContainer target = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(mol2);

            //    Calling the main algorithm to perform MCS search

            Aromaticity.CDKLegacy.Apply(source);
            Aromaticity.CDKLegacy.Apply(target);

            bool bondSensitive        = false;
            bool removeHydrogen       = true;
            bool stereoMatch          = true;
            bool fragmentMinimization = true;
            bool energyMinimization   = true;

            Isomorphism comparison = new Isomorphism(Algorithm.Default, bondSensitive);

            comparison.Init(source, target, removeHydrogen, true);
            comparison.SetChemFilters(stereoMatch, fragmentMinimization, energyMinimization);

            Assert.IsTrue(comparison.IsSubgraph());
            Assert.AreEqual(13, comparison.GetFirstMapping().Count);
        }
Exemple #5
0
        public void TestGetAllAtomMapping()
        {
            var sp      = new SmilesParser(ChemObjectBuilder.Instance, false);
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(target);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(queryac);
            Aromaticity.CDKLegacy.Apply(target);
            Aromaticity.CDKLegacy.Apply(queryac);

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(queryac);
            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(target);

            //    Calling the main algorithm to perform MCS cearch

            Aromaticity.CDKLegacy.Apply(queryac);
            Aromaticity.CDKLegacy.Apply(target);

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);
            Assert.IsNotNull(smsd1.GetFirstMapping());
            Assert.AreEqual(2, smsd1.GetAllAtomMapping().Count);
        }
Exemple #6
0
        public void TestSMSD()
        {
            //        Isomorphism ebimcs = new Isomorphism(Algorithm.VFLibMCS, true);
            //        ebimcs.Init(Cyclohexane, Benzene, true, true);
            //        ebimcs.SetChemFilters(true, true, true);
            //        Assert.AreEqual(1, ebimcs.GetFirstMapping().Count);

            Isomorphism ebimcs1 = new Isomorphism(Algorithm.Default, true);

            ebimcs1.Init(Benzene, Napthalene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);

            ebimcs1 = new Isomorphism(Algorithm.Default, false);
            ebimcs1.Init(Benzene, Napthalene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);

            ebimcs1 = new Isomorphism(Algorithm.VFLibMCS, true);
            ebimcs1.Init(Benzene, Napthalene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);

            ebimcs1 = new Isomorphism(Algorithm.CDKMCS, true);
            ebimcs1.Init(Benzene, Napthalene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);

            ebimcs1 = new Isomorphism(Algorithm.MCSPlus, true);
            ebimcs1.Init(Benzene, Napthalene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);
        }
Exemple #7
0
        public void TestVFLib()
        {
            Isomorphism sbf = new Isomorphism(Algorithm.VFLibMCS, true);

            sbf.Init(Benzene, Benzene, true, true);
            sbf.SetChemFilters(true, true, true);
            Assert.IsTrue(sbf.IsSubgraph());
        }
Exemple #8
0
        public void TestSMSD()
        {
            Isomorphism ebimcs = new Isomorphism(Algorithm.Default, false);

            ebimcs.Init(Cyclohexane, Benzene, true, true);
            ebimcs.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs.GetFirstMapping().Count);
        }
Exemple #9
0
        public void TestSubgraph()
        {
            Isomorphism sbf = new Isomorphism(Algorithm.SubStructure, false);

            sbf.Init(Benzene, Benzene, true, true);
            sbf.SetChemFilters(false, false, false);
            Assert.IsTrue(sbf.IsSubgraph());
        }
Exemple #10
0
        public void TestSMSDCyclohexaneBenzeneSubgraph()
        {
            Isomorphism ebimcs1 = new Isomorphism(Algorithm.SubStructure, false);

            ebimcs1.Init(Cyclohexane, Benzene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.IsTrue(ebimcs1.IsSubgraph());
        }
Exemple #11
0
        public void TestCDKMCS()
        {
            Isomorphism ebimcs = new Isomorphism(Algorithm.CDKMCS, false);

            ebimcs.Init(Cyclohexane, Benzene, true, true);
            ebimcs.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs.GetFirstMapping().Count);
            Assert.IsTrue(ebimcs.IsSubgraph());
        }
Exemple #12
0
        public void TestSubgraph()
        {
            Isomorphism sbf = new Isomorphism(Algorithm.SubStructure, true);

            sbf.Init(Benzene, Napthalene, true, true);
            sbf.SetChemFilters(false, false, false);
            Assert.IsTrue(sbf.IsSubgraph());
            Assert.AreEqual(24, sbf.GetAllAtomMapping().Count);
        }
Exemple #13
0
        public void TestSMSDChemicalFilters()
        {
            Isomorphism ebimcs = new Isomorphism(Algorithm.Default, false);

            ebimcs.Init(Cyclohexane, Benzene, true, true);
            ebimcs.SetChemFilters(true, true, true);
            Assert.AreEqual(12, ebimcs.GetAllMapping().Count);
            Assert.IsTrue(ebimcs.IsSubgraph());
        }
Exemple #14
0
        public void TestSMSDChemicalFilters()
        {
            Isomorphism ebimcs1 = new Isomorphism(Algorithm.Default, true);

            ebimcs1.Init(Napthalene, Benzene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetAllMapping().Count);
            Assert.IsFalse(ebimcs1.IsSubgraph());
        }
Exemple #15
0
        public void TestMCSPlus()
        {
            //TO DO fix me this error
            Isomorphism ebimcs = new Isomorphism(Algorithm.MCSPlus, false);

            ebimcs.Init(Cyclohexane, Benzene, true, true);
            ebimcs.SetChemFilters(true, true, true);
            Assert.IsTrue(ebimcs.IsSubgraph());
        }
Exemple #16
0
        public void TestSMSDCyclohexaneBenzeneSubgraph()
        {
            //        IQueryAtomContainer queryContainer = QueryAtomContainerCreator.CreateSymbolAndBondOrderQueryContainer(Cyclohexane);

            Isomorphism ebimcs = new Isomorphism(Algorithm.VFLibMCS, true);

            ebimcs.Init(Cyclohexane, Benzene, true, true);
            ebimcs.SetChemFilters(true, true, true);
            Assert.IsFalse(ebimcs.IsSubgraph());
        }
Exemple #17
0
        public void TestImpossibleQuery()
        {
            Isomorphism smsd   = new Isomorphism(Algorithm.Default, true);
            var         sp     = CDK.SmilesParser;
            var         query  = sp.ParseSmiles("CC");
            var         target = sp.ParseSmiles("C");

            smsd.Init(query, target, false, true);
            bool foundMatches = smsd.IsSubgraph();

            Assert.IsFalse(foundMatches);
        }
Exemple #18
0
        public void TestSetChemFilters()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/OCC=C");
            var queryac = sp.ParseSmiles("CCCOCC(C)=C");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, false);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);
            Assert.AreEqual(1, smsd1.GetAllAtomMapping().Count);
        }
Exemple #19
0
        public void TestSet_IAtomContainer_IAtomContainer()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);
            Assert.IsNotNull(smsd1.GetFirstMapping());
        }
Exemple #20
0
        public void TestIsSubgraph()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            Isomorphism smsd1 = new Isomorphism(Algorithm.SubStructure, false);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);
            Assert.AreEqual(true, smsd1.IsSubgraph());
        }
Exemple #21
0
        public void TestInit_3args_2()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/OCC=C");
            var queryac = sp.ParseSmiles("CCCOCC(C)=C");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, false);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, false, false);
            Assert.IsNotNull(smsd1.ReactantMolecule);
            Assert.IsNotNull(smsd1.ProductMolecule);
        }
Exemple #22
0
        public void TestGetProductMolecule()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);

            Assert.AreEqual(20, smsd1.ProductMolecule.Atoms.Count);
        }
Exemple #23
0
        public void TestSMSDBondInSensitive()
        {
            Isomorphism ebimcs1 = new Isomorphism(Algorithm.Default, false);

            ebimcs1.Init(Cyclohexane, Benzene, true, true);
            ebimcs1.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs1.GetFirstAtomMapping().Count);

            Isomorphism ebimcs2 = new Isomorphism(Algorithm.Default, false);

            ebimcs2.Init(Benzene, Napthalene, true, true);
            ebimcs2.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs2.GetFirstAtomMapping().Count);
        }
Exemple #24
0
        public void TestGetStereoScore()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/OCC=C");
            var queryac = sp.ParseSmiles("CCCOCC(C)=C");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, false);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, false, false);
            int score = 1048;

            Assert.AreEqual(score, smsd1.GetStereoScore(0));
        }
Exemple #25
0
        public void TestGetEnergyScore()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(false, false, true);
            double score = 610.0;

            Assert.AreEqual(score, smsd1.GetEnergyScore(0));
        }
Exemple #26
0
        public void TestSet_MolHandler_MolHandler()
        {
            var sp = CDK.SmilesParser;

            var         target1 = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var         queryac = sp.ParseSmiles("Nc1ccccc1");
            MolHandler  source  = new MolHandler(queryac, true, true);
            MolHandler  target  = new MolHandler(target1, true, true);
            Isomorphism smsd1   = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(source.Molecule, target.Molecule, true, true);
            smsd1.SetChemFilters(true, true, true);
            Assert.IsNotNull(smsd1.GetFirstMapping());
        }
Exemple #27
0
        public void TestGetTanimotoSimilarity()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);

            double score = 0.35;

            Assert.AreEqual(score, smsd1.GetTanimotoSimilarity(), 0);
        }
Exemple #28
0
        public void TestQueryAtomContainerMCSPLUS()
        {
            Isomorphism smsd   = new Isomorphism(Algorithm.MCSPlus, true);
            var         sp     = CDK.SmilesParser;
            var         query  = sp.ParseSmiles("CC");
            var         target = sp.ParseSmiles("C1CCC12CCCC2");

            smsd.Init(query, target, false, true);
            bool foundMatches = smsd.IsSubgraph();

            Assert.IsTrue(foundMatches);

            IQueryAtomContainer queryContainer = QueryAtomContainerCreator.CreateSymbolAndBondOrderQueryContainer(query);

            smsd.Init(queryContainer, target);
            foundMatches = smsd.IsSubgraph();
            Assert.IsTrue(foundMatches);
        }
Exemple #29
0
        public void TestMatchCountCDKMCS()
        {
            Isomorphism smsd   = new Isomorphism(Algorithm.CDKMCS, true);
            var         sp     = CDK.SmilesParser;
            var         query  = sp.ParseSmiles("CC");
            var         target = sp.ParseSmiles("C1CCC12CCCC2");

            smsd.Init(query, target, false, true);
            bool foundMatches = smsd.IsSubgraph();

            Assert.AreEqual(18, smsd.GetAllAtomMapping().Count);
            Assert.IsTrue(foundMatches);

            IQueryAtomContainer queryContainer = QueryAtomContainerCreator.CreateSymbolAndBondOrderQueryContainer(query);

            smsd.Init(queryContainer, target);
            foundMatches = smsd.IsSubgraph();
            Assert.IsTrue(foundMatches);
        }
Exemple #30
0
        public void TestGetEuclideanDistance()
        {
            var sp      = CDK.SmilesParser;
            var target  = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
            var queryac = sp.ParseSmiles("Nc1ccccc1");

            var smsd1 = new Isomorphism(Algorithm.SubStructure, true);

            smsd1.Init(queryac, target, true, true);
            smsd1.SetChemFilters(true, true, true);

            double score = 3.605;

            Assert.AreEqual(score, smsd1.GetEuclideanDistance(), 0.005);

            Isomorphism smsd2 = new Isomorphism(Algorithm.VFLibMCS, true);

            smsd2.Init(queryac, target, true, true);
            smsd2.SetChemFilters(true, true, true);

            Assert.AreEqual(score, smsd2.GetEuclideanDistance(), 0.005);
        }