From def5f3c9ca461176f1188d0adfd744726a56e6ed Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Mon, 6 Aug 2012 13:29:29 +0000 Subject: [PATCH] in progress --- .../org/forester/archaeopteryx/Configuration.java | 16 ++------- .../archaeopteryx/tools/InferenceManager.java | 11 ++---- .../archaeopteryx/tools/PhyloInferenceDialog.java | 37 +++++++++++++------- .../archaeopteryx/tools/PhylogeneticInferrer.java | 25 +++++++++---- .../java/src/org/forester/msa/ClustalOmega.java | 23 +++++++++--- 5 files changed, 67 insertions(+), 45 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index d81100a..e45dfc8 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -97,7 +97,6 @@ public final class Configuration { private boolean _taxonomy_colorize_node_shapes = false; private int _default_bootstrap_samples = -1; private File _path_to_local_mafft = null; - private File _path_to_local_kalign = null; private File _path_to_local_fastme = null; private File _path_to_local_raxml = null; private File _path_to_local_clustalo = null; @@ -440,9 +439,7 @@ public final class Configuration { return _path_to_local_mafft; } - public File getPathToLocalKalign() { - return _path_to_local_kalign; - } + public File getPathToLocalFastme() { return _path_to_local_fastme; @@ -826,9 +823,7 @@ public final class Configuration { _path_to_local_mafft = path_to_local_mafft; } - private void setPathToLocalKalign( final File path_to_local_kalign ) { - _path_to_local_kalign = path_to_local_kalign; - } + private void setPathToLocalFastme( final File path_to_local_fastme ) { _path_to_local_fastme = path_to_local_fastme; @@ -1068,12 +1063,7 @@ public final class Configuration { setPathToLocalMafft( new File( str ) ); } } - else if ( key.equals( "kalign_local" ) ) { - final String str = ( ( String ) st.nextElement() ).trim(); - if ( !ForesterUtil.isEmpty( str ) ) { - setPathToLocalKalign( new File( str ) ); - } - } + else if ( key.equals( "fastme_local" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); if ( !ForesterUtil.isEmpty( str ) ) { diff --git a/forester/java/src/org/forester/archaeopteryx/tools/InferenceManager.java b/forester/java/src/org/forester/archaeopteryx/tools/InferenceManager.java index f472ff0..2c416b9 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/InferenceManager.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/InferenceManager.java @@ -10,21 +10,19 @@ public final class InferenceManager { private final static String DEFAULT_PATHS[] = { "C:\\Program Files\\", "C:\\Program Files (x86)\\", "/bin/", "/usr/local/bin/", "/usr/bin/" }; private final File _path_to_local_mafft; - private final File _path_to_local_kalign; private final File _path_to_local_fastme; private final File _path_to_local_raxml; private final File _path_to_local_clustalo; public static InferenceManager createInstance( final Configuration c ) { return new InferenceManager( c.getpathToLocalMafft(), - c.getPathToLocalKalign(), c.getPathToLocalFastme(), c.getPathToLocalRaxml(), c.getPathToLocalClustalOmega() ); } public boolean canDoMsa() { - return ( getPathToLocalMafft() != null ) || ( getPathToLocalKalign() != null ) + return ( getPathToLocalMafft() != null ) || ( getPathToLocalClustalo() != null ); } @@ -32,9 +30,7 @@ public final class InferenceManager { return _path_to_local_mafft; } - public File getPathToLocalKalign() { - return _path_to_local_kalign; - } + public File getPathToLocalFastme() { return _path_to_local_fastme; @@ -78,12 +74,11 @@ public final class InferenceManager { } private InferenceManager( final File path_to_local_mafft, - final File path_to_local_kalign, final File path_to_local_fastme, final File path_to_local_raxml, final File path_to_local_clustalo ) { _path_to_local_mafft = createLocalPath( path_to_local_mafft, "mafft" ); - _path_to_local_kalign = createLocalPath( path_to_local_kalign, "kalign" ); + _path_to_local_fastme = createLocalPath( path_to_local_fastme, "fastme" ); _path_to_local_raxml = createLocalPath( path_to_local_raxml, "raxml" ); _path_to_local_clustalo = createLocalPath( path_to_local_clustalo, "clustalo" ); diff --git a/forester/java/src/org/forester/archaeopteryx/tools/PhyloInferenceDialog.java b/forester/java/src/org/forester/archaeopteryx/tools/PhyloInferenceDialog.java index fbfd4c2..399c521 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/PhyloInferenceDialog.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/PhyloInferenceDialog.java @@ -78,13 +78,16 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { private JTextField _input_seqs_min_length_tf; private JTextField _input_seqs_max_length_tf; private JTextField _input_seqs_type_tf; - private JTextField _input_seqs_msa_program_name_tf; - private JTextField _input_seqs_msa_paramenters_tf; + + private JTextField _mafft_paramenters_tf; + private JTextField _clustalo_paramenters_tf; private JTextField _msa_processing_max_allowed_gap_ratio_tf; private JTextField _msa_processing_min_allowed_length_tf; private JTextField _random_seed_tf; private JCheckBox _execute_msa_processing_cb; private JCheckBox _msa_processing_remove_all_gap_columns_cb; + private JCheckBox _mafft_cb; + private JCheckBox _clustalo_cb; private JCheckBox _save_pwd_file_cb; private JCheckBox _save_processed_msa_cb; private JCheckBox _save_original_msa_cb; @@ -108,9 +111,11 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { final JPanel inputfile_pnl_1 = new JPanel(); final JPanel inputfile_pnl_2 = new JPanel(); final JPanel inputfile_pnl_3 = new JPanel(); + final JPanel inputfile_pnl_4 = new JPanel(); inputfile_pnl_1.setLayout( new FlowLayout() ); inputfile_pnl_2.setLayout( new FlowLayout() ); inputfile_pnl_3.setLayout( new FlowLayout() ); + inputfile_pnl_4.setLayout( new FlowLayout() ); inputfile_pnl_1.add( new JLabel( "Input Sequence File:" ) ); inputfile_pnl_1.add( _input_seqs_tf = new JTextField() ); inputfile_pnl_1.add( _select_input_seqs_btn = new JButton( "Select Input File" ) ); @@ -125,11 +130,15 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { inputfile_pnl_2.add( _input_seqs_max_length_tf = new JTextField() ); inputfile_pnl_2.add( new JLabel( "Type:" ) ); inputfile_pnl_2.add( _input_seqs_type_tf = new JTextField() ); - inputfile_pnl_3.add( new JLabel( "Mutiple Sequence Alignment: " ) ); - inputfile_pnl_3.add( new JLabel( "Program: " ) ); - inputfile_pnl_3.add( _input_seqs_msa_program_name_tf = new JTextField() ); + + + inputfile_pnl_3.add( _mafft_cb = new JCheckBox( "MAFFT") ); inputfile_pnl_3.add( new JLabel( "Parameters: " ) ); - inputfile_pnl_3.add( _input_seqs_msa_paramenters_tf = new JTextField() ); + inputfile_pnl_3.add( _mafft_paramenters_tf = new JTextField() ); + + inputfile_pnl_4.add( _clustalo_cb = new JCheckBox( "ClustalO") ); + inputfile_pnl_4.add( new JLabel( "Parameters: " ) ); + inputfile_pnl_4.add( _clustalo_paramenters_tf = new JTextField() ); _input_seqs_median_length_tf.setColumns( 4 ); _input_seqs_min_length_tf.setColumns( 4 ); _input_seqs_max_length_tf.setColumns( 4 ); @@ -142,12 +151,16 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { _input_seqs_max_length_tf.setEditable( false ); _input_seqs_number_tf.setEditable( false ); _input_seqs_type_tf.setEditable( false ); - _input_seqs_msa_program_name_tf.setEditable( false ); - _input_seqs_msa_paramenters_tf.setColumns( 26 ); + + _mafft_paramenters_tf.setColumns( 26 ); + _mafft_paramenters_tf.setText( "--maxiterate 1000 --localpair" ); + _clustalo_paramenters_tf.setColumns( 26 ); + _clustalo_paramenters_tf.setText( "clustalo options" ); _select_input_seqs_btn.addActionListener( this ); _pnl.add( inputfile_pnl_1 ); _pnl.add( inputfile_pnl_2 ); _pnl.add( inputfile_pnl_3 ); + _pnl.add( inputfile_pnl_4 ); } else { setTitle( "Phylogenetic Inference (from already aligned sequences) " ); @@ -273,9 +286,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { _value = JOptionPane.CANCEL_OPTION; if ( from_unaligned_seqs ) { updateSeqsItems(); - _input_seqs_msa_program_name_tf.setText( getPhylogeneticInferenceOptions().getMsaPrg() ); - _input_seqs_msa_paramenters_tf.setText( getPhylogeneticInferenceOptions().getMsaPrgParameters() ); - } + } else { updateMsaItems(); } @@ -376,8 +387,8 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener { } private void processMsaPrgParameters() { - if ( _input_seqs_msa_paramenters_tf != null ) { - getPhylogeneticInferenceOptions().setMsaPrgParameters( _input_seqs_msa_paramenters_tf.getText() ); + if ( _mafft_paramenters_tf != null ) { + getPhylogeneticInferenceOptions().setMsaPrgParameters( _mafft_paramenters_tf.getText() ); } } diff --git a/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java b/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java index c1aefc5..66fbdbc 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java @@ -86,7 +86,7 @@ public class PhylogeneticInferrer extends RunnableProcess { _options = options; } - private Msa inferMsa() throws IOException, InterruptedException { + private Msa inferMsa( final MSA_PRG msa_prg ) throws IOException, InterruptedException { // final File temp_seqs_file = File.createTempFile( "__msa__temp__", ".fasta" ); // if ( DEBUG ) { // System.out.println(); @@ -97,8 +97,17 @@ public class PhylogeneticInferrer extends RunnableProcess { // final BufferedWriter writer = new BufferedWriter( new FileWriter( temp_seqs_file ) ); // SequenceWriter.writeSeqs( _seqs, writer, SEQ_FORMAT.FASTA, 100 ); // writer.close(); - final List opts = processMafftOptions(); - return runMAFFT( _seqs, opts ); + switch ( msa_prg ) { + case MAFFT: + return runMAFFT( _seqs, processMafftOptions() ); + + case CLUSTAL_O: + return runClustalOmega( _seqs, processMafftOptions() ); + default: + return null; + } + + } private List processMafftOptions() { @@ -160,7 +169,7 @@ public class PhylogeneticInferrer extends RunnableProcess { if ( _msa == null ) { Msa msa = null; try { - msa = inferMsa(); + msa = inferMsa( MSA_PRG.MAFFT ); } catch ( final IOException e ) { end( _mf ); @@ -275,13 +284,13 @@ public class PhylogeneticInferrer extends RunnableProcess { return msa; } - private Msa runClustalOmega( final File input_seqs, final List opts ) throws IOException, + private Msa runClustalOmega( final List seqs, final List opts ) throws IOException, InterruptedException { Msa msa = null; final MsaInferrer clustalo = ClustalOmega.createInstance( _mf.getInferenceManager().getPathToLocalClustalo() .getCanonicalPath() ); try { - msa = clustalo.infer( input_seqs, opts ); + msa = clustalo.infer( seqs, opts ); } catch ( final IOException e ) { System.out.println( clustalo.getErrorDescription() ); @@ -338,4 +347,8 @@ public class PhylogeneticInferrer extends RunnableProcess { } } } + + public enum MSA_PRG { + MAFFT, CLUSTAL_O; + } } diff --git a/forester/java/src/org/forester/msa/ClustalOmega.java b/forester/java/src/org/forester/msa/ClustalOmega.java index 72db9d3..f6d4f65 100644 --- a/forester/java/src/org/forester/msa/ClustalOmega.java +++ b/forester/java/src/org/forester/msa/ClustalOmega.java @@ -25,12 +25,16 @@ package org.forester.msa; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.forester.io.parsers.FastaParser; +import org.forester.io.writers.SequenceWriter; +import org.forester.io.writers.SequenceWriter.SEQ_FORMAT; import org.forester.sequence.Sequence; import org.forester.util.SystemCommandExecutor; @@ -67,6 +71,19 @@ public final class ClustalOmega extends MsaInferrer { return _exit_code; } + + public Msa infer( final List seqs, final List opts ) throws IOException, InterruptedException { + final File file = File.createTempFile( "__clustalo_input_", ".fasta" ); + file.deleteOnExit(); + final BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); + SequenceWriter.writeSeqs( seqs, writer, SEQ_FORMAT.FASTA, 100 ); + writer.close(); + final Msa msa = infer( file, opts ); + file.delete(); + return msa; + } + + @Override public Msa infer( final File path_to_input_seqs, final List opts ) throws IOException, InterruptedException { init(); @@ -98,9 +115,5 @@ public final class ClustalOmega extends MsaInferrer { _exit_code = -100; } - @Override - public Msa infer( final List seqs, final List opts ) throws IOException, InterruptedException { - // TODO Auto-generated method stub - return null; - } + } -- 1.7.10.2