[][src]Struct taxonomy::GeneralTaxonomy

pub struct GeneralTaxonomy {
    pub tax_ids: Vec<String>,
    pub parent_ids: Vec<usize>,
    pub parent_dists: Vec<f32>,
    pub ranks: Vec<TaxRank>,
    pub names: Vec<String>,
    // some fields omitted
}

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

Fields

tax_ids: Vec<String>parent_ids: Vec<usize>parent_dists: Vec<f32>ranks: Vec<TaxRank>names: Vec<String>

Methods

impl GeneralTaxonomy[src]

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

Initializer for a new GeneralTaxonomy.

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

pub fn from_taxonomy<'t, T: 't, D: 't>(
    taxonomy: &'t impl Taxonomy<'t, T, D>
) -> Result<Self> where
    T: Clone + Debug + Display + PartialEq + Ord,
    D: Clone + Debug + Ord + Into<f64> + PartialOrd + PartialEq + Sum
[src]

Build a GeneralTaxonomy from any object that implements the Taxonomy trait.

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 trait 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 trait is implemented for internal IDs also, the can be used to speed up some operations by avoiding a string lookup.

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

Remove a single node from the taxonomy.

Unlike pruning the children of the node are kept, but are rejoined onto the node's parent. The root node can not be removed

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

Add a new node to the taxonomy.

Trait Implementations

impl Clone for GeneralTaxonomy[src]

impl Debug for GeneralTaxonomy[src]

impl Default for GeneralTaxonomy[src]

fn default() -> Self[src]

Create a new GeneralTaxonomy with only a root node.

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

impl Serialize for GeneralTaxonomy[src]

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.

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.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.