public static double [ ] getBiologicalMoleculeCentroid ( final Structure asymUnit , List < BiologicalAssemblyTransformation > transformations ) throws IllegalArgumentException { if ( asymUnit == null ) { throw new IllegalArgumentException ( "null structure" ) ; } Atom [ ] atoms = StructureTools . getAllAtomArray ( asymUnit ) ; int atomCount = atoms . length ; double [ ] centroid = new double [ 3 ] ; if ( atomCount <= 0 ) { return centroid ; } if ( transformations . size ( ) == 0 ) { return Calc . getCentroid ( atoms ) . getCoords ( ) ; } int count = 0 ; double [ ] transformedCoordinate = new double [ 3 ] ; for ( int i = 0 ; i < atomCount ; i ++ ) { Atom atom = atoms [ i ] ; Chain chain = atom . getGroup ( ) . getChain ( ) ; String intChainID = chain . getId ( ) ; for ( BiologicalAssemblyTransformation m : transformations ) { if ( ! m . getChainId ( ) . equals ( intChainID ) ) continue ; Point3d coords = atom . getCoordsAsPoint3d ( ) ; transformedCoordinate [ 0 ] = coords . x ; transformedCoordinate [ 1 ] = coords . y ; transformedCoordinate [ 2 ] = coords . z ; m . transformPoint ( transformedCoordinate ) ; centroid [ 0 ] += transformedCoordinate [ 0 ] ; centroid [ 1 ] += transformedCoordinate [ 1 ] ; centroid [ 2 ] += transformedCoordinate [ 2 ] ; count ++ ; } } centroid [ 0 ] /= count ; centroid [ 1 ] /= count ; centroid [ 2 ] /= count ; return centroid ; }
Returns the centroid of the biological molecule .