small clean-up.
[jalview.git] / wiki / forester.wiki
index 25708bf..33be888 100644 (file)
@@ -1,3 +1,6 @@
+= forester Tutorial and Examples =
+<wiki:toc max_depth="3" />
+
 = Introduction =
 
 Under development!
@@ -26,7 +29,7 @@ import org.forester.io.writers.PhylogenyWriter;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.util.ForesterUtil;
 
-public class Example4 {
+public class Example {
 
     public static void main( final String[] args ) {
         // Reading-in of (a) tree(s) from a file.
@@ -77,7 +80,7 @@ import org.forester.io.parsers.PhylogenyParser;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.util.ForesterUtil;
 
-public class Example1 {
+public class Example {
 
     public static void main( final String[] args ) {
         // Reading-in of (a) tree(s) from a file.
@@ -118,7 +121,7 @@ import org.forester.archaeopteryx.Archaeopteryx;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 
-public class Example2 {
+public class Example {
 
     public static void main( final String[] args ) {
         // Creating a new rooted tree with two external nodes.
@@ -145,7 +148,7 @@ public class Example2 {
 
 
 
-= Using iterators to visit tree nodes in certain orders=
+= Using iterators to visit tree nodes in certain orders =
 
 This needs file "forester.jar" to be in the class-path.
 
@@ -157,7 +160,7 @@ import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
 
-public class Example3 {
+public class Example {
 
     public static void main( final String[] args ) {
         // Creating a new rooted tree with four external nodes.
@@ -198,4 +201,68 @@ public class Example3 {
     }
 }
 
+}}}
+
+
+
+
+
+
+
+
+
+= Creating a basic gene tree (with branch lengths) =
+
+This needs file "forester.jar" to be in the class-path.
+
+{{{
+
+package examples;
+
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Sequence;
+import org.forester.phylogeny.data.Taxonomy;
+
+public class Example {
+
+    public static void main( final String[] args ) {
+        // Creating a new rooted tree with two external nodes.
+        final Phylogeny phy = new Phylogeny();
+        final PhylogenyNode root = new PhylogenyNode();
+        final PhylogenyNode d1 = new PhylogenyNode();
+        final PhylogenyNode d2 = new PhylogenyNode();
+        // Setting of distances.
+        d1.setDistanceToParent( 1.2 );
+        d2.setDistanceToParent( 2.4 );
+        // Adding species information.
+        final Taxonomy t1 = new Taxonomy();
+        t1.setScientificName( "Nematostella vectensis" );
+        d1.getNodeData().addTaxonomy( t1 );
+        final Taxonomy t2 = new Taxonomy();
+        t2.setScientificName( "Monosiga brevicollis" );
+        d2.getNodeData().addTaxonomy( t2 );
+        // Adding gene names.
+        final Sequence s1 = new Sequence();
+        s1.setName( "Bcl-2" );
+        d1.getNodeData().addSequence( s1 );
+        final Sequence s2 = new Sequence();
+        s2.setName( "Bcl-2" );
+        d2.getNodeData().addSequence( s2 );
+        // Root is a speciation.
+        final Event ev = new Event();
+        ev.setSpeciations( 1 );
+        ev.setDuplications( 0 );
+        root.getNodeData().setEvent( ev );
+        // Putting the tree together.
+        root.addAsChild( d1 );
+        root.addAsChild( d2 );
+        phy.setRoot( root );
+        phy.setRooted( true );
+        // Displaying the newly created tree with Archaeopteryx.
+        Archaeopteryx.createApplication( phy );
+    }
+}
+
 }}}
\ No newline at end of file