3 // forester -- software libraries and applications
4 // for evolutionary biology research and applications.
6 // Copyright (C) 2008-2011 Christian M. Zmasek
7 // Copyright (C) 2008-2011 Burnham Institute for Medical Research
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 // Contact: phylosoft @ gmail . com
25 // WWW: www.phylosoft.org/forester
27 package org.forester.test.examples;
29 import org.forester.archaeopteryx.Archaeopteryx;
30 import org.forester.phylogeny.Phylogeny;
31 import org.forester.phylogeny.PhylogenyNode;
32 import org.forester.phylogeny.data.Event;
33 import org.forester.phylogeny.data.Sequence;
34 import org.forester.phylogeny.data.Taxonomy;
36 public class Example5 {
38 public static void main( final String[] args ) {
39 // Creating a new rooted tree with two external nodes.
40 final Phylogeny phy = new Phylogeny();
41 final PhylogenyNode root = new PhylogenyNode();
42 final PhylogenyNode d1 = new PhylogenyNode();
43 final PhylogenyNode d2 = new PhylogenyNode();
44 // Setting of distances.
45 d1.setDistanceToParent( 1.2 );
46 d2.setDistanceToParent( 2.4 );
47 // Adding species information.
48 final Taxonomy t1 = new Taxonomy();
49 t1.setScientificName( "Nematostella vectensis" );
50 d1.getNodeData().addTaxonomy( t1 );
51 final Taxonomy t2 = new Taxonomy();
52 t2.setScientificName( "Monosiga brevicollis" );
53 d2.getNodeData().addTaxonomy( t2 );
55 final Sequence s1 = new Sequence();
56 s1.setName( "Bcl-2" );
57 d1.getNodeData().addSequence( s1 );
58 final Sequence s2 = new Sequence();
59 s2.setName( "Bcl-2" );
60 d2.getNodeData().addSequence( s2 );
61 // Root is a speciation.
62 final Event ev = new Event();
63 ev.setSpeciations( 1 );
64 ev.setDuplications( 0 );
65 root.getNodeData().setEvent( ev );
66 // Putting the tree together.
67 root.addAsChild( d1 );
68 root.addAsChild( d2 );
70 phy.setRooted( true );
71 // Displaying the newly created tree with Archaeopteryx.
72 Archaeopteryx.createApplication( phy );