inprogress
[jalview.git] / forester / java / src / org / forester / msa_compactor / MsaCompactor.java
index 0673cf3..366d5bd 100644 (file)
@@ -99,8 +99,14 @@ public class MsaCompactor {
         for( final GapContribution gap_gontribution : stats ) {
             to_remove_ids.add( gap_gontribution.getId() );
         }
+        if ( !_realign ) {
+            _step = -1;
+        }
         printTableHeader();
-        final int x = ForesterUtil.roundToInt( _msa.getNumberOfSequences() / 20.0 );
+        int x = ForesterUtil.roundToInt( _msa.getNumberOfSequences() / 20.0 );
+        if ( x < 1 ) {
+            x = 1;
+        }
         MsaProperties msa_prop = new MsaProperties( _msa, _report_aln_mean_identity );
         msa_props.add( msa_prop );
         printMsaProperties( "", msa_prop );
@@ -130,6 +136,10 @@ public class MsaCompactor {
         return msa_props;
     }
 
+    final public void deleteGapColumns( final double max_allowed_gap_ratio ) {
+        _msa.deleteGapColumns( max_allowed_gap_ratio );
+    }
+
     final public Msa getMsa() {
         return _msa;
     }
@@ -138,6 +148,15 @@ public class MsaCompactor {
         return _removed_seq_ids;
     }
 
+    public final void removeSequencesByMinimalLength( final int min_effective_length ) {
+        printMsaProperties( "", new MsaProperties( _msa, _report_aln_mean_identity ) );
+        System.out.println();
+        _msa = DeleteableMsa.createInstance( MsaMethods.removeSequencesByMinimalLength( _msa, min_effective_length ) );
+        removeGapColumns();
+        printMsaProperties( "", new MsaProperties( _msa, _report_aln_mean_identity ) );
+        System.out.println();
+    }
+
     public final List<MsaProperties> removeViaGapAverage( final double mean_gapiness ) throws IOException,
             InterruptedException {
         final GapContribution stats[] = calcGapContribtionsStats( _norm );
@@ -416,11 +435,11 @@ public class MsaCompactor {
     }
 
     private final boolean isPrintMsaStats( final int i ) {
-        return ( ( ( _step < 2 ) && ( _step_for_diagnostics < 2 ) ) || ( ( _step_for_diagnostics > 0 ) && ( ( ( i + 1 ) % _step_for_diagnostics ) == 0 ) ) );
+        return ( ( ( _step == 1 ) && ( _step_for_diagnostics == 1 ) ) || ( ( _step_for_diagnostics > 0 ) && ( ( ( i + 1 ) % _step_for_diagnostics ) == 0 ) ) );
     }
 
     private final boolean isPrintMsaStatsWriteOutfileAndRealign( final int i ) {
-        return ( ( ( _step < 2 ) && ( _step_for_diagnostics < 2 ) ) || ( ( _step > 0 ) && ( ( ( i + 1 ) % _step ) == 0 ) ) );
+        return ( ( ( _step == 1 ) && ( _step_for_diagnostics == 1 ) ) || ( ( _step > 0 ) && ( ( ( i + 1 ) % _step ) == 0 ) ) );
     }
 
     private final StringBuilder msaPropertiesAsSB( final MsaProperties msa_properties ) {
@@ -430,7 +449,7 @@ public class MsaCompactor {
         sb.append( msa_properties.getLength() );
         sb.append( "\t" );
         sb.append( NF_4.format( msa_properties.getGapRatio() ) );
-        if ( _report_aln_mean_identity /*msa_properties.getAverageIdentityRatio() >= 0*/) {
+        if ( _report_aln_mean_identity ) {
             sb.append( "\t" );
             sb.append( NF_4.format( msa_properties.getAverageIdentityRatio() ) );
         }
@@ -466,7 +485,7 @@ public class MsaCompactor {
     }
 
     private final void printMsaProperties( final String id, final MsaProperties msa_properties ) {
-        if ( ( _step < 2 ) || ( _step_for_diagnostics < 2 ) ) {
+        if ( ( _step == 1 ) || ( _step_for_diagnostics == 1 ) ) {
             System.out.print( ForesterUtil.pad( id, _longest_id_length, ' ', false ) );
             System.out.print( "\t" );
         }
@@ -487,7 +506,7 @@ public class MsaCompactor {
     }
 
     private final void printTableHeader() {
-        if ( ( _step < 2 ) || ( _step_for_diagnostics < 2 ) ) {
+        if ( ( _step == 1 ) || ( _step_for_diagnostics == 1 ) ) {
             System.out.print( ForesterUtil.pad( "Id", _longest_id_length, ' ', false ) );
             System.out.print( "\t" );
         }