inprogress
[jalview.git] / forester / java / src / org / forester / test / examples / Example4.java
1 // $Id:
2 //
3 // forester -- software libraries and applications
4 // for evolutionary biology research and applications.
5 //
6 // Copyright (C) 2008-2011 Christian M. Zmasek
7 // Copyright (C) 2008-2011 Burnham Institute for Medical Research
8 // All rights reserved
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 //
24 // Contact: phylosoft @ gmail . com
25 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26
27 package org.forester.test.examples;
28
29 import java.io.File;
30 import java.io.IOException;
31
32 import org.forester.io.parsers.PhylogenyParser;
33 import org.forester.io.parsers.util.ParserUtils;
34 import org.forester.io.writers.PhylogenyWriter;
35 import org.forester.phylogeny.Phylogeny;
36 import org.forester.phylogeny.PhylogenyMethods;
37 import org.forester.util.ForesterUtil;
38
39 public class Example4 {
40
41     public static void main( final String[] args ) {
42         // Reading-in of (a) tree(s) from a file.
43         final File treefile = new File( "/home/czmasek/tol_117_TEST.xml" );
44         PhylogenyParser parser = null;
45         try {
46             parser = ParserUtils.createParserDependingOnFileType( treefile, true );
47         }
48         catch ( final IOException e ) {
49             e.printStackTrace();
50         }
51         Phylogeny[] phys = null;
52         try {
53             phys = PhylogenyMethods.readPhylogenies( parser, treefile );
54         }
55         catch ( final IOException e ) {
56             e.printStackTrace();
57         }
58         // Writing trees to a file.
59         final File outfile = new File( "/home/czmasek/tol_117_TEST_out.xml" );
60         try {
61             final PhylogenyWriter writer = new PhylogenyWriter();
62             writer.toPhyloXML( phys, 0, outfile, ForesterUtil.LINE_SEPARATOR );
63         }
64         catch ( final Exception e ) {
65             e.printStackTrace();
66         }
67     }
68 }