JAL-2852 added framework for saving as EPS file
[jalview.git] / forester / java / src / org / forester / archaeopteryx / tools / PhyloInferenceDialog.java
index fbfd4c2..b6e65b6 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 //
 // Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.archaeopteryx.tools;
 
 import java.awt.Color;
 import java.awt.FlowLayout;
+import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.List;
@@ -48,7 +49,7 @@ import javax.swing.border.LineBorder;
 import org.forester.archaeopteryx.AptxUtil;
 import org.forester.archaeopteryx.MainFrameApplication;
 import org.forester.evoinference.distance.PairwiseDistanceCalculator.PWD_DISTANCE_METHOD;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
 import org.forester.util.BasicDescriptiveStatistics;
 import org.forester.util.DescriptiveStatistics;
 
@@ -78,13 +79,13 @@ 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                         _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                          _save_pwd_file_cb;
     private JCheckBox                          _save_processed_msa_cb;
     private JCheckBox                          _save_original_msa_cb;
@@ -95,7 +96,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
     public PhyloInferenceDialog( final MainFrameApplication frame,
                                  final PhylogeneticInferenceOptions options,
                                  final boolean from_unaligned_seqs ) {
-        super( frame, true );
+        super( (Frame) null, true );
         setVisible( false );
         _parent_frame = frame;
         _opts = options;
@@ -108,9 +109,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 +128,9 @@ 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() );
             _input_seqs_median_length_tf.setColumns( 4 );
             _input_seqs_min_length_tf.setColumns( 4 );
             _input_seqs_max_length_tf.setColumns( 4 );
@@ -142,12 +143,13 @@ 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" );
             _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) " );
@@ -202,7 +204,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
         distance_calc_pnl_1.add( _distance_calc_kimura_rb = new JRadioButton( "Kimura correction" ) );
         distance_calc_pnl_1.add( _distance_calc_poisson_rb = new JRadioButton( "Poisson" ) );
         distance_calc_pnl_1
-                .add( _distance_calc_fract_dissimilarity_rb = new JRadioButton( "Fractional dissimilarity" ) );
+        .add( _distance_calc_fract_dissimilarity_rb = new JRadioButton( "Fractional dissimilarity" ) );
         final ButtonGroup distance_calc_group_1 = new ButtonGroup();
         distance_calc_group_1.add( _distance_calc_kimura_rb );
         distance_calc_group_1.add( _distance_calc_poisson_rb );
@@ -273,8 +275,6 @@ 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();
@@ -334,7 +334,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
     private void processMsaProcessing() {
         getPhylogeneticInferenceOptions().setExecuteMsaProcessing( _execute_msa_processing_cb.isSelected() );
         getPhylogeneticInferenceOptions()
-                .setMsaProcessingRemoveAllGapColumns( _msa_processing_remove_all_gap_columns_cb.isSelected() );
+        .setMsaProcessingRemoveAllGapColumns( _msa_processing_remove_all_gap_columns_cb.isSelected() );
         int min_length = -1;
         try {
             min_length = Integer.parseInt( _msa_processing_min_allowed_length_tf.getText().trim() );
@@ -348,7 +348,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
         double msa_processing_max_allowed_gap_ratio = -1.0;
         try {
             msa_processing_max_allowed_gap_ratio = Double.parseDouble( _msa_processing_max_allowed_gap_ratio_tf
-                    .getText().trim() );
+                                                                       .getText().trim() );
         }
         catch ( final NumberFormatException e ) {
             msa_processing_max_allowed_gap_ratio = -1.0;
@@ -376,8 +376,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() );
         }
     }
 
@@ -387,7 +387,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
     }
 
     private void readInputSeqsFile() {
-        getParentFrame().readSeqsFromFile();
+        getParentFrame().readSeqsFromFileforPI();
         updateSeqsItems();
     }
 
@@ -410,7 +410,7 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
     private void updateMsaProcessingItem() {
         _execute_msa_processing_cb.setSelected( getPhylogeneticInferenceOptions().isExecuteMsaProcessing() );
         _msa_processing_remove_all_gap_columns_cb.setSelected( getPhylogeneticInferenceOptions()
-                .isMsaProcessingRemoveAllGapColumns() );
+                                                               .isMsaProcessingRemoveAllGapColumns() );
         if ( _opts.getMsaProcessingMaxAllowedGapRatio() > 0 ) {
             _msa_processing_max_allowed_gap_ratio_tf.setText( _opts.getMsaProcessingMaxAllowedGapRatio() + "" );
         }
@@ -478,9 +478,9 @@ public class PhyloInferenceDialog extends JDialog implements ActionListener {
         }
     }
 
-    DescriptiveStatistics calcSequenceStats( final List<Sequence> seqs ) {
+    DescriptiveStatistics calcSequenceStats( final List<MolecularSequence> seqs ) {
         final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
-        for( final Sequence s : seqs ) {
+        for( final MolecularSequence s : seqs ) {
             stats.addValue( s.getLength() );
         }
         return stats;