Created
March 18, 2009 11:23
-
-
Save gilleain/81069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void clone(IAtomContainer source, IAtomContainer target) { | |
for (int i = 0; i < source.getAtomCount(); i++) { | |
IAtom atom = (IAtom) source.getAtom(i).clone(); | |
target.addAtom(atom); | |
} | |
for (IBond bond : source.bonds()) { | |
IBond newBond = (IBond)bond.clone(); | |
IAtom[] newAtoms = new IAtom[bond.getAtomCount()]; | |
for (int j = 0; j < bond.getAtomCount(); ++j) { | |
IAtom atom = bond.getAtom(j); | |
newAtoms[j] = getAtomByEquals(target, source, atom); | |
// newAtoms[j] = getAtomByID(target, atom.getID()); | |
} | |
newBond.setAtoms(newAtoms); | |
target.addBond(newBond); | |
} | |
} | |
public IAtom getAtomByID(IAtomContainer container, String id) { | |
for (IAtom atom : container.atoms()) { | |
if (atom.getID().equals(id)) { | |
return atom; | |
} | |
} | |
return null; | |
} | |
public IAtom getAtomByEquals(IAtomContainer target, IAtomContainer source, IAtom atom) { | |
return target.getAtom(source.getAtomNumber(atom)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment