inprogress
[jalview.git] / forester / java / src / org / forester / application / msa_compactor.java
index 7457b3e..33254a5 100644 (file)
@@ -9,26 +9,28 @@ import java.util.List;
 import org.forester.io.parsers.FastaParser;
 import org.forester.io.parsers.GeneralMsaParser;
 import org.forester.msa.Msa;
-import org.forester.msa.MsaCompactor;
+import org.forester.msa.Msa.MSA_FORMAT;
 import org.forester.msa.MsaMethods;
+import org.forester.msa_compactor.MsaCompactor;
 import org.forester.util.CommandLineArguments;
 import org.forester.util.ForesterUtil;
 
 public class msa_compactor {
 
-    final static private String HELP_OPTION_1                 = "help";
-    final static private String HELP_OPTION_2                 = "h";
-    final static private String REMOVE_WORST_OFFENDERS_OPTION = "w";
-    final static private String AV_GAPINESS_OPTION            = "a";
-    final static private String STEP_OPTION                   = "s";
-    final static private String LENGTH_OPTION                 = "l";
-    final static private String REALIGN_OPTION                = "r";
-    final static private String PRG_NAME                      = "msa_compactor";
-    final static private String PRG_DESC                      = "multiple sequnce aligment compactor";
-    final static private String PRG_VERSION                   = "0.90";
-    final static private String PRG_DATE                      = "2012.07.11";
-    final static private String E_MAIL                        = "phylosoft@gmail.com";
-    final static private String WWW                           = "www.phylosoft.org/forester/";
+    final static private String HELP_OPTION_1                          = "help";
+    final static private String HELP_OPTION_2                          = "h";
+    final static private String REMOVE_WORST_OFFENDERS_OPTION          = "w";
+    final static private String AV_GAPINESS_OPTION                     = "a";
+    final static private String STEP_OPTION                            = "s";
+    final static private String LENGTH_OPTION                          = "l";
+    final static private String REALIGN_OPTION                         = "r";
+    final static private String DO_NOT_NORMALIZE_FOR_EFF_LENGTH_OPTION = "nn";
+    final static private String PRG_NAME                               = "msa_compactor";
+    final static private String PRG_DESC                               = "multiple sequnce aligment compactor";
+    final static private String PRG_VERSION                            = "0.01";
+    final static private String PRG_DATE                               = "140314";
+    final static private String E_MAIL                                 = "phylosoft@gmail.com";
+    final static private String WWW                                    = "https://sites.google.com/site/cmzmasek/home/software/forester";
 
     public static void main( final String args[] ) {
         try {
@@ -44,11 +46,13 @@ public class msa_compactor {
             int length = -1;
             int step = 1;
             boolean realign = false;
+            boolean norm = true;
             final List<String> allowed_options = new ArrayList<String>();
             allowed_options.add( REMOVE_WORST_OFFENDERS_OPTION );
             allowed_options.add( AV_GAPINESS_OPTION );
             allowed_options.add( LENGTH_OPTION );
             allowed_options.add( REALIGN_OPTION );
+            allowed_options.add( DO_NOT_NORMALIZE_FOR_EFF_LENGTH_OPTION );
             allowed_options.add( STEP_OPTION );
             final String dissallowed_options = cla.validateAllowedOptionsAsString( allowed_options );
             if ( dissallowed_options.length() > 0 ) {
@@ -69,6 +73,9 @@ public class msa_compactor {
             if ( cla.isOptionSet( REALIGN_OPTION ) ) {
                 realign = true;
             }
+            if ( cla.isOptionSet( DO_NOT_NORMALIZE_FOR_EFF_LENGTH_OPTION ) ) {
+                norm = false;
+            }
             //            else if ( cla.isOptionSet( STEP_OPTION ) && cla.isOptionSet( WINDOW_OPTION ) ) {
             //                step = cla.getOptionValueAsInt( STEP_OPTION );
             //                window = cla.getOptionValueAsInt( WINDOW_OPTION );
@@ -87,7 +94,7 @@ public class msa_compactor {
             }
             MsaCompactor mc = null;
             if ( worst_remove > 0 ) {
-                mc = MsaCompactor.removeWorstOffenders( msa, worst_remove, realign );
+                mc = MsaCompactor.removeWorstOffenders( msa, worst_remove, realign, norm );
             }
             else if ( av > 0 ) {
                 mc = MsaCompactor.reduceGapAverage( msa, av, step, realign, out, 50 );
@@ -99,6 +106,7 @@ public class msa_compactor {
             for( final String id : mc.getRemovedSeqIds() ) {
                 System.out.println( id );
             }
+            mc.writeMsa( out, MSA_FORMAT.PHYLIP, ".aln" );
         }
         catch ( final Exception e ) {
             e.printStackTrace();
@@ -120,11 +128,8 @@ public class msa_compactor {
         System.out.println();
         System.out.println( " options: " );
         System.out.println();
-        //        System.out.println( "   -" + FROM_OPTION + "=<integer>: from (msa column)" );
-        //        System.out.println( "   -" + TO_OPTION + "=<integer>: to (msa column)" );
-        //        System.out.println( "    or" );
-        //        System.out.println( "   -" + WINDOW_OPTION + "=<integer>: window size (msa columns)" );
-        System.out.println( "   -" + REMOVE_WORST_OFFENDERS_OPTION + "=<integer>: step size (msa columns)" );
+        System.out.println( "   -" + REMOVE_WORST_OFFENDERS_OPTION + "=<integer>  number of sequences to remove" );
+        System.out.println( "   -" + REALIGN_OPTION + " to realign using " );
         System.out.println();
         System.out.println();
         System.out.println();