SMSDNormalizer extends AtomContainerManipulator { public static IAtomContainer makeDeepCopy(IAtomContainer container) { IAtomContainer newAtomContainer = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class); int lonePairCount = container.getLonePairCount(); int singleElectronCount = container.getSingleElectronCount(); ILonePair[] lonePairs = new ILonePair[lonePairCount]; ISingleElectron[] singleElectrons = new ISingleElectron[singleElectronCount]; IAtom[] atoms = copyAtoms(container, newAtomContainer); copyBonds(atoms, container, newAtomContainer); for (int index = 0; index < container.getLonePairCount(); index++) { if (container.getAtom(index).getSymbol().equalsIgnoreCase("R")) { lonePairs[index] = DefaultChemObjectBuilder.getInstance().newInstance(ILonePair.class, container.getAtom(index)); } newAtomContainer.addLonePair(lonePairs[index]); } for (int index = 0; index < container.getSingleElectronCount(); index++) { singleElectrons[index] = DefaultChemObjectBuilder.getInstance().newInstance(ISingleElectron.class, container.getAtom(index)); newAtomContainer.addSingleElectron(singleElectrons[index]); } newAtomContainer.addProperties(container.getProperties()); newAtomContainer.setFlags(container.getFlags()); newAtomContainer.setID(container.getID()); newAtomContainer.notifyChanged(); return newAtomContainer; }  static IAtomContainer makeDeepCopy(IAtomContainer container); static void aromatizeMolecule(IAtomContainer mol); static int getExplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom); static int getImplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom); static int getHydrogenCount(IAtomContainer atomContainer, IAtom atom); static IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer); static IAtomContainer convertExplicitToImplicitHydrogens(IAtomContainer atomContainer); static void percieveAtomTypesAndConfigureAtoms(IAtomContainer container);  }
@Test public void testMakeDeepCopy() throws InvalidSmilesException { String rawMolSmiles = "[H]POOSC(Br)C(Cl)C(F)I"; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer container = sp.parseSmiles(rawMolSmiles); int counter = 0; for (IAtom a : container.atoms()) { a.setID(String.valueOf(counter++)); } IAtomContainer result = SMSDNormalizer.makeDeepCopy(container); for (int i = 0; i < result.getAtomCount(); i++) { assertEquals(result.getAtom(i).getSymbol(), container.getAtom(i).getSymbol()); assertEquals(result.getAtom(i).getID(), container.getAtom(i).getID()); } }