From: cmzmasek Date: Thu, 3 Apr 2014 19:23:17 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=539013fa8fcd8ff8d4db0e517edb5fff91645b57;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/application/msa_compactor.java b/forester/java/src/org/forester/application/msa_compactor.java index 57d2a4d..b030d74 100644 --- a/forester/java/src/org/forester/application/msa_compactor.java +++ b/forester/java/src/org/forester/application/msa_compactor.java @@ -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() ) { diff --git a/forester/java/src/org/forester/msa_compactor/MsaCompactor.java b/forester/java/src/org/forester/msa_compactor/MsaCompactor.java index 258c2b9..d6ece5d 100644 --- a/forester/java/src/org/forester/msa_compactor/MsaCompactor.java +++ b/forester/java/src/org/forester/msa_compactor/MsaCompactor.java @@ -39,6 +39,7 @@ public class MsaCompactor { private static final boolean VERBOSE = true; private Msa _msa; private final SortedSet _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 opts = new ArrayList(); 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; + + } }