Struct tskit::Tree [−][src]
pub struct Tree { /* fields omitted */ }
Expand description
A Tree.
Wrapper around tsk_tree_t
.
Implementations
impl Tree
[src]
impl Tree
[src]pub fn parent_array(&self) -> &[tsk_id_t]
[src]
pub fn parent_array(&self) -> &[tsk_id_t]
[src]Failing examples
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); while let Some(tree) = tree_iter.next() { let p = tree.parent_array(); drop(tree_iter); for _ in p {} // ERROR }
pub fn samples_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]
pub fn samples_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]Failing examples
An error will be returned if [’crate::TreeFlags::SAMPLE_LISTS`] is not used:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); // ERROR while let Some(tree) = tree_iter.next() { let s = tree.samples_array().unwrap(); for _ in s {} }
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::SAMPLE_LISTS).unwrap(); while let Some(tree) = tree_iter.next() { let s = tree.samples_array().unwrap(); drop(tree_iter); for _ in s {} // ERROR }
pub fn next_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]
pub fn next_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]Failing examples
An error will be returned if [’crate::TreeFlags::SAMPLE_LISTS`] is not used:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); // ERROR while let Some(tree) = tree_iter.next() { let n = tree.next_sample_array().unwrap(); for _ in n {} }
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::SAMPLE_LISTS).unwrap(); while let Some(tree) = tree_iter.next() { let n = tree.next_sample_array().unwrap(); drop(tree_iter); for _ in n {} // ERROR }
pub fn left_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]
pub fn left_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]Failing examples
An error will be returned if [’crate::TreeFlags::SAMPLE_LISTS`] is not used:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); // Error while let Some(tree) = tree_iter.next() { let l = tree.left_sample_array().unwrap(); for _ in l {} }
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::SAMPLE_LISTS).unwrap(); while let Some(tree) = tree_iter.next() { let l = tree.left_sample_array().unwrap(); drop(tree_iter); for _ in l {} // Error }
pub fn right_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]
pub fn right_sample_array(&self) -> Result<&[tsk_id_t], TskitError>
[src]Failing examples
An error will be returned if [’crate::TreeFlags::SAMPLE_LISTS`] is not used:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); // ERROR while let Some(tree) = tree_iter.next() { let r = tree.right_sample_array().unwrap(); for _ in r {} }
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::SAMPLE_LISTS).unwrap(); while let Some(tree) = tree_iter.next() { let r = tree.right_sample_array().unwrap(); drop(tree_iter); for _ in r {} // ERROR }
pub fn left_sib_array(&self) -> &[tsk_id_t]
[src]
pub fn left_sib_array(&self) -> &[tsk_id_t]
[src]Failing examples
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); while let Some(tree) = tree_iter.next() { let r = tree.left_sib_array(); drop(tree_iter); for _ in r {} // ERROR }
pub fn right_sib_array(&self) -> &[tsk_id_t]
[src]
pub fn right_sib_array(&self) -> &[tsk_id_t]
[src]Failing examples
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); while let Some(tree) = tree_iter.next() { let r = tree.right_sib_array(); drop(tree_iter); for _ in r {} // ERROR }
pub fn left_child_array(&self) -> &[tsk_id_t]
[src]
pub fn left_child_array(&self) -> &[tsk_id_t]
[src]Failing examples
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); while let Some(tree) = tree_iter.next() { let l = tree.left_child_array(); drop(tree_iter); for _ in l {} // ERROR }
pub fn right_child_array(&self) -> &[tsk_id_t]
[src]
pub fn right_child_array(&self) -> &[tsk_id_t]
[src]Failing examples
The lifetime of the slice is tied to the parent object:
use streaming_iterator::StreamingIterator; let tables = tskit::TableCollection::new(1.).unwrap(); let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); let mut tree_iter = treeseq.tree_iterator(tskit::TreeFlags::default()).unwrap(); while let Some(tree) = tree_iter.next() { let r = tree.right_child_array(); drop(tree_iter); for _ in r {} // ERROR }
pub fn left_child(&self, u: tsk_id_t) -> Result<tsk_id_t, TskitError>
[src]
pub fn left_child(&self, u: tsk_id_t) -> Result<tsk_id_t, TskitError>
[src]pub fn right_child(&self, u: tsk_id_t) -> Result<tsk_id_t, TskitError>
[src]
pub fn right_child(&self, u: tsk_id_t) -> Result<tsk_id_t, TskitError>
[src]pub fn samples_to_vec(&self) -> Vec<tsk_id_t>
[src]
👎 Deprecated since 0.2.3: Please use Tree::sample_nodes instead
pub fn samples_to_vec(&self) -> Vec<tsk_id_t>
[src]Please use Tree::sample_nodes instead
Obtain the list of samples for the current tree/tree sequence as a vector.
pub fn sample_nodes(&self) -> &[tsk_id_t]
[src]
pub fn sample_nodes(&self) -> &[tsk_id_t]
[src]Get the list of sample nodes as a slice.
pub fn path_to_root(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]
👎 Deprecated since 0.2.3: Please use Tree::parents instead
pub fn path_to_root(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]Please use Tree::parents instead
Return an Iterator
from the node u
to the root of the tree.
Errors
TskitError::IndexError
if u
is out of range.
pub fn parents(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]
pub fn parents(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]Return an Iterator
from the node u
to the root of the tree,
travering all parent nodes.
Errors
TskitError::IndexError
if u
is out of range.
pub fn children(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]
pub fn children(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]pub fn samples(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]
pub fn samples(
&self,
u: tsk_id_t
) -> Result<impl Iterator<Item = tsk_id_t> + '_, TskitError>
[src]Return an Iterator
over the sample nodes descending from node u
.
Note
If u
is itself a sample, then it is included in the values returned.
Errors
TskitError::IndexError
if u
is out of range.
TskitError::NotTrackingSamples
if TreeFlags::SAMPLE_LISTS
was not used
to initialize self
.
pub fn roots_to_vec(&self) -> Vec<tsk_id_t>
[src]
pub fn roots_to_vec(&self) -> Vec<tsk_id_t>
[src]Return all roots as a vector.
pub fn traverse_nodes(
&self,
order: NodeTraversalOrder
) -> Box<dyn Iterator<Item = tsk_id_t>>
[src]
pub fn traverse_nodes(
&self,
order: NodeTraversalOrder
) -> Box<dyn Iterator<Item = tsk_id_t>>
[src]Return an Iterator
over all nodes in the tree.
Parameters
order
: A value fromNodeTraversalOrder
specifying the iteration order.
pub fn node_table<'a>(&'a self) -> NodeTable<'a>
[src]
pub fn node_table<'a>(&'a self) -> NodeTable<'a>
[src]Return the crate::NodeTable
for this current tree
(and the tree sequence from which it came).
This is a convenience function for accessing node times, etc..
pub fn total_branch_length(&self, by_span: bool) -> Result<f64, TskitError>
[src]
pub fn total_branch_length(&self, by_span: bool) -> Result<f64, TskitError>
[src]Calculate the total length of the tree via a preorder traversal.
Parameters
by_span
: iftrue
, multiply the return value byTree::span
.
Errors
TskitError
may be returned if a node index is out of range.
pub fn num_tracked_samples(&self, u: tsk_id_t) -> Result<u64, TskitError>
[src]
pub fn num_tracked_samples(&self, u: tsk_id_t) -> Result<u64, TskitError>
[src]pub fn kc_distance(&self, other: &Tree, lambda: f64) -> Result<f64, TskitError>
[src]
pub fn kc_distance(&self, other: &Tree, lambda: f64) -> Result<f64, TskitError>
[src]Calculate the average Kendall-Colijn (K-C
) distance between
pairs of trees whose intervals overlap.
Note
Parameters
lambda
specifies the relative weight of topology and branch length. Iflambda
is 0, we only consider topology. Iflambda
is 1, we only consider branch lengths.
Trait Implementations
impl DoubleEndedStreamingIterator for Tree
[src]
impl DoubleEndedStreamingIterator for Tree
[src]impl StreamingIterator for Tree
[src]
impl StreamingIterator for Tree
[src]fn get(&self) -> Option<&Tree>
[src]
fn get(&self) -> Option<&Tree>
[src]Returns a reference to the current element of the iterator. Read more
fn next(&mut self) -> Option<&Self::Item>
[src]
fn next(&mut self) -> Option<&Self::Item>
[src]Advances the iterator and returns the next value. Read more
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]Returns the bounds on the remaining length of the iterator.
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(&Self::Item) -> bool,
[src]
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(&Self::Item) -> bool,
[src]Determines if all elements of the iterator satisfy a predicate.
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(&Self::Item) -> bool,
[src]
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(&Self::Item) -> bool,
[src]Determines if any elements of the iterator satisfy a predicate.
fn chain<I>(self, other: I) -> Chain<Self, I> where
I: StreamingIterator<Item = Self::Item>,
[src]
fn chain<I>(self, other: I) -> Chain<Self, I> where
I: StreamingIterator<Item = Self::Item>,
[src]Consumes two iterators and returns a new iterator that iterates over both in sequence.
fn cloned(self) -> Cloned<Self> where
Self::Item: Clone,
[src]
fn cloned(self) -> Cloned<Self> where
Self::Item: Clone,
[src]Produces a normal, non-streaming, iterator by cloning the elements of this iterator.
fn count(self) -> usize
[src]
fn count(self) -> usize
[src]Consumes the iterator, counting the number of remaining elements and returning it.
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]Creates an iterator which uses a closure to determine if an element should be yielded.
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F> where
F: FnMut(&Self::Item) -> Option<B>,
[src]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F> where
F: FnMut(&Self::Item) -> Option<B>,
[src]Creates an iterator which both filters and maps by applying a closure to elements.
fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F> where
F: FnMut(&Self::Item) -> J,
J: StreamingIterator,
[src]
fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F> where
F: FnMut(&Self::Item) -> J,
J: StreamingIterator,
[src]Creates an iterator which flattens iterators obtained by applying a closure to elements. Note that the returned iterators must be streaming iterators. Read more
fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F> where
F: FnMut(&Self::Item) -> Option<B>,
[src]
fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F> where
F: FnMut(&Self::Item) -> Option<B>,
[src]Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements.
fn find<F>(&mut self, f: F) -> Option<&Self::Item> where
F: FnMut(&Self::Item) -> bool,
[src]
fn find<F>(&mut self, f: F) -> Option<&Self::Item> where
F: FnMut(&Self::Item) -> bool,
[src]Returns the first element of the iterator that satisfies the predicate.
fn fuse(self) -> Fuse<Self>
[src]
fn fuse(self) -> Fuse<Self>
[src]Creates an iterator which is “well behaved” at the beginning and end of iteration. Read more
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
[src]Call a closure on each element, passing the element on.
The closure is called upon calls to advance
or advance_back
, and exactly once per element
regardless of how many times (if any) get
is called. Read more
fn map<B, F>(self, f: F) -> Map<Self, B, F> where
F: FnMut(&Self::Item) -> B,
[src]
fn map<B, F>(self, f: F) -> Map<Self, B, F> where
F: FnMut(&Self::Item) -> B,
[src]Creates an iterator which transforms elements of this iterator by passing them to a closure.
fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F> where
F: FnMut(&Self::Item) -> B,
[src]
fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F> where
F: FnMut(&Self::Item) -> B,
[src]Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure.
fn map_ref<B, F>(self, f: F) -> MapRef<Self, F> where
F: Fn(&Self::Item) -> &B,
B: ?Sized,
[src]
fn map_ref<B, F>(self, f: F) -> MapRef<Self, F> where
F: Fn(&Self::Item) -> &B,
B: ?Sized,
[src]Creates an iterator which transforms elements of this iterator by passing them to a closure. Read more
fn nth(&mut self, n: usize) -> Option<&Self::Item>
[src]
fn nth(&mut self, n: usize) -> Option<&Self::Item>
[src]Consumes the first n
elements of the iterator, returning the next one.
fn position<F>(&mut self, f: F) -> Option<usize> where
F: FnMut(&Self::Item) -> bool,
[src]
fn position<F>(&mut self, f: F) -> Option<usize> where
F: FnMut(&Self::Item) -> bool,
[src]Returns the index of the first element of the iterator matching a predicate.
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]Creates an iterator that skips initial elements matching a predicate.
fn take(self, n: usize) -> Take<Self>
[src]
fn take(self, n: usize) -> Take<Self>
[src]Creates an iterator which only returns the first n
elements.
fn take_while<F>(self, f: F) -> TakeWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
fn take_while<F>(self, f: F) -> TakeWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]Creates an iterator which only returns initial elements matching a predicate.
fn rev(self) -> Rev<Self> where
Self: DoubleEndedStreamingIterator,
[src]
fn rev(self) -> Rev<Self> where
Self: DoubleEndedStreamingIterator,
[src]Creates an iterator which returns elemens in the opposite order.
impl TskitTypeAccess<tsk_tree_t> for Tree
[src]
impl TskitTypeAccess<tsk_tree_t> for Tree
[src]fn as_ptr(&self) -> *const tsk_tree_t
[src]
fn as_ptr(&self) -> *const tsk_tree_t
[src]Return const pointer
fn as_mut_ptr(&mut self) -> *mut tsk_tree_t
[src]
fn as_mut_ptr(&mut self) -> *mut tsk_tree_t
[src]Return mutable pointer