private static int calcAdjustedMinimumSequenceLength ( List < Subunit > subunits , int absMinLen , double fraction , int minLen ) { int maxLength = Integer . MIN_VALUE ; int minLength = Integer . MAX_VALUE ; // Extract the length List, the min and the max List < Integer > lengths = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < subunits . size ( ) ; i ++ ) { if ( subunits . get ( i ) . size ( ) >= absMinLen ) { maxLength = Math . max ( subunits . get ( i ) . size ( ) , maxLength ) ; minLength = Math . min ( subunits . get ( i ) . size ( ) , minLength ) ; lengths . add ( subunits . get ( i ) . size ( ) ) ; } } int adjustedMinimumSequenceLength = minLen ; if ( lengths . size ( ) < 2 ) return adjustedMinimumSequenceLength ; // Calculate the median of the lengths double median = 0 ; Collections . sort ( lengths ) ; if ( lengths . size ( ) % 2 == 1 ) { int middle = ( lengths . size ( ) - 1 ) / 2 ; median = lengths . get ( middle ) ; } else { int middle2 = lengths . size ( ) / 2 ; int middle1 = middle2 - 1 ; median = 0.5 * ( lengths . get ( middle1 ) + lengths . get ( middle2 ) ) ; } // If the median * fraction is lower than the minLength if ( minLength >= median * fraction ) { adjustedMinimumSequenceLength = Math . min ( minLength , minLen ) ; } return adjustedMinimumSequenceLength ; }
Returns an adapted minimum sequence length . This method ensure that structure that only have short chains are not excluded by the minimumSequenceLength cutoff value .