5 Documentation, tutorial, and examples for [http://www.phylosoft.org/forester/ forester].
7 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
10 Copyright (C) 2011 Christian M Zmasek. All rights reserved.
13 = Parsing of phylogenetic trees and displaying them with Archaeopteryx =
15 This needs file "forester.jar" to be in the class-path.
22 import java.io.IOException;
24 import org.forester.archaeopteryx.Archaeopteryx;
25 import org.forester.io.parsers.PhylogenyParser;
26 import org.forester.phylogeny.Phylogeny;
27 import org.forester.util.ForesterUtil;
29 public class Example1 {
31 public static void main( final String[] args ) {
32 // Reads in (a) tree(s) from a file.
33 final File treefile = new File( "/path/to/tree.xml" );
34 PhylogenyParser parser = null;
36 parser = ForesterUtil.createParserDependingOnFileType( treefile, true );
38 catch ( final IOException e ) {
41 Phylogeny[] phys = null;
43 phys = ForesterUtil.readPhylogenies( parser, treefile );
45 catch ( final IOException e ) {
48 // Display of the tree(s) with Archaeopteryx.
49 Archaeopteryx.createApplication( phys );
56 = Creating a new tree and displaying it with Archaeopteryx =
58 This needs file "forester.jar" to be in the class-path.
64 import org.forester.archaeopteryx.Archaeopteryx;
65 import org.forester.phylogeny.Phylogeny;
66 import org.forester.phylogeny.PhylogenyNode;
68 public class Example2 {
70 public static void main( final String[] args ) {
71 // Creating a new rooted tree with two external nodes.
72 final Phylogeny phy = new Phylogeny();
73 final PhylogenyNode root = new PhylogenyNode();
74 final PhylogenyNode d1 = new PhylogenyNode();
75 final PhylogenyNode d2 = new PhylogenyNode();
76 root.setName( "root" );
77 d1.setName( "descendant 1" );
78 d2.setName( "descendant 2" );
79 root.addAsChild( d1 );
80 root.addAsChild( d2 );
82 phy.setRooted( true );
83 // Displaying the newly created tree with Archaeopteryx.
84 Archaeopteryx.createApplication( phy );