Пример #1
0
        public void TestGetFirstMapping()
        {
            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());

            Assert.AreEqual(7, smsd1.GetFirstMapping().Count);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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());
        }
Пример #7
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());
        }
Пример #8
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);
        }
Пример #9
0
 public void TestSearchMCS()
 {
     try
     {
         var            sp     = new SmilesParser(ChemObjectBuilder.Instance, false);
         IAtomContainer target = null;
         target = sp.ParseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
         AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(target);
         var queryac = sp.ParseSmiles("Nc1ccccc1");
         AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(queryac);
         Aromaticity.CDKLegacy.Apply(target);
         Aromaticity.CDKLegacy.Apply(queryac);
         Isomorphism smsd1 = new Isomorphism(Algorithm.Default, true);
         smsd1.Init(queryac, target, true, true);
         smsd1.SetChemFilters(true, true, true);
         Assert.AreEqual(7, smsd1.GetFirstAtomMapping().Count);
         Assert.AreEqual(2, smsd1.GetAllAtomMapping().Count);
         Assert.IsNotNull(smsd1.GetFirstMapping());
     }
     catch (InvalidSmilesException ex)
     {
         Trace.TraceError(ex.Message);
     }
 }
Пример #10
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
            }
        }