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 ] ; // Deep copy of the Atoms IAtom [ ] atoms = copyAtoms ( container , newAtomContainer ) ; // Deep copy of the bonds copyBonds ( atoms , container , newAtomContainer ) ; // Deep copy of the LonePairs 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 ; }
Returns deep copy of the molecule