(no commit message)
[jalview.git] / forester / java / src / org / forester / archaeopteryx / tools / PhylogeneticInferrer.java
index 7e0ec77..6cf6614 100644 (file)
@@ -58,13 +58,13 @@ import org.forester.sequence.Sequence;
 import org.forester.tools.ConfidenceAssessor;
 import org.forester.util.ForesterUtil;
 
-public class PhylogeneticInferrer implements Runnable {
+public class PhylogeneticInferrer extends RunnableProcess {
 
     private Msa                                _msa;
     private final MainFrameApplication         _mf;
     private final PhylogeneticInferenceOptions _options;
     private final List<Sequence>               _seqs;
-    private final boolean DEBUG = true;
+    private final boolean                      DEBUG           = true;
     public final static String                 MSA_FILE_SUFFIX = ".aln";
     public final static String                 PWD_FILE_SUFFIX = ".pwd";
 
@@ -89,9 +89,9 @@ public class PhylogeneticInferrer implements Runnable {
     private Msa inferMsa() throws IOException, InterruptedException {
         final File temp_seqs_file = File.createTempFile( "__msa__temp__", ".fasta" );
         if ( DEBUG ) {
-        System.out.println();
-        System.out.println( "temp file: " + temp_seqs_file );
-        System.out.println();
+            System.out.println();
+            System.out.println( "temp file: " + temp_seqs_file );
+            System.out.println();
         }
         //final File temp_seqs_file = new File( _options.getTempDir() + ForesterUtil.FILE_SEPARATOR + "s.fasta" );
         final BufferedWriter writer = new BufferedWriter( new FileWriter( temp_seqs_file ) );
@@ -145,7 +145,7 @@ public class PhylogeneticInferrer implements Runnable {
                 e.printStackTrace();
             }
         }
-        final NeighborJoining nj = new NeighborJoining();
+        final NeighborJoining nj = NeighborJoining.createInstance();
         final Phylogeny phy = nj.execute( m );
         PhylogeneticInferrer.extractFastaInformation( phy );
         return phy;
@@ -156,12 +156,14 @@ public class PhylogeneticInferrer implements Runnable {
         if ( ( _msa == null ) && ( _seqs == null ) ) {
             throw new IllegalArgumentException( "cannot run phylogenetic analysis with null msa and seq array" );
         }
+        start( _mf, "phylogenetic inference" );
         if ( _msa == null ) {
             Msa msa = null;
             try {
                 msa = inferMsa();
             }
             catch ( final IOException e ) {
+                end( _mf );
                 JOptionPane.showMessageDialog( _mf,
                                                "Could not create multiple sequence alignment with \""
                                                        + _options.getMsaPrg() + "\" and the following parameters:\n\""
@@ -170,11 +172,12 @@ public class PhylogeneticInferrer implements Runnable {
                                                "Failed to Calculate MSA",
                                                JOptionPane.ERROR_MESSAGE );
                 if ( DEBUG ) {
-                e.printStackTrace();
+                    e.printStackTrace();
                 }
                 return;
             }
             catch ( final Exception e ) {
+                end( _mf );
                 JOptionPane.showMessageDialog( _mf,
                                                "Could not create multiple sequence alignment with \""
                                                        + _options.getMsaPrg() + "\" and the following parameters:\n\""
@@ -183,11 +186,12 @@ public class PhylogeneticInferrer implements Runnable {
                                                "Unexpected Exception During MSA Calculation",
                                                JOptionPane.ERROR_MESSAGE );
                 if ( DEBUG ) {
-                e.printStackTrace();
+                    e.printStackTrace();
                 }
                 return;
             }
             if ( msa == null ) {
+                end( _mf );
                 JOptionPane.showMessageDialog( _mf,
                                                "Could not create multiple sequence alignment with "
                                                        + _options.getMsaPrg() + "\nand the following parameters:\n\""
@@ -197,8 +201,8 @@ public class PhylogeneticInferrer implements Runnable {
                 return;
             }
             if ( DEBUG ) {
-            System.out.println( msa.toString() );
-            System.out.println( MsaMethods.calcBasicGapinessStatistics( msa ).toString() );
+                System.out.println( msa.toString() );
+                System.out.println( MsaMethods.calcBasicGapinessStatistics( msa ).toString() );
             }
             final MsaMethods msa_tools = MsaMethods.createInstance();
             if ( _options.isExecuteMsaProcessing() ) {
@@ -206,6 +210,7 @@ public class PhylogeneticInferrer implements Runnable {
                                                   _options.getMsaProcessingMinAllowedLength(),
                                                   msa );
                 if ( msa == null ) {
+                    end( _mf );
                     JOptionPane.showMessageDialog( _mf,
                                                    "Less than two sequences longer than "
                                                            + _options.getMsaProcessingMinAllowedLength()
@@ -216,9 +221,9 @@ public class PhylogeneticInferrer implements Runnable {
                 }
             }
             if ( DEBUG ) {
-            System.out.println( msa_tools.getIgnoredSequenceIds() );
-            System.out.println( msa.toString() );
-            System.out.println( MsaMethods.calcBasicGapinessStatistics( msa ).toString() );
+                System.out.println( msa_tools.getIgnoredSequenceIds() );
+                System.out.println( msa.toString() );
+                System.out.println( MsaMethods.calcBasicGapinessStatistics( msa ).toString() );
             }
             _msa = msa;
         }
@@ -237,7 +242,8 @@ public class PhylogeneticInferrer implements Runnable {
             ConfidenceAssessor.evaluate( "bootstrap", eval_phys, master_phy, true, 1 );
         }
         _mf.getMainPanel().addPhylogenyInNewTab( master_phy, _mf.getConfiguration(), "nj", "njpath" );
-        _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+        //  _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+        end( _mf );
         JOptionPane.showMessageDialog( _mf,
                                        "Inference successfully completed",
                                        "Inference Completed",