ncbitaxonomy
v1.0.6
Published
Tree API for NCBI Taxonomy
Downloads
7
Readme
ncbi taxonomy
A package to perform operations on a NCBI taxonomy tree
Dependencies
- Get a NCBI Taxononmy tree dump as a
taxdump.tar.gz
archive - Unpack it at a
TAXDUMP_FOLDER
location
Command Line version
Look for taxonomy nodes by names
node --max-old-space-size=4096 build/tests/main.js -i TAXDUMP_FOLDER --named ".*coccus.*"
Look for a single taxonomy node by TaxonID
node --max-old-space-size=4096 build/tests/main.js -i TAXDUMP_FOLDER --key 9606
Look for taxonomy nodes based on parent node TaxonID
node --max-old-space-size=4096 build/tests/main.js -i TAXDUMP_FOLDER -p 9605
Assert if one node is a descendant of another
a and b are, respectively, the putative descendant and parent.
node --max-old-space-size=4096 build/tests/main.js -i data/ncbiTaxonID -a 1301 -b 131567
NPM Package API
import the package
import { parseTree } from 'ncbitaxonomy';
Invoke a Taxonomy tree object
You need to supply a path to TAXDUMP_FOLDER
parseTree(pathDir:string): Promise<Tree>
The tree object exposes the following properties:
Get the list of ascendants of a node
Returns all list of nodes from provided taxonomic node to the taxonomy root:
lineage(node:TaxNode):TaxNode[]
Check if a node is descendant of another
isChildOf(mayChildNode:TaxNode, mayParentNode:TaxNode):Boolean
Search for nodes
Provide string with a regular expression syntax to look for node names matching it. Alternativeley provide a valid taxonID of the node itself or its direct parent
interface searchCrit {
name? : string,
id? : string|number,
directParent? : string|number
}
The find method will return a possible a zero size array.
find(data:searchCrit):TaxNode[]
Iterating over all nodes
The Tree object is iterable through the nodes() method. The iteration order is the insertion order.
for (let curNode:TaxNode of treeObject) {
// all node will sequentially be accessed here
}