in progress
authorcmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 3 Apr 2014 19:23:17 +0000 (19:23 +0000)
committercmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 3 Apr 2014 19:23:17 +0000 (19:23 +0000)
forester/java/src/org/forester/application/msa_compactor.java
forester/java/src/org/forester/msa_compactor/MsaCompactor.java

index 57d2a4d..b030d74 100644 (file)
@@ -94,6 +94,15 @@ public class msa_compactor {
             //                printHelp();
             //                System.exit( 0 );
             //            }
+            
+            if ( realign ) {
+                if ( ForesterUtil.isEmpty( path_to_mafft ) ) {
+                    path_to_mafft = MsaCompactor.guessPathToMafft();
+                }
+                checkPathToMafft( path_to_mafft );
+            }
+            
+            
             Msa msa = null;
             final FileInputStream is = new FileInputStream( in );
             if ( FastaParser.isLikelyFasta( in ) ) {
@@ -103,22 +112,17 @@ public class msa_compactor {
                 msa = GeneralMsaParser.parse( is );
             }
             
-            if ( realign ) {
-                if ( ForesterUtil.isEmpty( path_to_mafft ) ) {
-                    path_to_mafft = MsaCompactor.guessPathToMafft();
-                }
-                checkPathToMafft( path_to_mafft );
-            }
+          
             
             MsaCompactor mc = null;
             if ( worst_remove > 0 ) {
-                mc = MsaCompactor.removeWorstOffenders( msa, worst_remove, realign, norm );
+                mc = MsaCompactor.removeWorstOffenders( msa, worst_remove, realign, norm, path_to_mafft );
             }
             else if ( av > 0 ) {
-                mc = MsaCompactor.reduceGapAverage( msa, av, step, realign, out, 50 );
+                mc = MsaCompactor.reduceGapAverage( msa, av, step, realign, out, 50, path_to_mafft );
             }
             else if ( length > 0 ) {
-                mc = MsaCompactor.reduceLength( msa, length, step, realign );
+                mc = MsaCompactor.reduceLength( msa, length, step, realign, path_to_mafft );
             }
             System.out.println( MsaMethods.calcGapRatio( mc.getMsa() ) );
             for( final String id : mc.getRemovedSeqIds() ) {
index 258c2b9..d6ece5d 100644 (file)
@@ -39,6 +39,7 @@ public class MsaCompactor {
     private static final boolean      VERBOSE = true;
     private Msa                       _msa;
     private final SortedSet<String>   _removed_seq_ids;
+    private String _path_to_mafft;
     static {
         NF_4.setRoundingMode( RoundingMode.HALF_UP );
         NF_3.setRoundingMode( RoundingMode.HALF_UP );
@@ -155,8 +156,13 @@ public class MsaCompactor {
     
 
     final private void mafft() throws IOException, InterruptedException {
+      //  final MsaInferrer mafft = Mafft
+        //       .createInstance( "/home/czmasek/SOFTWARE/MSA/MAFFT/mafft-7.130-without-extensions/scripts/mafft" );
+      
         final MsaInferrer mafft = Mafft
-                .createInstance( "/home/czmasek/SOFTWARE/MSA/MAFFT/mafft-7.130-without-extensions/scripts/mafft" );
+                .createInstance( _path_to_mafft );
+      
+        
         final List<String> opts = new ArrayList<String>();
         opts.add( "--maxiterate" );
         opts.add( "1000" );
@@ -335,9 +341,13 @@ public class MsaCompactor {
                                                        final int step,
                                                        final boolean realign,
                                                        final File out,
-                                                       final int minimal_effective_length ) throws IOException,
+                                                       final int minimal_effective_length,
+                                                       final String path_to_mafft ) throws IOException,
             InterruptedException {
         final MsaCompactor mc = new MsaCompactor( msa );
+        if ( realign) {
+            mc.setPathToMafft( path_to_mafft );
+        }
         mc.removeViaGapAverage( max_gap_average, step, realign, out, minimal_effective_length );
         return mc;
     }
@@ -345,8 +355,12 @@ public class MsaCompactor {
     public final static MsaCompactor reduceLength( final Msa msa,
                                                    final int length,
                                                    final int step,
-                                                   final boolean realign ) throws IOException, InterruptedException {
+                                                   final boolean realign,
+                                                   final String path_to_mafft ) throws IOException, InterruptedException {
         final MsaCompactor mc = new MsaCompactor( msa );
+        if ( realign) {
+            mc.setPathToMafft( path_to_mafft );
+        }
         mc.removeViaLength( length, step, realign );
         return mc;
     }
@@ -354,10 +368,19 @@ public class MsaCompactor {
     public final static MsaCompactor removeWorstOffenders( final Msa msa,
                                                            final int worst_offenders_to_remove,
                                                            final boolean realign,
-                                                           final boolean norm ) throws IOException,
+                                                           final boolean norm,
+                                                           final String path_to_mafft ) throws IOException,
             InterruptedException {
         final MsaCompactor mc = new MsaCompactor( msa );
+        if ( realign) {
+            mc.setPathToMafft( path_to_mafft );
+        }
         mc.removeWorstOffenders( worst_offenders_to_remove, 1, realign, norm );
         return mc;
     }
+
+    private void setPathToMafft( final String path_to_mafft ) {
+        _path_to_mafft = path_to_mafft;
+        
+    }
 }