private void layoutMolecule ( List ringSetMolecule , IAtomContainer molecule , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d , AtomPlacer atomPlacer ) throws CDKException , IOException , CloneNotSupportedException { //logger.debug("****** LAYOUT MOLECULE MAIN *******"); IAtomContainer ac = null ; int safetyCounter = 0 ; IAtom atom = null ; //Place rest Chains/Atoms do { safetyCounter ++ ; atom = ap3d . getNextPlacedHeavyAtomWithUnplacedRingNeighbour ( molecule ) ; if ( atom != null ) { //logger.debug("layout RingSystem..."); IAtom unplacedAtom = ap3d . getUnplacedRingHeavyAtom ( molecule , atom ) ; IRingSet ringSetA = getRingSetOfAtom ( ringSetMolecule , unplacedAtom ) ; IAtomContainer ringSetAContainer = RingSetManipulator . getAllInOneContainer ( ringSetA ) ; templateHandler . mapTemplates ( ringSetAContainer , ringSetAContainer . getAtomCount ( ) ) ; if ( checkAllRingAtomsHasCoordinates ( ringSetAContainer ) ) { } else { throw new IOException ( "RingAtomLayoutError: Not every ring atom is placed! Molecule cannot be layout.Sorry" ) ; } Point3d firstAtomOriginalCoord = unplacedAtom . getPoint3d ( ) ; Point3d centerPlacedMolecule = ap3d . geometricCenterAllPlacedAtoms ( molecule ) ; setBranchAtom ( molecule , unplacedAtom , atom , ap3d . getPlacedHeavyAtoms ( molecule , atom ) , ap3d , atlp3d ) ; layoutRingSystem ( firstAtomOriginalCoord , unplacedAtom , ringSetA , centerPlacedMolecule , atom , ap3d ) ; searchAndPlaceBranches ( molecule , ringSetAContainer , ap3d , atlp3d , atomPlacer ) ; //logger.debug("Ready layout Ring System"); ringSetA = null ; unplacedAtom = null ; firstAtomOriginalCoord = null ; centerPlacedMolecule = null ; } else { //logger.debug("layout chains..."); setAtomsToUnVisited ( molecule ) ; atom = ap3d . getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour ( molecule ) ; if ( atom != null ) { ac = atom . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; ac . addAtom ( atom ) ; searchAndPlaceBranches ( molecule , ac , ap3d , atlp3d , atomPlacer ) ; ac = null ; } } } while ( ! ap3d . allHeavyAtomsPlaced ( molecule ) || safetyCounter > molecule . getAtomCount ( ) ) ; }
Layout the molecule starts with ring systems and than aliphatic chains .