ExtAtomContainerManipulator extends AtomContainerManipulator { public static IAtomContainer makeDeepCopy(IAtomContainer container) { IAtomContainer newAtomContainer = container.getBuilder().newInstance(IAtomContainer.class); IAtom[] atoms = copyAtoms(container, newAtomContainer); copyBonds(atoms, container, newAtomContainer); for (int index = 0; index < container.getLonePairCount(); index++) { if (container.getAtom(index).getSymbol().equalsIgnoreCase("R") || container.getAtom(index).getSymbol().equalsIgnoreCase("A")) { newAtomContainer.addLonePair(container.getBuilder().newInstance(ILonePair.class, container.getAtom(index))); } else { newAtomContainer.addLonePair(index); } } for (int index = 0; index < container.getSingleElectronCount(); index++) { newAtomContainer.addSingleElectron(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(IAtom atom); static int getHydrogenCount(IAtomContainer atomContainer, IAtom atom); static IAtomContainer removeHydrogensExceptSingleAndPreserveAtomID(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 = ExtAtomContainerManipulator.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()); } }