newick

package
Version: v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package newick handles reading and writing Newick-formatted trees.

This package uses the format described in: https://en.wikipedia.org/wiki/Newick_format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Name     string  // Node name. Can be empty.
	Distance float64 // Distance from parent. 0 is treated as none.
	Children []*Node // Child nodes. Can be nil.
}

A Node is a single node in a tree, along with the subtree that is under it.

func (*Node) MarshalText added in v0.1.17

func (n *Node) MarshalText() ([]byte, error)

MarshalText returns a condensed Newick-format representation of this node.

func (*Node) PostOrder added in v0.1.17

func (n *Node) PostOrder(forEach func(*Node) bool)

PostOrder calls forEach on every node in the tree, non-recursively. Every node is called after its children. The iteration stops when forEach returns false.

func (*Node) PreOrder added in v0.1.17

func (n *Node) PreOrder(forEach func(*Node) bool)

PreOrder calls forEach on every node in the tree, non-recursively. Every node is called before its children. The iteration stops when forEach returns false.

type Reader

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

A Reader reads Newick-formatted trees.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a Reader that reads from the given stream.

func (*Reader) Read

func (r *Reader) Read() (*Node, error)

Read reads a single tree from the input. Can be called multiple times to read subsequent trees.

Notes

Bugs

  • Comments are currently not supported.

Jump to

Keyboard shortcuts

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