statalign.io.input.plugins
Class NewickReader

java.lang.Object
  extended by statalign.io.input.DataReader
      extended by statalign.io.input.plugins.NewickReader

public class NewickReader
extends DataReader

Class to parse Newick format tree files or strings. The tree must either be an rooted or unrooted binary tree, the latter will be rooted after parsing at the middle of the third branch of the top node as the Tree class does not support unrooted trees. The vertex[] array of the tree are filled such that the leaf nodes come first in the order they are visited by a left-first preorder traversal then the internal nodes in the reversed order they are visited by the same traversal (root will be the last). The latter ones get labelled by their index in the array. Vertex.vertexNum fields are filled. You can specify a lower limit on edge lengths using the appropriate constructors. Default is a lower limit of 0. Any number of white space (including new lines) may be present.

Author:
novak

Nested Class Summary
 class NewickReader.FormatException
           
static class NewickReader.FormatExceptType
           
 
Constructor Summary
NewickReader()
          Constructs a NewickReader with the default minimum edge length of 0.
NewickReader(double minEdgeLen)
          Constructs a NewickReader with a specified minimum edge length.
 
Method Summary
static void main(java.lang.String[] args)
           
 Tree read(java.io.Reader reader)
          Parses tree.
 java.util.List<java.lang.String> supportedExtensions()
          DataReader plugins must override this to return a list of supported file extensions.
 
Methods inherited from class statalign.io.input.DataReader
read, read, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NewickReader

public NewickReader()
Constructs a NewickReader with the default minimum edge length of 0.


NewickReader

public NewickReader(double minEdgeLen)
Constructs a NewickReader with a specified minimum edge length.

Method Detail

read

public Tree read(java.io.Reader reader)
          throws java.io.IOException
Parses tree.

Specified by:
read in class DataReader
Returns:
tree built
Throws:
java.io.IOException - only if parsing from file and I/O error occurs
NewickReader.FormatException
NewickReader.FormatException - if
java.io.IOException - if I/O error occurs

supportedExtensions

public java.util.List<java.lang.String> supportedExtensions()
Description copied from class: DataReader
DataReader plugins must override this to return a list of supported file extensions.

Specified by:
supportedExtensions in class DataReader
Returns:
a list of all lower case file extensions supported by this plugin

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        NewickReader.FormatException
Throws:
java.io.IOException
NewickReader.FormatException