d75fb50607811878a4dc0ec37f5c3652ba4e8bb6
[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
14 = Parsing of phylogenetic trees and displaying them with Archaeopteryx =
15
16 This needs file "forester.jar" to be in the class-path.
17
18 {{{
19
20 package examples;
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.forester.archaeopteryx.Archaeopteryx;
26 import org.forester.io.parsers.PhylogenyParser;
27 import org.forester.phylogeny.Phylogeny;
28 import org.forester.util.ForesterUtil;
29
30 public class Example1 {
31
32     public static void main( final String[] args ) {
33         // Reads in (a) tree(s) from a file.
34         final File treefile = new File( "/path/to/tree.xml" );
35         PhylogenyParser parser = null;
36         try {
37             parser = ForesterUtil.createParserDependingOnFileType( treefile, true );
38         }
39         catch ( final IOException e ) {
40             e.printStackTrace();
41         }
42         Phylogeny[] phys = null;
43         try {
44             phys = ForesterUtil.readPhylogenies( parser, treefile );
45         }
46         catch ( final IOException e ) {
47             e.printStackTrace();
48         }
49         // Display of the tree(s) with Archaeopteryx.
50         Archaeopteryx.createApplication( phys );
51     }
52 }
53
54 }}}
55
56
57
58
59 = Creating a new tree and displaying it with Archaeopteryx =
60
61 This needs file "forester.jar" to be in the class-path.
62
63 {{{
64
65 package examples;
66
67 import org.forester.archaeopteryx.Archaeopteryx;
68 import org.forester.phylogeny.Phylogeny;
69 import org.forester.phylogeny.PhylogenyNode;
70
71 public class Example2 {
72
73     public static void main( final String[] args ) {
74         // Creating a new rooted tree with two external nodes.
75         final Phylogeny phy = new Phylogeny();
76         final PhylogenyNode root = new PhylogenyNode();
77         final PhylogenyNode d1 = new PhylogenyNode();
78         final PhylogenyNode d2 = new PhylogenyNode();
79         root.setName( "root" );
80         d1.setName( "descendant 1" );
81         d2.setName( "descendant 2" );
82         root.addAsChild( d1 );
83         root.addAsChild( d2 );
84         phy.setRoot( root );
85         phy.setRooted( true );
86         // Displaying the newly created tree with Archaeopteryx.
87         Archaeopteryx.createApplication( phy );
88     }
89 }
90
91 }}}