c35bcfd3e4d5ee4f953791d39052b3d998b3615c
[jalview.git] / wiki / forester.wiki
1 = Introduction =
2
3 Under development!
4
5 Documentation, tutorial, and examples for [http://www.phylosoft.org/forester/ forester].
6
7 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
8
9  
10 Copyright (C) 2011 Christian M Zmasek. All rights reserved.
11
12
13 = Parsing of phylogenetic trees and displaying them with Archaeopteryx =
14
15 This needs file "forester.jar" to be in the class-path.
16
17 {{{
18
19 package examples;
20
21 import java.io.File;
22 import java.io.IOException;
23
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;
28
29 public class Example1 {
30
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;
35         try {
36             parser = ForesterUtil.createParserDependingOnFileType( treefile, true );
37         }
38         catch ( final IOException e ) {
39             e.printStackTrace();
40         }
41         Phylogeny[] phys = null;
42         try {
43             phys = ForesterUtil.readPhylogenies( parser, treefile );
44         }
45         catch ( final IOException e ) {
46             e.printStackTrace();
47         }
48         // Display of the tree(s) with Archaeopteryx.
49         Archaeopteryx.createApplication( phys );
50     }
51 }
52
53 }}}
54
55
56 = Creating a new tree and displaying it with Archaeopteryx =
57
58 This needs file "forester.jar" to be in the class-path.
59
60 {{{
61
62 package examples;
63
64 import org.forester.archaeopteryx.Archaeopteryx;
65 import org.forester.phylogeny.Phylogeny;
66 import org.forester.phylogeny.PhylogenyNode;
67
68 public class Example2 {
69
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 );
81         phy.setRoot( root );
82         phy.setRooted( true );
83         // Displaying the newly created tree with Archaeopteryx.
84         Archaeopteryx.createApplication( phy );
85     }
86 }
87
88 }}}