uk.ac.vamsas.objects.utils.trees
Class NewickFile

java.lang.Object
  extended byuk.ac.vamsas.objects.utils.trees.NewickFile

public class NewickFile
extends java.lang.Object

DOCUMENT ME!

Version:
$Revision: 1.12 $
Author:
$author$

Constructor Summary
NewickFile(java.io.File inFile)
           
NewickFile(SequenceNode newtree)
          Creates a new NewickFile object.
NewickFile(SequenceNode newtree, boolean bootstrap)
          Creates a new NewickFile object.
NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances)
          Creates a new NewickFile object.
NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances, boolean rootdistance)
          Creates a new NewickFile object.
NewickFile(java.lang.String inStr)
          Creates a new NewickFile object
 
Method Summary
 void _print(java.lang.StringBuffer tf, SequenceNode c)
           
 java.util.Vector attachTreeMap(Treenode[] tn)
          re-decorate the newick node representation with the VorbaId of an object mapped by its corresponding TreeNode.
 java.util.Vector findLeaves(SequenceNode node, java.util.Vector leaves)
          Search for leaf nodes.
 SequenceNode getTree()
          DOCUMENT ME!
 boolean HasBootstrap()
           
 boolean HasDistances()
           
 boolean HasRootDistance()
           
static void main(java.lang.String[] args)
           
 Treenode[] makeTreeNodes()
          make tree node vector from a newick tree structure with associated vamsas objects
 Treenode[] makeTreeNodes(boolean ignoreplaceholders)
          make treenode vector for a parsed tree with/out leaf node associations
 Treenode[] matchTreeNodeNames(java.lang.String[] names, Vobject[] boundObjects)
           
 java.lang.String nextLine()
           
 void parse()
          call this to convert the newick string into a binary node linked tree Note: this is automatically called by the constructors, so you normally wouldn't need to use this.
 java.lang.String print()
          Generate a newick format tree according to internal flags for bootstraps, distances and root distances.
 java.lang.String print(boolean withbootstraps)
          Generate a newick format tree according to internal flags for distances and root distances and user specificied writing of bootstraps.
 java.lang.String print(boolean withbootstraps, boolean withdists)
          Generate newick format tree according to internal flags for writing root node distances.
 java.lang.String print(boolean withbootstraps, boolean withdists, boolean printRootInfo)
          Generate newick format tree according to user specified flags
 void print(java.lang.StringBuffer tf, SequenceNode root)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewickFile

public NewickFile(java.lang.String inStr)
           throws java.io.IOException
Creates a new NewickFile object

Parameters:
inStr - Newick style tree string
Throws:
java.io.IOException - if string is not a valid newick file

NewickFile

public NewickFile(java.io.File inFile)
           throws java.io.IOException

NewickFile

public NewickFile(SequenceNode newtree)
Creates a new NewickFile object.

Parameters:
newtree - DOCUMENT ME!

NewickFile

public NewickFile(SequenceNode newtree,
                  boolean bootstrap)
Creates a new NewickFile object.

Parameters:
newtree - DOCUMENT ME!
bootstrap - DOCUMENT ME!

NewickFile

public NewickFile(SequenceNode newtree,
                  boolean bootstrap,
                  boolean distances)
Creates a new NewickFile object.

Parameters:
newtree - DOCUMENT ME!
bootstrap - DOCUMENT ME!
distances - DOCUMENT ME!

NewickFile

public NewickFile(SequenceNode newtree,
                  boolean bootstrap,
                  boolean distances,
                  boolean rootdistance)
Creates a new NewickFile object.

Parameters:
newtree - DOCUMENT ME!
bootstrap - DOCUMENT ME!
distances - DOCUMENT ME!
rootdistance - DOCUMENT ME!
Method Detail

HasBootstrap

public boolean HasBootstrap()
Returns:
true if tree has bootstrap values

HasDistances

public boolean HasDistances()
Returns:
true if tree has distances on branches

HasRootDistance

public boolean HasRootDistance()
Returns:
true if root has a stem distance

nextLine

public java.lang.String nextLine()
                          throws java.io.IOException
Throws:
java.io.IOException

parse

public void parse()
           throws java.io.IOException
call this to convert the newick string into a binary node linked tree Note: this is automatically called by the constructors, so you normally wouldn't need to use this.

Throws:
java.io.IOException - if the newick string cannot be parsed.

getTree

public SequenceNode getTree()
DOCUMENT ME!

Returns:
DOCUMENT ME!

matchTreeNodeNames

public Treenode[] matchTreeNodeNames(java.lang.String[] names,
                                     Vobject[] boundObjects)

print

public java.lang.String print()
Generate a newick format tree according to internal flags for bootstraps, distances and root distances.

Returns:
new hampshire tree in a single line

print

public java.lang.String print(boolean withbootstraps)
Generate a newick format tree according to internal flags for distances and root distances and user specificied writing of bootstraps.

Parameters:
withbootstraps - controls if bootstrap values are explicitly written.
Returns:
new hampshire tree in a single line

print

public java.lang.String print(boolean withbootstraps,
                              boolean withdists)
Generate newick format tree according to internal flags for writing root node distances.

Parameters:
withbootstraps - explicitly write bootstrap values
withdists - explicitly write distances
Returns:
new hampshire tree in a single line

print

public java.lang.String print(boolean withbootstraps,
                              boolean withdists,
                              boolean printRootInfo)
Generate newick format tree according to user specified flags

Parameters:
withbootstraps - explicitly write bootstrap values
withdists - explicitly write distances
printRootInfo - explicitly write root distance
Returns:
new hampshire tree in a single line

print

public void print(java.lang.StringBuffer tf,
                  SequenceNode root)

_print

public void _print(java.lang.StringBuffer tf,
                   SequenceNode c)

main

public static void main(java.lang.String[] args)

findLeaves

public java.util.Vector findLeaves(SequenceNode node,
                                   java.util.Vector leaves)
Search for leaf nodes.

Parameters:
node - root node to search from
leaves - Vector of leaves to add leaf node objects too.
Returns:
Vector of leaf nodes on binary tree

makeTreeNodes

public Treenode[] makeTreeNodes()
make tree node vector from a newick tree structure with associated vamsas objects

Returns:
Treenode definitions for nodes with associated objects

makeTreeNodes

public Treenode[] makeTreeNodes(boolean ignoreplaceholders)
make treenode vector for a parsed tree with/out leaf node associations

Parameters:
ignoreplaceholders - if true means only associated nodes are returned
Returns:
treenode vector for associated or all leaves

attachTreeMap

public java.util.Vector attachTreeMap(Treenode[] tn)
re-decorate the newick node representation with the VorbaId of an object mapped by its corresponding TreeNode. Note: this only takes the first object in the first set of references.

Parameters:
tn -
Returns:
vector of mappings { treenode, SequenceNode, Vobject for VorbaId on sequence node }