From: cmzmasek@gmail.com Date: Wed, 20 Nov 2013 21:16:07 +0000 (+0000) Subject: inprogress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=83086d32cf5b8c98a5c8d045187e07e4fa9bb752;p=jalview.git inprogress --- diff --git a/forester/java/src/org/forester/application/decoratorX.java b/forester/java/src/org/forester/application/decoratorX.java index a65f048..58a2b00 100644 --- a/forester/java/src/org/forester/application/decoratorX.java +++ b/forester/java/src/org/forester/application/decoratorX.java @@ -48,7 +48,7 @@ public class decoratorX { System.exit( -1 ); } final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final PhyloXmlParser xml_parser = new PhyloXmlParser(); + final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating(); final Phylogeny phy = factory.create( intree, xml_parser )[ 0 ]; final BasicTable t = BasicTableParser.parse( intable, '\t' ); final PhylogenyNodeIterator it = phy.iteratorExternalForward(); diff --git a/forester/java/src/org/forester/application/dom_dup.java b/forester/java/src/org/forester/application/dom_dup.java index 64b4640..e9cdba0 100644 --- a/forester/java/src/org/forester/application/dom_dup.java +++ b/forester/java/src/org/forester/application/dom_dup.java @@ -51,7 +51,7 @@ public class dom_dup { final File intree_file = cla.getFile( 2 ); final File species_groups_file = cla.getFile( 1 ); final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny phy = factory.create( intree_file, new PhyloXmlParser() )[ 0 ]; + final Phylogeny phy = factory.create( intree_file, PhyloXmlParser.createPhyloXmlParserXsdValidating() )[ 0 ]; ForesterUtil.programMessage( PRG_NAME, "Pattern string: " + pattern_str ); final Pattern pattern = Pattern.compile( pattern_str ); ForesterUtil.programMessage( PRG_NAME, "Pattern is: " + pattern ); diff --git a/forester/java/src/org/forester/application/gsdi.java b/forester/java/src/org/forester/application/gsdi.java index b16b733..7e2d514 100644 --- a/forester/java/src/org/forester/application/gsdi.java +++ b/forester/java/src/org/forester/application/gsdi.java @@ -180,7 +180,7 @@ public final class gsdi { } try { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - gene_tree = factory.create( gene_tree_file, new PhyloXmlParser() )[ 0 ]; + gene_tree = factory.create( gene_tree_file, PhyloXmlParser.createPhyloXmlParserXsdValidating() )[ 0 ]; } catch ( final IOException e ) { fatalError( "error", diff --git a/forester/java/src/org/forester/application/subtree_feature_count.java b/forester/java/src/org/forester/application/subtree_feature_count.java index c5fe6f7..57d4620 100644 --- a/forester/java/src/org/forester/application/subtree_feature_count.java +++ b/forester/java/src/org/forester/application/subtree_feature_count.java @@ -45,7 +45,7 @@ public class subtree_feature_count { final double depth = cla.getOptionValueAsDouble( DEPTH_OPTION ); final File intree_file = cla.getFile( 0 ); final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny phy = factory.create( intree_file, new PhyloXmlParser() )[ 0 ]; + final Phylogeny phy = factory.create( intree_file, PhyloXmlParser.createPhyloXmlParserXsdValidating() )[ 0 ]; execute( phy, depth ); } catch ( final Exception e ) { @@ -56,7 +56,11 @@ public class subtree_feature_count { private static StringBuilder analyzeSubtree( final PhylogenyNode n, final double depth ) { final PhylogenyNode node = moveUp( n, depth ); - for( final PhylogenyNode ext : node.getAllExternalDescendants() ) { + final List ext_descs = node.getAllExternalDescendants(); + for( final PhylogenyNode ext : ext_descs ) { + if ( ext.getIndicator() != 0 ) { + throw new RuntimeException( "this should not have happened" ); + } ext.setIndicator( ( byte ) 1 ); } int xray = 0; @@ -66,7 +70,7 @@ public class subtree_feature_count { PhylogenyNode first_node = null; PhylogenyNode last_node = null; int c = 0; - for( final PhylogenyNode ext : node.getAllExternalDescendants() ) { + for( final PhylogenyNode ext : ext_descs ) { if ( is_first ) { first_node = ext; is_first = false; diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 368499a..5d13def 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1761,7 +1761,7 @@ public final class MainFrameApplication extends MainFrame { } } if ( xml_parser == null ) { - xml_parser = new PhyloXmlParser(); + xml_parser = PhyloXmlParser.createPhyloXmlParser(); } return xml_parser; } @@ -2227,7 +2227,8 @@ public final class MainFrameApplication extends MainFrame { if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) { if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrameApplication.xmlfilter ) { try { - final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new PhyloXmlParser(), file ); + final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser + .createPhyloXmlParserXsdValidating(), file ); t = trees[ 0 ]; } catch ( final Exception e ) { @@ -2248,7 +2249,8 @@ public final class MainFrameApplication extends MainFrame { // "*.*": else { try { - final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new PhyloXmlParser(), file ); + final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser + .createPhyloXmlParserXsdValidating(), file ); t = trees[ 0 ]; } catch ( final Exception e ) { diff --git a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java index 1fb4a59..184e35e 100644 --- a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java +++ b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java @@ -132,7 +132,7 @@ public class UrlTreeReader implements Runnable { ( ( NHXParser ) parser ).setGuessRootedness( true ); break; case PHYLOXML: - parser = new PhyloXmlParser(); + parser = PhyloXmlParser.createPhyloXmlParserXsdValidating(); break; default: throw new IllegalArgumentException( "unknown format: " + client.getReturnFormat() ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlParser.java index 983048f..8ca07b9 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlParser.java @@ -75,7 +75,7 @@ public class PhyloXmlParser implements PhylogenyParser { private StringBuffer _error_messages; private StringBuffer _warning_messages; - public PhyloXmlParser() { + private PhyloXmlParser() { init(); reset(); } @@ -279,6 +279,11 @@ public class PhyloXmlParser implements PhylogenyParser { return xml_parser; } + public static PhyloXmlParser createPhyloXmlParser() { + final PhyloXmlParser xml_parser = new PhyloXmlParser(); + return xml_parser; + } + private class PhyloXmlParserErrorHandler extends DefaultHandler { @Override diff --git a/forester/java/src/org/forester/io/parsers/util/ParserUtils.java b/forester/java/src/org/forester/io/parsers/util/ParserUtils.java index 7931248..bbd9820 100644 --- a/forester/java/src/org/forester/io/parsers/util/ParserUtils.java +++ b/forester/java/src/org/forester/io/parsers/util/ParserUtils.java @@ -76,7 +76,7 @@ public final class ParserUtils { PhylogenyParser parser = null; final String first_line = ForesterUtil.getFirstLine( file ).trim().toLowerCase(); if ( first_line.startsWith( "<" ) ) { - parser = new PhyloXmlParser(); + parser = PhyloXmlParser.createPhyloXmlParser(); if ( phyloxml_validate_against_xsd ) { final ClassLoader cl = PhyloXmlParser.class.getClassLoader(); final URL xsd_url = cl.getResource( ForesterConstants.LOCAL_PHYLOXML_XSD_RESOURCE ); @@ -127,7 +127,7 @@ public final class ParserUtils { } else if ( filename_lc.endsWith( ".xml" ) || filename_lc.endsWith( ".px" ) || filename_lc.endsWith( "phyloxml" ) || filename_lc.endsWith( ".zip" ) ) { - parser = new PhyloXmlParser(); + parser = PhyloXmlParser.createPhyloXmlParser(); if ( phyloxml_validate_against_xsd ) { final ClassLoader cl = PhyloXmlParser.class.getClassLoader(); final URL xsd_url = cl.getResource( ForesterConstants.LOCAL_PHYLOXML_XSD_RESOURCE ); @@ -168,7 +168,7 @@ public final class ParserUtils { if ( parser == null ) { final String first_line = ForesterUtil.getFirstLine( url ).trim().toLowerCase(); if ( first_line.startsWith( "<" ) ) { - parser = new PhyloXmlParser(); + parser = PhyloXmlParser.createPhyloXmlParser(); if ( phyloxml_validate_against_xsd ) { final ClassLoader cl = PhyloXmlParser.class.getClassLoader(); final URL xsd_url = cl.getResource( ForesterConstants.LOCAL_PHYLOXML_XSD_RESOURCE ); diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index ae43b31..fc210a5 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -1365,7 +1365,7 @@ public final class Test { private static boolean testBasicPhyloXMLparsing() { try { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final PhyloXmlParser xml_parser = new PhyloXmlParser(); + final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser(); final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml", xml_parser ); if ( xml_parser.getErrorCount() > 0 ) { @@ -1558,7 +1558,7 @@ public final class Test { private static boolean testBasicPhyloXMLparsingRoundtrip() { try { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final PhyloXmlParser xml_parser = new PhyloXmlParser(); + final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser(); if ( USE_LOCAL_PHYLOXML_SCHEMA ) { xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD ); } @@ -1910,7 +1910,7 @@ public final class Test { // Do nothing -- means were not running from jar. } if ( xml_parser == null ) { - xml_parser = new PhyloXmlParser(); + xml_parser = PhyloXmlParser.createPhyloXmlParser(); if ( USE_LOCAL_PHYLOXML_SCHEMA ) { xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD ); } @@ -8540,7 +8540,7 @@ public final class Test { // Do nothing -- means were not running from jar. } if ( xml_parser == null ) { - xml_parser = new PhyloXmlParser(); + xml_parser = PhyloXmlParser.createPhyloXmlParser(); if ( USE_LOCAL_PHYLOXML_SCHEMA ) { xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD ); }