X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fapplication%2Fannotator.java;h=4374f5321cd1ef0c818e57bab86e34661440d1cd;hb=0b39293d1577083551ba528d0ac7afcacbf69dde;hp=8ecc9a416d2130f1e3ee22198612057cb2adae71;hpb=0ac19dbd836236ac1c4da82415702836b7c54843;p=jalview.git diff --git a/forester/java/src/org/forester/application/annotator.java b/forester/java/src/org/forester/application/annotator.java index 8ecc9a4..4374f53 100644 --- a/forester/java/src/org/forester/application/annotator.java +++ b/forester/java/src/org/forester/application/annotator.java @@ -28,6 +28,7 @@ package org.forester.application; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.forester.analysis.AncestralTaxonomyInference; @@ -75,42 +76,50 @@ public final class annotator { infiles.add( file ); } } + Collections.sort( infiles ); int c = 0; for( final File infile : infiles ) { System.out.println( ++c + "/" + infiles.size() + ": " + infile ); - Phylogeny phy = null; - try { - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phylogenies = factory.create( infile, - PhyloXmlParser.createPhyloXmlParserXsdValidating() ); - phy = phylogenies[ 0 ]; - } - catch ( final Exception e ) { - ForesterUtil.fatalError( PRG_NAME, "failed to read phylgenies from [" + infile + "] [" + e.getMessage() - + "]" ); - } - try { - obtainSeqInformation( phy ); - } - catch ( final IOException e ) { - ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); - } - try { - inferTaxonomyFromDescendents( phy ); - } - catch ( final IOException e ) { - ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); - } - catch ( final AncestralTaxonomyInferenceException e ) { - ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); - } final File outfile = new File( outdir.getAbsolutePath().toString() + "/" + infile.getName() ); - try { - final PhylogenyWriter w = new PhylogenyWriter(); - w.toPhyloXML( phy, 0, outfile ); + if ( outfile.exists() ) { + System.out.println( outfile + " already exists" ); } - catch ( final IOException e ) { - ForesterUtil.fatalError( PRG_NAME, "failed to write output [" + e.getMessage() + "]" ); + else { + Phylogeny phy = null; + try { + final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); + final Phylogeny[] phylogenies = factory.create( infile, + PhyloXmlParser.createPhyloXmlParserXsdValidating() ); + phy = phylogenies[ 0 ]; + } + catch ( final Exception e ) { + ForesterUtil + .fatalError( PRG_NAME, "failed to read phylgenies from [" + infile + "] [" + e.getMessage() + + "]" ); + } + try { + obtainSeqInformation( phy ); + } + catch ( final IOException e ) { + ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); + } + // try { + // inferTaxonomyFromDescendents( phy ); + // } + // catch ( final IOException e ) { + // ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); + // } + // catch ( final AncestralTaxonomyInferenceException e ) { + // ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); + // } + //phy.setRerootable( false ); + try { + final PhylogenyWriter w = new PhylogenyWriter(); + w.toPhyloXML( phy, 0, outfile ); + } + catch ( final IOException e ) { + ForesterUtil.fatalError( PRG_NAME, "failed to write output [" + e.getMessage() + "]" ); + } } } } @@ -120,7 +129,7 @@ public final class annotator { } private static void inferTaxonomyFromDescendents( final Phylogeny phy ) throws IOException, - AncestralTaxonomyInferenceException { + AncestralTaxonomyInferenceException { AncestralTaxonomyInference.inferTaxonomyFromDescendents( phy ); }