- 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,
- final boolean midpoint_reroot ) throws FileNotFoundException,
- IOException {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- 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 );
- }
- }
- AptxUtil.printAppletMessage( "Archaeopteryx", "parser is " + parser.getName() );
- final Phylogeny[] phys = factory.create( url.openStream(), parser );
- if ( phys != null ) {
- if ( nhx_or_nexus && internal_numbers_are_confidences ) {
- for( final Phylogeny phy : phys ) {
- PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
- }
- }
- if ( midpoint_reroot ) {
- for( final Phylogeny phy : phys ) {
- PhylogenyMethods.midpointRoot( phy );
- PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
- }
- }