expandedTree

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package expandedTree contains structs and functions that build and utilize information in a binary tree format that can be used for genome simulation and reconstruction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignFastas

func AssignFastas(root *ETree, fastaFilename string)

AssignFastas takes a root node and the name of a fasta file. The function will assign fasta sequences to all the nodes in the tree if the names are identical.

func PopulateSubstitutionMatrices added in v1.0.1

func PopulateSubstitutionMatrices(node *ETree, unitMatrix [][]float64, unitBranchLength float64)

PopulateSubstitutionMatrices initializes the SubstitutionMatrix field of every node in an input newick tree if the provided node is the root node. The substitution matrix for each branch is based on a known unitMatrix [][]float64, which is the substitution matrix S measured (often empirically) over a unitBranchLength float64. Thus, for a branch of length t, the substitution matrix is S^{t / unitBranchLength}

func SetUp

func SetUp(root *ETree, prevNode *ETree)

SetUp takes a pointer to a node, root, and a "previous" node and sets the "Up" pointer of root to point to prevNode.

func ToMap added in v1.0.1

func ToMap(root *ETree) map[string]*ETree

ToMap creates a map[string]*Etree, mapping each node's name to the *ETree struct.

func ToNewickFile added in v1.0.1

func ToNewickFile(filename string, root *ETree)

ToNewickFile writes a newick tree to a filename from a specified root.

func ToNewickString added in v1.0.1

func ToNewickString(node *ETree) string

ToNewickString converts a *ETree to a Newick-format string.

Types

type ETree

type ETree struct {
	Name                  string
	BranchLength          float64 // This is the branch length between this node and Up.
	OnlyTopology          bool
	Fasta                 *fasta.Fasta // Contains the sequence associated with this node. Fasta.Name should equal Name.
	State                 int          // corresponds to a base
	Stored                []float64    // a list of probabilities for each base at any given site of the genome
	Scrap                 float64
	Left                  *ETree
	Right                 *ETree
	Up                    *ETree      // The immediate ancestral node.
	DescendentBasePresent bool        // True if any descendent nodes have a base, in a specific position
	BasePresent           bool        // True if this node has a base (A, C, G, T, or N). False if this node has dna.Gap.
	SubstitutionMatrix    [][]float64 // for custom substitution matrices. This is a 4x4 substitution matrices for nucleotides.
}

ETree is a struct that represents a node in a binary tree, and has additional fields for simulation and reconstruction.

func CopyTree

func CopyTree(tree *ETree) *ETree

CopyTree takes a root node and returns a pointer to the root node of a copy of the entire tree.

func FindNodeName

func FindNodeName(node *ETree, findMe string) *ETree

FindNodeName takes a root node the name of the node we are searching for if the name is found at the root or below, a pointer to that node is the return value, and nil otherwise.

func GetBranch

func GetBranch(node *ETree) []*ETree

GetBranch takes a root node and returns a slice of all internal nodes in the tree.

func GetLeaves

func GetLeaves(node *ETree) []*ETree

GetLeaves takes a root node and returns a slice of all leaf nodes in the tree.

func GetTree

func GetTree(node *ETree) []*ETree

GetTree takes a root node and returns a slice of all nodes in the tree.

func ReadNewick

func ReadNewick(filename string) (*ETree, error)

ReadNewick takes a filename of a tree in newick format and returns a pointer to the root node.

func ReadTree

func ReadTree(newickFilename string, fastasFilename string) (*ETree, error)

ReadTree takes a filename of a tree in newick format and a filename of a fasta file. The names in the tree will be assigned a sequence in the fasta file if they have identical names. The function returns a pointer to the root node.

Jump to

Keyboard shortcuts

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