X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FArchaeopteryx.java;h=e1a8a477def7a95c7ebbfb1abb9af5509af4c411;hb=54d8e3a926c3cf3477199c8b85aca478230e223c;hp=3593218d28a0a1a1324d26c24c4a2d92f2b76582;hpb=f975d866f1108d926b27a92c3d270bbe8f1273e6;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java b/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java index 3593218..e1a8a47 100644 --- a/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java +++ b/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java @@ -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; @@ -31,26 +31,25 @@ import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; import org.forester.io.parsers.phyloxml.PhyloXmlParser; +import org.forester.io.parsers.util.ParserUtils; import org.forester.phylogeny.Phylogeny; -import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; +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 { - private final static boolean TEST = false; //TODO remove me! - public static MainFrame createApplication( final Phylogeny phylogeny ) { final Phylogeny[] phylogenies = new Phylogeny[ 1 ]; phylogenies[ 0 ] = phylogeny; 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 ) { return createApplication( phylogenies, "", "" ); } @@ -69,7 +68,7 @@ public final class Archaeopteryx { try { int filename_index = 0; if ( args.length == 0 ) { - conf = new Configuration( null, false, false ); + conf = new Configuration( null, false, false, true ); } else if ( args.length > 0 ) { // check for a config file @@ -80,7 +79,7 @@ public final class Archaeopteryx { if ( args[ 0 ].startsWith( "-open" ) ) { filename_index += 1; } - conf = new Configuration( config_filename, false, false ); + conf = new Configuration( config_filename, false, false, true ); if ( args.length > filename_index ) { f = new File( args[ filename_index ] ); final String err = ForesterUtil.isReadableFile( f ); @@ -88,18 +87,14 @@ public final class Archaeopteryx { ForesterUtil.fatalError( Constants.PRG_NAME, err ); } boolean nhx_or_nexus = false; - final PhylogenyParser p = ForesterUtil.createParserDependingOnFileType( f, conf - .isValidatePhyloXmlAgainstSchema() ); + final PhylogenyParser p = ParserUtils.createParserDependingOnFileType( f, conf + .isValidatePhyloXmlAgainstSchema() ); if ( p instanceof NHXParser ) { nhx_or_nexus = true; final NHXParser nhx = ( NHXParser ) p; nhx.setReplaceUnderscores( conf.isReplaceUnderscoresInNhParsing() ); nhx.setIgnoreQuotes( false ); - ForesterUtil.TAXONOMY_EXTRACTION te = ForesterUtil.TAXONOMY_EXTRACTION.NO; - if ( conf.isExtractPfamTaxonomyCodesInNhParsing() ) { - te = ForesterUtil.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY; - } - nhx.setTaxonomyExtraction( te ); + nhx.setTaxonomyExtraction( conf.getTaxonomyExtraction() ); } else if ( p instanceof NexusPhylogeniesParser ) { nhx_or_nexus = true; @@ -110,27 +105,12 @@ public final class Archaeopteryx { else if ( p instanceof PhyloXmlParser ) { MainFrameApplication.warnIfNotPhyloXmlValidation( conf ); } - phylogenies = ForesterUtil.readPhylogenies( p, f ); + phylogenies = PhylogenyMethods.readPhylogenies( p, f ); if ( nhx_or_nexus && conf.isInternalNumberAreConfidenceForNhParsing() ) { for( final Phylogeny phy : phylogenies ) { - ForesterUtil.transferInternalNodeNamesToConfidence( phy ); + PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" ); } } - // - // Phylogeny py = phylogenies[ 0 ]; - // for( final PhylogenyNodeIterator iter = py.iteratorExternalForward(); iter.hasNext(); ) { - // final PhylogenyNode node = iter.next(); - // System.out.println( node.getNodeData().getTaxonomy().getScientificName() + "\t" - // + node.getNodeData().getBinaryCharacters().getPresentCount() ); - // } - // for( final PhylogenyNodeIterator iter = py.iteratorPreorder(); iter.hasNext(); ) { - // final PhylogenyNode node = iter.next(); - // if ( !node.isExternal() ) { - // System.out.println( node.getNodeData().getTaxonomy().getScientificName() + "\t" - // + node.getNodeData().getBinaryCharacters().getPresentCount() ); - // } - // } - // } } } @@ -141,38 +121,21 @@ public final class Archaeopteryx { if ( f != null ) { title = f.getName(); } + File current_dir = null; + if ( ( phylogenies != null ) && ( phylogenies.length > 0 ) ) { + current_dir = new File( "." ); + } try { - String s = ""; - if ( TEST ) { - s = "/home/czmasek/888.xml"; - if ( ForesterUtil.isReadableFile( s ) != null ) { - s = "/Users/zma/888.xml"; - if ( ForesterUtil.isReadableFile( s ) != null ) { - s = "C:\\888.xml"; - if ( ForesterUtil.isReadableFile( s ) != null ) { - s = "C:\\Documents and Settings\\czmasek\\"; - } - } - } - } - if ( !TEST ) { - MainFrameApplication.createInstance( phylogenies, conf, title ); - } - else { - MainFrameApplication.createInstance( ParserBasedPhylogenyFactory.getInstance() - .create( s, new PhyloXmlParser() ), - conf, - title ); - } + MainFrameApplication.createInstance( phylogenies, conf, title, current_dir ); } - // catch ( final IOException ex ) { - // ForesterUtil.fatalError( Constants.PRG_NAME, "failed to start: " + ex.getLocalizedMessage() ); - // } - catch ( final Exception ex ) { - Util.unexpectedException( ex ); + catch ( final OutOfMemoryError e ) { + AptxUtil.outOfMemoryError( e ); + } + catch ( final Exception e ) { + AptxUtil.unexpectedException( e ); } - catch ( final Error err ) { - Util.unexpectedError( err ); + catch ( final Error e ) { + AptxUtil.unexpectedError( e ); } } } \ No newline at end of file