public static void add3DCoordinates1 ( IAtomContainer atomContainer ) { // atoms without coordinates IAtomContainer noCoords = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; // get vector of possible referenceAtoms? IAtomContainer refAtoms = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { IAtom atom = atomContainer . getAtom ( i ) ; // is this atom without 3D coords, and has only one ligand? if ( atom . getPoint3d ( ) == null ) { List < IAtom > connectedAtoms = atomContainer . getConnectedAtomsList ( atom ) ; if ( connectedAtoms . size ( ) == 1 ) { IAtom refAtom = ( IAtom ) connectedAtoms . get ( 0 ) ; ; if ( refAtom . getPoint3d ( ) != null ) { refAtoms . addAtom ( refAtom ) ; // store atoms with no coords and ref atoms in a // single container noCoords . addAtom ( atom ) ; noCoords . addAtom ( refAtom ) ; // bond is required to extract ligands noCoords . addBond ( atomContainer . getBuilder ( ) . newInstance ( IBond . class , atom , refAtom , Order . SINGLE ) ) ; } } } } // now add coordinates to ligands of reference atoms // use default length of 1.0, which can be adjusted later double length = 1.0 ; double angle = TETRAHEDRAL_ANGLE ; for ( int i = 0 ; i < refAtoms . getAtomCount ( ) ; i ++ ) { IAtom refAtom = refAtoms . getAtom ( i ) ; List < IAtom > noCoordLigands = noCoords . getConnectedAtomsList ( refAtom ) ; int nLigands = noCoordLigands . size ( ) ; int nwanted = nLigands ; String elementType = refAtom . getSymbol ( ) ; // try to deal with lone pairs on small hetero if ( elementType . equals ( "N" ) || elementType . equals ( "O" ) || elementType . equals ( "S" ) ) { nwanted = 3 ; } Point3d [ ] newPoints = calculate3DCoordinatesForLigands ( atomContainer , refAtom , nwanted , length , angle ) ; for ( int j = 0 ; j < nLigands ; j ++ ) { IAtom ligand = ( IAtom ) noCoordLigands . get ( j ) ; Point3d newPoint = rescaleBondLength ( refAtom , ligand , newPoints [ j ] ) ; ligand . setPoint3d ( newPoint ) ; } } }
Generate coordinates for all atoms which are singly bonded and have no coordinates . This is useful when hydrogens are present but have no coordinates . It knows about C O N S only and will give tetrahedral or trigonal geometry elsewhere . Bond lengths are computed from covalent radii if available . Angles are tetrahedral or trigonal