[][src]Struct taxonomy::GeneralTaxonomy

pub struct GeneralTaxonomy { /* fields omitted */ }

A concrete implementation of the Taxonomy trait suitable for interconversions of different formats.

Methods

impl GeneralTaxonomy[src]

pub fn new(
    tax_ids: Vec<String>,
    parent_ids: Vec<usize>,
    names: Option<Vec<String>>,
    ranks: Option<Vec<Option<TaxRank>>>,
    dists: Option<Vec<f32>>
) -> Self
[src]

Initializer for a new Taxonomy.

All Vecs must be the same length or initialization will fail.

pub fn from_internal_id(&self, tax_id: usize) -> Result<&str>[src]

Given an internal tax_id (an array position) return the corresponding external tax_id (e.g. a NCBI taxonomy ID).

Because the Taxonomy train is implemented for internal IDs also, the can be used to speed up some operations by avoiding a string lookup.

pub fn to_internal_id(&self, tax_id: &str) -> Result<usize>[src]

Given an external tax_id (e.g. a NCBI taxonomy ID) return the corresponding internal tax_id (the position of that tax node in the internal array).

Because the Taxonomy train is implemented for internal IDs also, the can be used to speed up some operations by avoiding a string lookup.

Trait Implementations

impl<'s> Taxonomy<'s, usize, f32> for GeneralTaxonomy[src]

This is the implementation for "internal" tax ID lookup; these IDs are arbitrary (they're positions of the tax nodes in the internal array) and not linked at all to the "external" (e.g. NCBI) IDs. Using these IDs directly can lead to a decent speed up without having to build indicies.

fn lineage(&'t self, tax_id: T) -> Result<Vec<T>>[src]

Returns a Vec of taxonomy nodes from the one provided back to root. Read more

fn parent_at_rank(&'t self, tax_id: T, rank: TaxRank) -> Result<Option<(T, D)>>[src]

Returns the parent at a given taxonomic rank (note this may not be the immediate parent). This also returns the distance to that parent. Read more

fn lca(&'t self, id1: T, id2: T) -> Result<T>[src]

Returns the first common parent between two nodes. E.g. for the tree: Read more

fn traverse(&'t self, node: T) -> Result<TaxonomyIterator<'t, T, D>> where
    Self: Sized
[src]

Generates an iterator that traces over the entire taxonomic tree. During preorder traversal, it returns (T, true) and during postorder traversal it returns (T, false) Read more

fn is_empty(&'t self) -> bool where
    Self: Sized
[src]

Convenience function for determining if there are any nodes at all in the taxonomy. This should almost always be implemented for performance reasons. Read more

impl<'s> Taxonomy<'s, &'s str, f32> for GeneralTaxonomy[src]

This is the implementation for &str taxonomy access for a more end-user understandable (but slightly slower) workflow.

fn lineage(&'t self, tax_id: T) -> Result<Vec<T>>[src]

Returns a Vec of taxonomy nodes from the one provided back to root. Read more

fn parent_at_rank(&'t self, tax_id: T, rank: TaxRank) -> Result<Option<(T, D)>>[src]

Returns the parent at a given taxonomic rank (note this may not be the immediate parent). This also returns the distance to that parent. Read more

fn lca(&'t self, id1: T, id2: T) -> Result<T>[src]

Returns the first common parent between two nodes. E.g. for the tree: Read more

fn traverse(&'t self, node: T) -> Result<TaxonomyIterator<'t, T, D>> where
    Self: Sized
[src]

Generates an iterator that traces over the entire taxonomic tree. During preorder traversal, it returns (T, true) and during postorder traversal it returns (T, false) Read more

fn is_empty(&'t self) -> bool where
    Self: Sized
[src]

Convenience function for determining if there are any nodes at all in the taxonomy. This should almost always be implemented for performance reasons. Read more

impl Clone for GeneralTaxonomy[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for GeneralTaxonomy[src]

impl Serialize for GeneralTaxonomy[src]

impl<'de> Deserialize<'de> for GeneralTaxonomy[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]