private List < Integer > getPermutation ( Matrix4d transformation ) { double rmsdThresholdSq = Math . pow ( this . parameters . getRmsdThreshold ( ) , 2 ) ; List < Point3d > centers = subunits . getOriginalCenters ( ) ; List < Integer > seqClusterId = subunits . getClusterIds ( ) ; List < Integer > permutations = new ArrayList < Integer > ( centers . size ( ) ) ; double [ ] dSqs = new double [ centers . size ( ) ] ; boolean [ ] used = new boolean [ centers . size ( ) ] ; Arrays . fill ( used , false ) ; for ( int i = 0 ; i < centers . size ( ) ; i ++ ) { Point3d tCenter = new Point3d ( centers . get ( i ) ) ; transformation . transform ( tCenter ) ; int permutation = - 1 ; double minDistSq = Double . MAX_VALUE ; for ( int j = 0 ; j < centers . size ( ) ; j ++ ) { if ( seqClusterId . get ( i ) == seqClusterId . get ( j ) ) { if ( ! used [ j ] ) { double dSq = tCenter . distanceSquared ( centers . get ( j ) ) ; if ( dSq < minDistSq && dSq <= rmsdThresholdSq ) { minDistSq = dSq ; permutation = j ; dSqs [ j ] = dSq ; } } } } // can't map to itself if ( permutations . size ( ) == permutation ) { permutation = - 1 ; } if ( permutation != - 1 ) { used [ permutation ] = true ; } permutations . add ( permutation ) ; } return permutations ; }
Returns a permutation of subunit indices for the given helix transformation . An index of - 1 is used to indicate subunits that do not superpose onto any other subunit .