petrie
v1.0.0
Published
a graph-based phylogenetic tree, implemented in Javascript.
Downloads
7
Readme
Petrie
a Graph-based phylogenetic tree, implemented in Javascript.
Phylogeny and Taxonomy
Whether your purposes are phylogenetic or taxonomic in nature doesn't matter. That is, whether you are making a evolutional tree, or a species classification tree. Your source of graph data will determine the utility.
- https://en.wikipedia.org/wiki/Phylogenetic_tree
- https://en.wikipedia.org/wiki/Taxonomic_rank
Graph
- https://github.com/trekhleb/javascript-algorithms/tree/master/src/data-structures/graph
Implementation
todo
Nepenthes Example
I chose Nepenthes, because I grow them at home! This project is part of a bigger one related to carnivorous plants and terraria that I'm breaking apart.
- http://www.carnivorousplants.org/cp/evolution/Nepenthes
I'm a hobbiest, so if youre actually in a scientific field and have favorite phylogenetic database, data structure, protocol to share this kind of data, or other research I know nothing about!, I'd love to hear about it in the issues.
Getting started
Install package.
yarn add petrie
Import module.
import Tree from 'petrie';
Create a cached tree from the ICPS Carnivorous Plant Names Database.
Create a cached tree using NCBS.
Creating your own tree.
Import your data.
import data from './data'; // default export location
Initialize a new Tree
instance.
const tree = new Tree(data);
Searching.
tree.find('nepenthes');
tree.find('nepenthes a');
Taxonomy
const ampullaria = tree.find('nepenthes ampullaria')[0];
ampullaria.name // binomial name
ampullaria.domain
ampullaria.order
ampullaria.species
ampullaria.divisions // synonymous with Species.prototype.children
ampullaria.order.divisions
// using HAMT methods to determine parents and children
ampullaria.children
const nepenthes = tree.find('nepenthes')[0]
ampullaria.isParent(nepenthes);
// false
nepenthes.isParent(ampullaria);
// true
Phylogeny
const nepenthes
ampullaria.geneticDistance();
HAMT
Using HAMT means that we have an entire tree-searching algorithm at our hands. Let's use it to create a binomial name searching autocomplete.
Graphing
D3 is an optional dependency to try to keep this project footprint small, and because not everybody needs graphing. If you like other chart libraries, please feel free to let me know in the issues.
import d3 from 'd3';
Contributing
Issues and pull requests are very welcome!
Tests
yarn test
License
MIT