// 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;
import org.forester.analysis.TaxonomyDataManager;
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.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
import org.forester.io.parsers.tol.TolParser;
import org.forester.io.parsers.util.ParserUtils;
System.out.println( "[" + applet_name + "] > " + message );
}
- final static Phylogeny[] readPhylogeniesFromUrl( final URL url, final boolean phyloxml_validate_against_xsd )
+ final static Phylogeny[] readPhylogeniesFromUrl( final URL url,
+ final boolean phyloxml_validate_against_xsd,
+ final boolean replace_underscores,
+ final boolean internal_numbers_are_confidences,
+ final TAXONOMY_EXTRACTION taxonomy_extraction )
throws FileNotFoundException, IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- PhylogenyParser parser = null;
+ final PhylogenyParser parser;
+ boolean nhx_or_nexus = false;
if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
parser = new TolParser();
}
else {
parser = ParserUtils.createParserDependingOnUrlContents( url, phyloxml_validate_against_xsd );
+ if ( parser instanceof NHXParser ) {
+ nhx_or_nexus = true;
+ final NHXParser nhx = ( NHXParser ) parser;
+ nhx.setReplaceUnderscores( replace_underscores );
+ nhx.setIgnoreQuotes( false );
+ nhx.setTaxonomyExtraction( taxonomy_extraction );
+ }
+ else if ( parser instanceof NexusPhylogeniesParser ) {
+ nhx_or_nexus = true;
+ final NexusPhylogeniesParser nex = ( NexusPhylogeniesParser ) parser;
+ nex.setReplaceUnderscores( replace_underscores );
+ nex.setIgnoreQuotes( false );
+ }
+ }
+ final Phylogeny[] phys = factory.create( url.openStream(), parser );
+ if ( nhx_or_nexus && internal_numbers_are_confidences ) {
+ for( final Phylogeny phy : phys ) {
+ PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
+ }
}
- return factory.create( url.openStream(), parser );
+ return phys;
}
final static void removeBranchColors( final Phylogeny phy ) {
}
}
- final static void unexpectedError( final Error err ) {
- err.printStackTrace();
+ final static void unexpectedError( final Error e ) {
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
final StringBuffer sb = new StringBuffer();
- for( final StackTraceElement s : err.getStackTrace() ) {
+ for( final StackTraceElement s : e.getStackTrace() ) {
sb.append( s + "\n" );
}
JOptionPane
.showMessageDialog( null,
"An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nError: " + err + "\n" + sb,
+ + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n"
+ + sb,
"Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
JOptionPane.ERROR_MESSAGE );
System.exit( -1 );
}
- final static void unexpectedException( final Exception ex ) {
- ex.printStackTrace();
+ final static void outOfMemoryError( final OutOfMemoryError e ) {
+ System.err.println();
+ System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
+ System.err.println();
+ e.printStackTrace();
+ System.err.println();
+ JOptionPane.showMessageDialog( null,
+ "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
+ + "\n\nError: " + e.getLocalizedMessage(),
+ "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
+ JOptionPane.ERROR_MESSAGE );
+ System.exit( -1 );
+ }
+
+ final static void unexpectedException( final Exception e ) {
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
final StringBuffer sb = new StringBuffer();
- for( final StackTraceElement s : ex.getStackTrace() ) {
+ for( final StackTraceElement s : e.getStackTrace() ) {
sb.append( s + "\n" );
}
- JOptionPane.showMessageDialog( null, "An unexpected exception has occured. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nException: " + ex + "\n" + sb, "Unexpected Exception ["
- + Constants.PRG_NAME + Constants.VERSION + "]", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( null,
+ "An unexpected exception has occured. \nPlease contact: "
+ + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage()
+ + "\n" + sb,
+ "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]",
+ JOptionPane.ERROR_MESSAGE );
}
final static String writePhylogenyToGraphicsByteArrayOutputStream( final ByteArrayOutputStream baos,