private boolean isAllowedPermutation ( List < Integer > permutation ) { List < Integer > seqClusterId = subunits . getClusterIds ( ) ; int selfaligned = 0 ; for ( int i = 0 ; i < permutation . size ( ) ; i ++ ) { int j = permutation . get ( i ) ; if ( seqClusterId . get ( i ) != seqClusterId . get ( j ) ) { return false ; } if ( i == j ) { selfaligned ++ ; } } // either identity (all self aligned) or all unique return selfaligned == 0 || selfaligned == permutation . size ( ) ; }
The permutation must map all subunits onto an equivalent subunit and no subunit onto itself