public static double getBondLengthRMSD ( IAtomContainer firstAtomContainer , IAtomContainer secondAtomContainer , Map < Integer , Integer > mappedAtoms , boolean Coords3d ) { //logger.debug("**** GT getBondLengthRMSD ****"); Iterator < Integer > firstAtoms = mappedAtoms . keySet ( ) . iterator ( ) ; IAtom centerAtomFirstMolecule ; IAtom centerAtomSecondMolecule ; List < IAtom > connectedAtoms ; double sum = 0 ; double n = 0 ; double distance1 = 0 ; double distance2 = 0 ; setVisitedFlagsToFalse ( firstAtomContainer ) ; setVisitedFlagsToFalse ( secondAtomContainer ) ; while ( firstAtoms . hasNext ( ) ) { centerAtomFirstMolecule = firstAtomContainer . getAtom ( firstAtoms . next ( ) ) ; centerAtomFirstMolecule . setFlag ( CDKConstants . VISITED , true ) ; centerAtomSecondMolecule = secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( centerAtomFirstMolecule ) ) ) ; connectedAtoms = firstAtomContainer . getConnectedAtomsList ( centerAtomFirstMolecule ) ; for ( int i = 0 ; i < connectedAtoms . size ( ) ; i ++ ) { IAtom conAtom = connectedAtoms . get ( i ) ; //this step is built to know if the program has already calculate a bond length (so as not to have duplicate values) if ( ! conAtom . getFlag ( CDKConstants . VISITED ) ) { if ( Coords3d ) { distance1 = centerAtomFirstMolecule . getPoint3d ( ) . distance ( conAtom . getPoint3d ( ) ) ; distance2 = centerAtomSecondMolecule . getPoint3d ( ) . distance ( secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( conAtom ) ) ) . getPoint3d ( ) ) ; sum = sum + Math . pow ( ( distance1 - distance2 ) , 2 ) ; n ++ ; } else { distance1 = centerAtomFirstMolecule . getPoint2d ( ) . distance ( conAtom . getPoint2d ( ) ) ; distance2 = centerAtomSecondMolecule . getPoint2d ( ) . distance ( secondAtomContainer . getAtom ( ( mappedAtoms . get ( firstAtomContainer . indexOf ( conAtom ) ) ) ) . getPoint2d ( ) ) ; sum = sum + Math . pow ( ( distance1 - distance2 ) , 2 ) ; n ++ ; } } } } setVisitedFlagsToFalse ( firstAtomContainer ) ; setVisitedFlagsToFalse ( secondAtomContainer ) ; return Math . sqrt ( sum / n ) ; }
Return the RMSD of bonds length between the 2 aligned molecules .