public static Atom [ ] findLinkage ( final Group group1 , final Group group2 , String nameOfAtomOnGroup1 , String nameOfAtomOnGroup2 , double bondLengthTolerance ) { Atom [ ] ret = new Atom [ 2 ] ; ret [ 0 ] = group1 . getAtom ( nameOfAtomOnGroup1 ) ; ret [ 1 ] = group2 . getAtom ( nameOfAtomOnGroup2 ) ; if ( ret [ 0 ] == null || ret [ 1 ] == null ) { return null ; } Atom a1 = ret [ 0 ] ; Atom a2 = ret [ 1 ] ; boolean hasBond = a1 . hasBond ( a2 ) ; if ( hasBond ) { return ret ; } // is it a metal ? if ( a1 . getElement ( ) . isMetal ( ) || a2 . getElement ( ) . isMetal ( ) ) { MetalBondDistance defined = getMetalDistanceCutoff ( a1 . getElement ( ) . name ( ) , a2 . getElement ( ) . name ( ) ) ; if ( defined != null ) { if ( hasMetalBond ( a1 , a2 , defined ) ) return ret ; else return null ; } } // not a metal double distance = Calc . getDistance ( a1 , a2 ) ; float radiusOfAtom1 = ret [ 0 ] . getElement ( ) . getCovalentRadius ( ) ; float radiusOfAtom2 = ret [ 1 ] . getElement ( ) . getCovalentRadius ( ) ; if ( Math . abs ( distance - radiusOfAtom1 - radiusOfAtom2 ) > bondLengthTolerance ) { return null ; } return ret ; }
Find a linkage between two groups within tolerance of bond length .