1 = forester Tutorial and Examples =
2 <wiki:toc max_depth="3" />
8 Documentation, tutorial, and examples for [http://www.phylosoft.org/forester/ forester].
10 *All examples require jar-file "forester.jar" to be in the class-path.*
12 Download: http://code.google.com/p/forester/downloads/list
14 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
17 Copyright (C) 2012 Christian M Zmasek. All rights reserved.
21 = Reading and writing of phylogenetic trees =
30 import java.io.IOException;
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;
39 public class Example {
41 public static void main( final String[] args ) {
42 // Reading-in of (a) tree(s) from a file.
43 final File treefile = new File( "/path/to/tree.xml" );
44 PhylogenyParser parser = null;
46 parser = ParserUtils.createParserDependingOnFileType( treefile, true );
48 catch ( final IOException e ) {
51 Phylogeny[] phys = null;
53 phys = PhylogenyMethods.readPhylogenies( parser, treefile );
55 catch ( final IOException e ) {
58 // Writing trees to a file.
59 final File outfile = new File( "/path/to/out_tree.xml" );
61 final PhylogenyWriter writer = new PhylogenyWriter();
62 writer.toPhyloXML( phys, 0, outfile, ForesterUtil.LINE_SEPARATOR );
64 catch ( final Exception e ) {
74 = Reading of phylogenetic trees and displaying them with Archaeopteryx =
82 import java.io.IOException;
84 import org.forester.archaeopteryx.Archaeopteryx;
85 import org.forester.io.parsers.util.ParserUtils;
86 import org.forester.io.parsers.PhylogenyParser;
87 import org.forester.phylogeny.Phylogeny;
88 import org.forester.phylogeny.PhylogenyMethods;
90 public class Example {
92 public static void main( final String[] args ) {
93 // Reading-in of (a) tree(s) from a file.
94 final File treefile = new File( "/path/to/tree.xml" );
95 PhylogenyParser parser = null;
97 parser = ParserUtils.createParserDependingOnFileType( treefile, true );
99 catch ( final IOException e ) {
102 Phylogeny[] phys = null;
104 phys = PhylogenyMethods.readPhylogenies( parser, treefile );
106 catch ( final IOException e ) {
109 // Display of the tree(s) with Archaeopteryx.
110 Archaeopteryx.createApplication( phys );