2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org/forester
26 package org.forester.application;
29 import java.io.FileWriter;
30 import java.io.PrintWriter;
32 import org.forester.io.parsers.PhylogenyParser;
33 import org.forester.io.parsers.util.ParserUtils;
34 import org.forester.phylogeny.Phylogeny;
35 import org.forester.phylogeny.PhylogenyNode;
36 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
37 import org.forester.phylogeny.factories.PhylogenyFactory;
39 public class printSameOrder {
41 public static void main( final String args[] ) {
42 Phylogeny tree = null;
43 PhylogenyNode node = null;
44 PrintWriter out = null;
45 File infile = null, outfile = null;
46 if ( args.length != 2 ) {
47 System.err.println( "\nprintSameOrder: Wrong number of arguments." );
48 System.err.println( "Usage: \"java printSameOrder <infile> <outfile>\"\n" );
51 infile = new File( args[ 0 ] );
52 outfile = new File( args[ 1 ] );
54 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
55 final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( infile, true );
56 tree = factory.create( infile, pp )[ 0 ];
58 catch ( final Exception e ) {
59 System.err.println( e + "\nCould not read " + infile + "\n" );
62 node = tree.getFirstExternalNode();
64 out = new PrintWriter( new FileWriter( outfile ), true );
65 while ( node != null ) {
66 out.println( node.getName() );
67 node = node.getNextExternalNode();
70 catch ( final Exception e ) {
71 System.err.println( e + "\nException during writing.\n" );