nexus

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: GPL-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteNexus

func WriteNexus(tchan <-chan tree.Trees, translate bool) (string, error)

WriteNexus generates a Nexus string from a tree channel if translate is true, then it replaces all tip names by indices and generates a translate block.

Types

type Nexus

type Nexus struct {
	HasAlignment bool // If the Nexus structure has contains an Alignment
	HasTrees     bool // If the Nexus structure has contains a Tree
	GapChar      rune // Gap character in the alignment
	MissingChar  rune // Missing character in the alignment
	// contains filtered or unexported fields
}

The nexus structure, with several trees (gotree) and one alignment (goalign)

func NewNexus

func NewNexus() *Nexus

func (*Nexus) AddTree

func (n *Nexus) AddTree(name string, t *tree.Tree)

func (*Nexus) Alignment

func (n *Nexus) Alignment() align.Alignment

func (*Nexus) FirstTree

func (n *Nexus) FirstTree() *tree.Tree

returns the first tree of the nexus data structure If no tree is present, then returns nil

func (*Nexus) IterateTrees

func (n *Nexus) IterateTrees(it func(string, *tree.Tree))

func (*Nexus) NTrees

func (n *Nexus) NTrees() int

returns the first tree of the nexus data structure If no tree is present, then returns nil

func (*Nexus) SetAlignment

func (n *Nexus) SetAlignment(align align.Alignment)

type Parser

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

Parser represents a parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse() (*Nexus, error)

Parses Nexus content from the reader

type Scanner

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

Scanner represents a lexical scanner.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner returns a new instance of Scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, lit string)

Scan returns the next token and literal value.

type Token

type Token int64
const (
	ILLEGAL Token = iota
	EOF
	WS
	IDENT        // Name of Node, or comment, or keyword
	NUMERIC      // Any numerical value
	OPENBRACK    // [ : For comment
	CLOSEBRACK   // ] : For comment
	ENDOFCOMMAND // ; : End of command
	ENDOFLINE    // \r \n
	COMMA        // , : separator for tables (translation command for ex)

	// Keywords
	NEXUS     // #NEXUS : Start of nexus file
	EQUAL     // '=' between keyword and value
	BEGIN     // Begin
	DATA      // Begin data -> Alignment
	TAXA      // Begin taxa -> Definition of taxa
	TAXLABELS // Begin taxa : list of  taxlabels
	TREES     // Begin trees -> Definition of trees
	TREE      // A specific tree in the BEGIN TREES section
	TRANSLATE // Command that defines a translation table for taxa names

	DIMENSIONS // Dimensions
	NTAX       // Dimensions : Number of taxa
	NCHAR      // Dimensions : Length of alignment

	FORMAT   // Format
	DATATYPE // Format datatype=dna
	MISSING  // Format missing=?  missing char
	GAP      // Format gap=- gap character

	MATRIX // Matrix
	END    // End
)

Jump to

Keyboard shortcuts

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