Created wiki page through web user interface.
[jalview.git] / wiki / Archaeopteryx.wiki
1 = forester Tutorial and Examples =
2 <wiki:toc max_depth="3" />
3
4 = Introduction =
5
6 Under development!
7
8 Documentation, tutorial, and examples for [http://www.phylosoft.org/forester/ forester].
9
10 *All examples require jar-file "forester.jar" to be in the class-path.*
11
12 Download: http://code.google.com/p/forester/downloads/list
13
14 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
15
16  
17 Copyright (C) 2012 Christian M Zmasek. All rights reserved.
18
19
20
21 = Reading and writing of phylogenetic trees =
22
23
24
25 {{{
26
27 package 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 Example {
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( "/path/to/tree.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( "/path/to/out_tree.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 }
69
70 }}}
71
72
73
74 = Reading of phylogenetic trees and displaying them with Archaeopteryx =
75
76
77 {{{
78
79 package examples;
80
81 import java.io.File;
82 import java.io.IOException;
83
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;
89
90 public class Example {
91
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;
96         try {
97             parser = ParserUtils.createParserDependingOnFileType( treefile, true );
98         }
99         catch ( final IOException e ) {
100             e.printStackTrace();
101         }
102         Phylogeny[] phys = null;
103         try {
104             phys = PhylogenyMethods.readPhylogenies( parser, treefile );
105         }
106         catch ( final IOException e ) {
107             e.printStackTrace();
108         }
109         // Display of the tree(s) with Archaeopteryx.
110         Archaeopteryx.createApplication( phys );
111     }
112 }
113
114 }}}