newick

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package newick decodes and encodes 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

func File added in v1.0.0

func File(file string) iter.Seq2[*Node, error]

File returns an iterator over trees in a file.

func Reader

func Reader(r io.Reader) iter.Seq2[*Node, error]

Reader returns an iterator over trees in a reader.

Types

type Node

type Node struct {
	Name     string  // Node name. May be empty.
	Distance float64 // Distance from parent. 0 is treated as none.
	Children []*Node // Child nodes. May 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() iter.Seq[*Node]

PostOrder returns an iterator over nodes in the tree. Every node is called after its children.

Does not make recursive calls.

func (*Node) PreOrder added in v0.1.17

func (n *Node) PreOrder() iter.Seq[*Node]

PreOrder returns an iterator over nodes in the tree. Every node is called before its children.

Does not make recursive calls.

func (*Node) Write added in v1.0.0

func (n *Node) Write(w io.Writer) error

Write writes a condensed Newick-format representation of this node to w.

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