From: cmzmasek@gmail.com Date: Thu, 9 Jun 2011 22:52:23 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ae2893aca6082d15fc6421aee44c3a089976bb87;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/test/examples/Example1.java b/forester/java/src/org/forester/test/examples/Example1.java index 045ee6b..13b24d1 100644 --- a/forester/java/src/org/forester/test/examples/Example1.java +++ b/forester/java/src/org/forester/test/examples/Example1.java @@ -37,7 +37,7 @@ import org.forester.util.ForesterUtil; public class Example1 { public static void main( final String[] args ) { - // Reads in (a) tree(s) from a file. + // Reading-in of (a) tree(s) from a file. final File treefile = new File( "/home/czmasek/tol_117_TEST.xml" ); PhylogenyParser parser = null; try { diff --git a/forester/java/src/org/forester/test/examples/Example4.java b/forester/java/src/org/forester/test/examples/Example4.java new file mode 100644 index 0000000..b363ab3 --- /dev/null +++ b/forester/java/src/org/forester/test/examples/Example4.java @@ -0,0 +1,66 @@ +// $Id: +// +// forester -- software libraries and applications +// for evolutionary biology research and applications. +// +// Copyright (C) 2008-2011 Christian M. Zmasek +// Copyright (C) 2008-2011 Burnham Institute for Medical Research +// All rights reserved +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +// +// Contact: phylosoft @ gmail . com +// WWW: www.phylosoft.org/forester + +package org.forester.test.examples; + +import java.io.File; +import java.io.IOException; + +import org.forester.io.parsers.PhylogenyParser; +import org.forester.io.writers.PhylogenyWriter; +import org.forester.phylogeny.Phylogeny; +import org.forester.util.ForesterUtil; + +public class Example4 { + + public static void main( final String[] args ) { + // Reading-in of (a) tree(s) from a file. + final File treefile = new File( "/home/czmasek/tol_117_TEST.xml" ); + PhylogenyParser parser = null; + try { + parser = ForesterUtil.createParserDependingOnFileType( treefile, true ); + } + catch ( final IOException e ) { + e.printStackTrace(); + } + Phylogeny[] phys = null; + try { + phys = ForesterUtil.readPhylogenies( parser, treefile ); + } + catch ( final IOException e ) { + e.printStackTrace(); + } + // Writing trees to a file. + final File outfile = new File( "/home/czmasek/tol_117_TEST_out.xml" ); + try { + final PhylogenyWriter writer = new PhylogenyWriter(); + writer.toPhyloXML( phys, 0, outfile, ForesterUtil.LINE_SEPARATOR ); + } + catch ( final Exception e ) { + e.printStackTrace(); + } + } +} diff --git a/forester/java/src/org/forester/test/examples/Example5.java b/forester/java/src/org/forester/test/examples/Example5.java new file mode 100644 index 0000000..facc4b9 --- /dev/null +++ b/forester/java/src/org/forester/test/examples/Example5.java @@ -0,0 +1,74 @@ +// $Id: +// +// forester -- software libraries and applications +// for evolutionary biology research and applications. +// +// Copyright (C) 2008-2011 Christian M. Zmasek +// Copyright (C) 2008-2011 Burnham Institute for Medical Research +// All rights reserved +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +// +// Contact: phylosoft @ gmail . com +// WWW: www.phylosoft.org/forester + +package org.forester.test.examples; + +import org.forester.archaeopteryx.Archaeopteryx; +import org.forester.phylogeny.Phylogeny; +import org.forester.phylogeny.PhylogenyNode; +import org.forester.phylogeny.data.Event; +import org.forester.phylogeny.data.Sequence; +import org.forester.phylogeny.data.Taxonomy; + +public class Example5 { + + 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 ); + } +}