Example #1
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);
        }
Example #2
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());
        }
Example #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);
        }
Example #4
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);
        }
Example #5
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());
        }
Example #6
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());
        }
Example #7
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());
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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());
        }
Example #11
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());
        }
Example #12
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());
        }
Example #13
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());
        }
Example #14
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());
        }
Example #15
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);
        }
Example #16
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());
        }
Example #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);
        }
Example #18
0
        public void TestSMSDLargeSubgraph()
        {
            var    sp     = CDK.SmilesParser;
            string c03374 = "CC1=C(C=C)\\C(NC1=O)=C" + "\\C1=C(C)C(CCC(=O)O[C@@H]2O[C@@H]"
                            + "([C@@H](O)[C@H](O)[C@H]2O)C(O)=O)" + "=C(CC2=C(CCC(O)=O)C(C)=C(N2)" + "\\C=C2NC(=O)C(C=C)=C/2C)N1";

            string c05787 = "CC1=C(C=C)\\C(NC1=O)=C" + "\\C1=C(C)C(CCC(=O)O[C@@H]2O[C@@H]"
                            + "([C@@H](O)[C@H](O)[C@H]2O)C(O)=O)" + "=C(CC2=C(CCC(=O)O[C@@H]3O[C@@H]"
                            + "([C@@H](O)[C@H](O)[C@H]3O)C(O)=O)" + "C(C)=C(N2)" + "\\C=C2NC(=O)C(C=C)=C/2C)N1";

            var mol1 = sp.ParseSmiles(c03374);
            var mol2 = sp.ParseSmiles(c05787);

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

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

            //    Calling the main algorithm to perform MCS cearch

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

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

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

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

            Assert.IsTrue(comparison.IsSubgraph());
            Assert.AreEqual(55, comparison.GetFirstMapping().Count);
        }
Example #19
0
        public void TestSMSDBondSensitive()
        {
            Isomorphism ebimcs3 = new Isomorphism(Algorithm.CDKMCS, true);

            ebimcs3.Init(Cyclohexane, Benzene, true, true);
            ebimcs3.SetChemFilters(false, false, false);
            Assert.IsFalse(ebimcs3.IsSubgraph());

            Isomorphism ebimcs4 = new Isomorphism(Algorithm.CDKMCS, true);

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

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

            ebimcs5.Init(Cyclohexane, Benzene, true, true);
            ebimcs5.SetChemFilters(true, true, true);
            Assert.IsFalse(ebimcs5.IsSubgraph());

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

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

            Isomorphism ebimcs7 = new Isomorphism(Algorithm.MCSPlus, true);

            ebimcs7.Init(Cyclohexane, Benzene, true, true);
            ebimcs7.SetChemFilters(true, true, true);
            Assert.IsFalse(ebimcs7.IsSubgraph());

            Isomorphism ebimcs8 = new Isomorphism(Algorithm.MCSPlus, true);

            ebimcs8.Init(Benzene, Napthalene, true, true);
            ebimcs8.SetChemFilters(true, true, true);
            Assert.AreEqual(6, ebimcs8.GetFirstAtomMapping().Count);
        }
Example #20
0
        public void TestSingleMappingTesting()
        {
            var sp            = CDK.SmilesParser;
            var atomContainer = sp.ParseSmiles("C");

            IAtomContainer mol2 = Create4Toluene();

            ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);
            Aromaticity.CDKLegacy.Apply(mol2);

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

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

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

            Assert.IsTrue(comparison.IsSubgraph());
            Assert.AreEqual(7, comparison.GetAllMapping().Count);
        }
Example #21
0
        static void Main()
        {
            {
                #region 1
                SmilesParser sp = new SmilesParser();
                // Benzene
                IAtomContainer A1 = sp.ParseSmiles("C1=CC=CC=C1");
                // Napthalene
                IAtomContainer A2 = sp.ParseSmiles("C1=CC2=C(C=C1)C=CC=C2");
                //Turbo mode search
                //Bond Sensitive is set true
                Isomorphism comparison = new Isomorphism(Algorithm.SubStructure, true);
                // set molecules, remove hydrogens, clean and configure molecule
                comparison.Init(A1, A2, true, true);
                // set chemical filter true
                comparison.SetChemFilters(false, false, false);
                if (comparison.IsSubgraph())
                {
                    //Get similarity score
                    Console.Out.WriteLine("Tanimoto coefficient:  " + comparison.GetTanimotoSimilarity());
                    Console.Out.WriteLine("A1 is a subgraph of A2:  " + comparison.IsSubgraph());
                    //Get Modified AtomContainer
                    IAtomContainer Mol1 = comparison.ReactantMolecule;
                    IAtomContainer Mol2 = comparison.ProductMolecule;
                    // Print the mapping between molecules
                    Console.Out.WriteLine(" Mappings: ");
                    foreach (var mapping in comparison.GetFirstMapping())
                    {
                        Console.Out.WriteLine((mapping.Key + 1) + " " + (mapping.Value + 1));

                        IAtom eAtom = Mol1.Atoms[mapping.Key];
                        IAtom pAtom = Mol2.Atoms[mapping.Value];
                        Console.Out.WriteLine(eAtom.Symbol + " " + pAtom.Symbol);
                    }
                    Console.Out.WriteLine("");
                }
                #endregion
            }
            {
                #region 2
                SmilesParser sp = new SmilesParser();
                // Benzene
                IAtomContainer A1 = sp.ParseSmiles("C1=CC=CC=C1");
                // Napthalene
                IAtomContainer A2 = sp.ParseSmiles("C1=CC2=C(C=C1)C=CC=C2");
                //{ 0: Default Isomorphism Algorithm, 1: MCSPlus Algorithm, 2: VFLibMCS Algorithm, 3: CDKMCS Algorithm}
                //Bond Sensitive is set true
                Isomorphism comparison = new Isomorphism(Algorithm.Default, true);
                // set molecules, remove hydrogens, clean and configure molecule
                comparison.Init(A1, A2, true, true);
                // set chemical filter true
                comparison.SetChemFilters(true, true, true);

                //Get similarity score
                Console.Out.WriteLine("Tanimoto coefficient:  " + comparison.GetTanimotoSimilarity());
                Console.Out.WriteLine("A1 is a subgraph of A2:  " + comparison.IsSubgraph());
                //Get Modified AtomContainer
                IAtomContainer Mol1 = comparison.ReactantMolecule;
                IAtomContainer Mol2 = comparison.ProductMolecule;
                // Print the mapping between molecules
                Console.Out.WriteLine(" Mappings: ");
                foreach (var mapping in comparison.GetFirstMapping())
                {
                    Console.Out.WriteLine((mapping.Key + 1) + " " + (mapping.Value + 1));

                    IAtom eAtom = Mol1.Atoms[mapping.Key];
                    IAtom pAtom = Mol2.Atoms[mapping.Value];
                    Console.Out.WriteLine(eAtom.Symbol + " " + pAtom.Symbol);
                }
                Console.Out.WriteLine("");
                #endregion
            }
        }