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()); }
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); }
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); }
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); }
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); }
static SMSDBondInsensitiveTest() { Napthalene = CreateNaphthalene(); Cyclohexane = CreateCyclohexane(); Benzene = CreateBenzene(); ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(Napthalene); ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(Cyclohexane); ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(Benzene); Aromaticity.CDKLegacy.Apply(Napthalene); Aromaticity.CDKLegacy.Apply(Cyclohexane); Aromaticity.CDKLegacy.Apply(Benzene); }
static VFLibTest() { hexane = CreateHexane(); Assert.AreEqual(6, hexane.Atoms.Count); ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(hexane); hexane = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(hexane); Aromaticity.CDKLegacy.Apply(hexane); hexaneQuery = new QueryCompiler(hexane, true).Compile(); Assert.AreEqual(6, hexaneQuery.CountNodes()); benzene = CreateBenzene(); ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(benzene); hexane = ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(benzene); Aromaticity.CDKLegacy.Apply(benzene); benzeneQuery = new QueryCompiler(benzene, true).Compile(); }
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); }
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); }
/// <summary> /// Returns IAtomContainer without Hydrogen. If an AtomContainer has atom single atom which /// is atom Hydrogen then its not removed. /// </summary> /// <returns>IAtomContainer without Hydrogen. If an AtomContainer has atom single atom which is atom Hydrogen then its not removed.</returns> public static IAtomContainer RemoveHydrogensAndPreserveAtomID(IAtomContainer atomContainer) { return(ExtAtomContainerManipulator.RemoveHydrogensExceptSingleAndPreserveAtomID(atomContainer)); }
/// <summary> /// The summed implicit + explicit hydrogens of the given IAtom. /// <returns>The summed implicit + explicit hydrogens of the given IAtom.</returns> /// </summary> public static int GetHydrogenCount(IAtomContainer atomContainer, IAtom atom) { return(ExtAtomContainerManipulator.GetHydrogenCount(atomContainer, atom)); }
/// <summary> /// This function finds rings and uses aromaticity detection code to /// aromatize the molecule. /// </summary> /// <param name="mol">input molecule</param> public static void AromatizeMolecule(IAtomContainer mol) { ExtAtomContainerManipulator.AromatizeMolecule(mol); }
/// <summary> /// Convenience method to perceive atom types for all <see cref="IAtom"/>s in the /// <see cref="IAtomContainer"/>, using the <see cref="AtomTypes.CDKAtomTypeMatcher"/>. If the /// matcher finds atom matching atom type, the <see cref="IAtom"/> will be configured /// to have the same properties as the <see cref="IAtomType"/>. If no matching atom /// type is found, no configuration is performed. /// <param name="container"></param> /// </summary> /// <exception cref="CDKException"></exception> public static void PercieveAtomTypesAndConfigureAtoms(IAtomContainer container) { ExtAtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(container); }
/// <summary> /// Returns IAtomContainer without Hydrogen. If an AtomContainer has atom single atom which /// is atom Hydrogen then its not removed. /// </summary> /// <returns>IAtomContainer without Hydrogen. If an AtomContainer has atom single atom which is atom Hydrogen then its not removed.</returns> public static IAtomContainer ConvertExplicitToImplicitHydrogens(IAtomContainer atomContainer) { return(ExtAtomContainerManipulator.ConvertExplicitToImplicitHydrogens(atomContainer)); }