public void TestRemoveMolecule() { Debug.WriteLine("***TestRemoveMolecule***"); bool itIsInThere = false; TemplateHandler th = new TemplateHandler(); IAtomContainer mol = TestMoleculeFactory.MakeAlphaPinene(); sdg.Molecule = mol; sdg.GenerateCoordinates(); mol = sdg.Molecule; var smiles = "C1=C(C)C2CC(C1)C2(C)(C)"; var smilesMol = sp.ParseSmiles(smiles); itIsInThere = th.MapTemplates(smilesMol); Debug.WriteLine($"Alpha-Pinene found by templateMapper: {itIsInThere}"); Assert.IsFalse(itIsInThere); th.AddMolecule(mol); Debug.WriteLine("now adding template for alpha-Pinen and trying again."); itIsInThere = th.MapTemplates(smilesMol); Debug.WriteLine($"Alpha-Pinene found by templateMapper: {itIsInThere}"); Assert.IsTrue(itIsInThere); Debug.WriteLine("now removing template for alpha-Pinen again and trying again."); th.RemoveMolecule(mol); itIsInThere = th.MapTemplates(smilesMol); Debug.WriteLine($"Alpha-Pinene found by templateMapper: {itIsInThere}"); Assert.IsFalse(itIsInThere); }
/// <summary> /// Singleton template instance, mainly useful for aligning molecules. /// </summary> /// <remarks> /// If the template does not have coordinates an error is thrown. /// For safety we clone the molecule. /// </remarks> /// <param name="template">the molecule</param> /// <returns>new template handler</returns> public static TemplateHandler CreateSingleton(IAtomContainer template) { var handler = new TemplateHandler(); var copy = (IAtomContainer)template.Clone(); handler.AddMolecule(copy); return(handler); }