taxdump

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 7 Imported by: 3

README

taxdump

Go Reference

This package provides querying manipulations from NCBI Taxonomy taxdump files.

History

This package was originally maintained in unikmer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIllegalColumnIndex = errors.New("taxdump: illegal column index, positive integer needed")

ErrIllegalColumnIndex means column index is 0 or negative.

View Source
var ErrNamesNotLoaded = errors.New("taxdump: taxonomy names not loaded, please call: LoadNames")

ErrNamesNotLoaded means you should call LoadNames before using taxonomy names.

View Source
var ErrRankNotLoaded = errors.New("taxdump: taxonomic ranks not loaded, please call: NewTaxonomyWithRank")

ErrRankNotLoaded means you should reate load Taxonomy with NewTaxonomyWithRank before calling some methods.

View Source
var ErrTooManyRanks = errors.New("taxdump: number of ranks exceed limit of 255")

ErrTooManyRanks means number of ranks exceed limit of 255

View Source
var ErrUnkownRank = errors.New("taxdump: unknown rank")

ErrUnkownRank indicate an unknown rank

Functions

This section is empty.

Types

type Taxonomy

type Taxonomy struct {
	Nodes      map[uint32]uint32 // child -> parent
	DelNodes   map[uint32]struct{}
	MergeNodes map[uint32]uint32 // from -> to
	Names      map[uint32]string

	Ranks map[string]interface{}
	// contains filtered or unexported fields
}

Taxonomy holds relationship of taxon in a taxonomy.

func NewTaxonomy

func NewTaxonomy(file string, childColumn int, parentColumn int) (*Taxonomy, error)

NewTaxonomy only loads nodes from nodes.dmp file.

func NewTaxonomyFromNCBI

func NewTaxonomyFromNCBI(file string) (*Taxonomy, error)

NewTaxonomyFromNCBI parses nodes relationship from nodes.dmp from ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz .

func NewTaxonomyWithRank

func NewTaxonomyWithRank(file string, childColumn int, parentColumn int, rankColumn int) (*Taxonomy, error)

NewTaxonomyWithRank loads nodes and ranks from nodes.dmp file.

func NewTaxonomyWithRankFromNCBI

func NewTaxonomyWithRankFromNCBI(file string) (*Taxonomy, error)

NewTaxonomyWithRankFromNCBI parses Taxonomy from nodes.dmp from ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz .

func (*Taxonomy) AtOrBelowRank

func (t *Taxonomy) AtOrBelowRank(taxid uint32, rank string) bool

AtOrBelowRank returns whether a taxid is at or below one rank.

func (*Taxonomy) CacheLCA

func (t *Taxonomy) CacheLCA()

CacheLCA tells to cache every LCA query result

func (*Taxonomy) LCA

func (t *Taxonomy) LCA(a uint32, b uint32) uint32

LCA returns the Lowest Common Ancestor of two nodes, 0 for unknown taxid.

func (*Taxonomy) LineageNames

func (t *Taxonomy) LineageNames(taxid uint32) []string

LineageNames returns nodes' names of the the complete lineage.

func (*Taxonomy) LineageTaxIds

func (t *Taxonomy) LineageTaxIds(taxid uint32) []uint32

LineageTaxIds returns nodes' taxid of the the complete lineage.

func (*Taxonomy) LoadDeletedNodes

func (t *Taxonomy) LoadDeletedNodes(file string, column int) error

LoadDeletedNodes loads deleted nodes.

func (*Taxonomy) LoadDeletedNodesFromNCBI

func (t *Taxonomy) LoadDeletedNodesFromNCBI(file string) error

LoadDeletedNodesFromNCBI loads deleted nodes from NCBI delnodes.dmp.

func (*Taxonomy) LoadMergedNodes

func (t *Taxonomy) LoadMergedNodes(file string, oldColumn int, newColumn int) error

LoadMergedNodes loads merged nodes.

func (*Taxonomy) LoadMergedNodesFromNCBI

func (t *Taxonomy) LoadMergedNodesFromNCBI(file string) error

LoadMergedNodesFromNCBI loads merged nodes from NCBI merged.dmp.

func (*Taxonomy) LoadNames

func (t *Taxonomy) LoadNames(file string, taxidColumn int, nameColumn int, typeColumn int, _type string) error

LoadNames loads names.

func (*Taxonomy) LoadNamesFromNCBI

func (t *Taxonomy) LoadNamesFromNCBI(file string) error

LoadNamesFromNCBI loads scientific names from NCBI names.dmp

func (*Taxonomy) MaxTaxid

func (t *Taxonomy) MaxTaxid() uint32

MaxTaxid returns maximum taxid

func (*Taxonomy) Name

func (t *Taxonomy) Name(taxid uint32) string

Name returns the name of a TaxId. If being merged, the name of the new TaxId will be returned. If the TaxId is not found or deleted, empty will be returned.

func (*Taxonomy) Rank

func (t *Taxonomy) Rank(taxid uint32) string

Rank returns the rank of a taxid. If being merged, the rank of the new TaxId will be returned. If the TaxId is not found or deleted, empty will be returned.

func (*Taxonomy) TaxId

func (t *Taxonomy) TaxId(taxid uint32) (uint32, bool)

TaxId checks if a TaxId is valid in the database. If being merged, the new TaxId will be returned. If the TaxId is not found or deleted, false will be returned.

Jump to

Keyboard shortcuts

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