JAL-2797 added constructor including embedded/standalone boolean
[jalview.git] / forester / java / src / org / forester / archaeopteryx / Archaeopteryx.java
index 6a28ef7..43481f5 100644 (file)
@@ -21,7 +21,7 @@
 // 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;
 
@@ -36,12 +36,6 @@ import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.util.ForesterUtil;
 
-//
-// java -javaagent:shiftone-jrat.jar -cp
-// $HOME/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester-atv/java/forester.jar:.
-// org.forester.archaeopteryx.Archaeopteryx
-// -c $HOME/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester-atv/_aptx_configuration_file
-//
 public final class Archaeopteryx {
 
     public static MainFrame createApplication( final Phylogeny phylogeny ) {
@@ -50,6 +44,15 @@ public final class Archaeopteryx {
         return createApplication( phylogenies, "", "" );
     }
 
+    public static MainFrame createApplication( final Phylogeny phylogeny, final Configuration config, final String title ) {
+        final Phylogeny[] phylogenies = new Phylogeny[ 1 ];
+        phylogenies[ 0 ] = phylogeny;
+        return MainFrameApplication.createInstance( phylogenies, config, title );
+    }
+    public static MainFrame createApplication( final Phylogeny[] phylogenies, final Configuration config, final String title ) {
+        return MainFrameApplication.createInstance( phylogenies, config, title );
+    }
+    
     public static MainFrame createApplication( final Phylogeny[] phylogenies ) {
         return createApplication( phylogenies, "", "" );
     }
@@ -60,7 +63,7 @@ public final class Archaeopteryx {
         return MainFrameApplication.createInstance( phylogenies, config_file_name, title );
     }
 
-    public static void main( final String args[] ) {
+    public static MainFrame main( final String args[] ) {
         Phylogeny[] phylogenies = null;
         String config_filename = null;
         Configuration conf = null;
@@ -84,21 +87,17 @@ public final class Archaeopteryx {
                     f = new File( args[ filename_index ] );
                     final String err = ForesterUtil.isReadableFile( f );
                     if ( !ForesterUtil.isEmpty( err ) ) {
-                        ForesterUtil.fatalError( Constants.PRG_NAME, err );
+                        ForesterUtil.fatalError( AptxConstants.PRG_NAME, err );
                     }
                     boolean nhx_or_nexus = false;
                     final PhylogenyParser p = ParserUtils.createParserDependingOnFileType( f, conf
-                            .isValidatePhyloXmlAgainstSchema() );
+                                                                                           .isValidatePhyloXmlAgainstSchema() );
                     if ( p instanceof NHXParser ) {
                         nhx_or_nexus = true;
                         final NHXParser nhx = ( NHXParser ) p;
                         nhx.setReplaceUnderscores( conf.isReplaceUnderscoresInNhParsing() );
                         nhx.setIgnoreQuotes( false );
-                        NHXParser.TAXONOMY_EXTRACTION te = NHXParser.TAXONOMY_EXTRACTION.NO;
-                        if ( conf.isExtractPfamTaxonomyCodesInNhParsing() ) {
-                            te = NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY;
-                        }
-                        nhx.setTaxonomyExtraction( te );
+                        nhx.setTaxonomyExtraction( conf.getTaxonomyExtraction() );
                     }
                     else if ( p instanceof NexusPhylogeniesParser ) {
                         nhx_or_nexus = true;
@@ -112,14 +111,14 @@ public final class Archaeopteryx {
                     phylogenies = PhylogenyMethods.readPhylogenies( p, f );
                     if ( nhx_or_nexus && conf.isInternalNumberAreConfidenceForNhParsing() ) {
                         for( final Phylogeny phy : phylogenies ) {
-                            PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
+                            PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
                         }
                     }
                 }
             }
         }
         catch ( final Exception e ) {
-            ForesterUtil.fatalError( Constants.PRG_NAME, "failed to start: " + e.getLocalizedMessage() );
+            ForesterUtil.fatalError( AptxConstants.PRG_NAME, "failed to start: " + e.getLocalizedMessage() );
         }
         String title = "";
         if ( f != null ) {
@@ -130,13 +129,16 @@ public final class Archaeopteryx {
             current_dir = new File( "." );
         }
         try {
-            MainFrameApplication.createInstance( phylogenies, conf, title, current_dir );
+           return MainFrameApplication.createInstance( phylogenies, conf, title, current_dir );
         }
-        catch ( final Exception ex ) {
-            AptxUtil.unexpectedException( ex );
+        catch ( final OutOfMemoryError e ) {
+            AptxUtil.outOfMemoryError( e );
         }
-        catch ( final Error err ) {
-            AptxUtil.unexpectedError( err );
+        catch ( final Exception e ) {
+            AptxUtil.unexpectedException( e );
         }
-    }
+        catch ( final Error e ) {
+            AptxUtil.unexpectedError( e );
+        }
+    return null;}
 }
\ No newline at end of file