newick

package
v0.0.0-...-22b94e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2014 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package newick provides facilities for reading and writing trees in the Newick format. The format used is roughly equivalent to the conventions established here: http://evolution.genetics.washington.edu/phylip/newick_doc.html. Although, comments and quoted labels are not (yet) implemented.

An informal description of the Newick format can be found here: http://evolution.genetics.washington.edu/phylip/newicktree.html.

Currently, this package only includes a reader, but a writer will be added as needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader corresponds to the state necessary to read trees from Newick formatted input.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a reader ready for reading trees from `r`.

func (*Reader) ReadAll

func (lx *Reader) ReadAll() ([]*Tree, error)

ReadAll returns all of the Newick trees in the source input. The first error that occurs is returned with no trees. The error is never `io.EOF`.

func (*Reader) ReadTree

func (lx *Reader) ReadTree() (*Tree, error)

ReadTree reads a single tree from the source input. If the end of the input is reached, then a nil `Tree` is returned with `io.EOF` as the error.

type Tree

type Tree struct {
	// All children of this node, which may be empty.
	Children []Tree

	// The label of this node. If it's empty, then this node does
	// not have a name.
	Label string

	// The branch length of this node corresponding to the distance between
	// it and its parent node. If it's `nil`, then no distance exists.
	Length *float64
}

Tree corresponds to any value representable in a Newick format. Each tree value corresponds to a single node.

func (*Tree) String

func (tree *Tree) String() string

String recursively converts a tree to a string, with whitespace indenting to indicate depth.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL