@Override
public final Phylogeny[] parse() throws IOException {
final List<Phylogeny> l = new ArrayList<Phylogeny>();
- int c = 0;
+ //int c = 0;
while ( hasNext() ) {
l.add( next() );
- c++;
+ // c++;
}
final Phylogeny[] p = new Phylogeny[ l.size() ];
for( int i = 0; i < l.size(); ++i ) {
_my_source_sbuff = null;
_my_source_sbuil = null;
_my_source_charary = null;
- determineSourceType( _source );
+ determineAndProcessSourceType( _source );
switch ( _input_type ) {
case STRING:
_my_source_br = null;
_allow_errors_in_distance_to_parent = allow_errors_in_distance_to_parent;
}
- private final void determineSourceType( final Object nhx_source ) throws IOException {
+ private final void determineAndProcessSourceType( final Object nhx_source ) throws IOException {
if ( nhx_source == null ) {
throw new PhylogenyParserException( getClass() + ": attempt to parse null object." );
}
_input_type = NHXParser.BUFFERED_READER;
_source_length = 0;
if ( _my_source_br != null ) {
- try {
- _my_source_br.close();
- }
- catch ( final IOException e ) {
- }
+ // I am REALLY not sure if it a "good" NOT to close the stream...
+// try {
+// _my_source_br.close();
+// }
+// catch ( final IOException e ) {
+// }
}
final File f = ( File ) nhx_source;
final String error = ForesterUtil.isReadableFile( f );
_input_type = NHXParser.BUFFERED_READER;
_source_length = 0;
if ( _my_source_br != null ) {
- try {
- _my_source_br.close();
- }
- catch ( final IOException e ) {
- }
+// I am REALLY not sure if it a "good" NOT to close the stream...
+// try {
+// _my_source_br.close();
+// }
+// catch ( final IOException e ) {
+// }
}
final InputStreamReader isr = new InputStreamReader( ( ( URL ) nhx_source ).openStream() );
_nhx_source = new BufferedReader( isr );
_input_type = NHXParser.BUFFERED_READER;
_source_length = 0;
if ( _my_source_br != null ) {
- try {
- _my_source_br.close();
- }
- catch ( final IOException e ) {
- }
+ // I am REALLY not sure if it a "good" NOT to close the stream...
+// try {
+// _my_source_br.close();
+// }
+// catch ( final IOException e ) {
+// }
}
final InputStreamReader isr = new InputStreamReader( ( InputStream ) nhx_source );
_nhx_source = new BufferedReader( isr );
private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
+ ForesterUtil.getFileSeparator() + "test_data"
+ ForesterUtil.getFileSeparator();
- private final static boolean PERFORM_DB_TESTS = true;
+ private final static boolean PERFORM_DB_TESTS = false;
private static final boolean PERFORM_WEB_TREE_ACCESS = true;
private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
+ ForesterConstants.PHYLO_XML_VERSION + "/"
System.exit( -1 );
}
final long start_time = new Date().getTime();
+
+ //
+ if ( Test.testNHXparsingFromURL() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ // System.exit( 1 );
+
+ //
+
+
+
System.out.print( "MSA entropy: " );
if ( Test.testMsaEntropy() ) {
System.out.println( "OK." );
}
catch ( final Exception e ) {
e.printStackTrace();
+ return false;
}
return true;
}
System.out.println( phys[ 1 ].toNewHampshire() );
return false;
}
- final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
+
+ final URL u2 = new URL( s );
+
+ final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
return false;
}
}
final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
final NHXParser p = new NHXParser();
- final URL u2 = new URL( s );
- p.setSource( u2 );
+ final URL u3 = new URL( s );
+ p.setSource( u3 );
if ( !p.hasNext() ) {
return false;
}
}
}
catch ( final Exception e ) {
+ System.out.println( e.toString());
e.printStackTrace();
+ return false;
}
return true;
}