[−][src]Struct taxonomy::GeneralTaxonomy
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]
tax_ids: Vec<String>,
parent_ids: Vec<usize>,
names: Option<Vec<String>>,
ranks: Option<Vec<Option<TaxRank>>>,
dists: Option<Vec<f32>>
) -> Self
Initializer for a new Taxonomy.
All Vec
s 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 root(&self) -> usize
[src]
fn children(&self, tax_id: usize) -> Result<Vec<usize>>
[src]
fn parent(&self, tax_id: usize) -> Result<Option<(usize, f32)>>
[src]
fn len(&self) -> usize
[src]
fn name(&self, tax_id: usize) -> Result<&str>
[src]
fn rank(&self, tax_id: usize) -> Result<Option<TaxRank>>
[src]
fn lineage(&'t self, tax_id: T) -> Result<Vec<T>>
[src]
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]
Self: Sized,
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]
Self: Sized,
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 root(&'s self) -> &'s str
[src]
fn children(&self, tax_id: &str) -> Result<Vec<&str>>
[src]
fn parent(&self, tax_id: &str) -> Result<Option<(&str, f32)>>
[src]
fn len(&self) -> usize
[src]
fn name(&self, tax_id: &str) -> Result<&str>
[src]
fn rank(&self, tax_id: &str) -> Result<Option<TaxRank>>
[src]
fn lineage(&'t self, tax_id: T) -> Result<Vec<T>>
[src]
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]
Self: Sized,
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]
Self: Sized,
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(&self) -> 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]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for GeneralTaxonomy
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for GeneralTaxonomy
impl Send for GeneralTaxonomy
impl Unpin for GeneralTaxonomy
impl UnwindSafe for GeneralTaxonomy
impl RefUnwindSafe for GeneralTaxonomy
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,