TemplateHandler { public void addMolecule(IAtomContainer molecule) { if (!GeometryUtil.has2DCoordinates(molecule)) throw new IllegalArgumentException("Template did not have 2D coordinates"); GeometryUtil.scaleMolecule(molecule, GeometryUtil.getScaleFactor(molecule, StructureDiagramGenerator.DEFAULT_BOND_LENGTH)); templates.add(molecule); anonPatterns.add(VentoFoggia.findSubstructure(molecule, anonAtomMatcher, anonBondMatcher)); elemPatterns.add(VentoFoggia.findSubstructure(molecule, elemAtomMatcher, anonBondMatcher)); } TemplateHandler(IChemObjectBuilder builder);  TemplateHandler(); void loadTemplates(IChemObjectBuilder builder); void addMolecule(IAtomContainer molecule); IAtomContainer removeMolecule(IAtomContainer molecule); boolean mapTemplateExact(IAtomContainer molecule); boolean mapTemplates(IAtomContainer molecule); int getTemplateCount(); IAtomContainer getTemplateAt(int position); IAtomContainerSet getMappedSubstructures(IAtomContainer molecule); static TemplateHandler createSingleton(IAtomContainer template); static TemplateHandler createFromSubstructure(Pattern ptrn, Iterable<IAtomContainer> mols); static TemplateHandler createFromSubstructure(Pattern ptrn, IAtomContainer mol);  }
@Test public void testAddMolecule() throws Exception { logger.debug("***TestAddMolecule***"); boolean itIsInThere = false; TemplateHandler th = new TemplateHandler(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = TestMoleculeFactory.makeAlphaPinene(); sdg.setMolecule(mol); sdg.generateCoordinates(); mol = sdg.getMolecule(); String smiles = "C1=C(C)C2CC(C1)C2(C)(C)"; IAtomContainer smilesMol = sp.parseSmiles(smiles); itIsInThere = th.mapTemplates(smilesMol); logger.debug("Alpha-Pinene found by templateMapper: " + itIsInThere); Assert.assertFalse(itIsInThere); th.addMolecule(mol); logger.debug("now adding template for alpha-Pinen and trying again."); itIsInThere = th.mapTemplates(smilesMol); logger.debug("Alpha-Pinene found by templateMapper: " + itIsInThere); Assert.assertTrue(itIsInThere); }