pub struct TreeInterface { /* private fields */ }

Implementations

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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}

Return the [left, right) coordinates of the tree.

Return the length of the genome for which this tree is the ancestry.

Get the parent of node u.

Errors

TskitError if u is out of range.

Get the left child of node u.

Errors

TskitError if u is out of range.

Get the right child of node u.

Errors

TskitError if u is out of range.

Get the left sib of node u.

Errors

TskitError if u is out of range.

Get the right sib of node u.

Errors

TskitError::IndexError if u is out of range.

👎Deprecated since 0.2.3: Please use Tree::sample_nodes instead

Obtain the list of samples for the current tree/tree sequence as a vector.

Panics

Will panic if the number of samples is too large to cast to a valid id.

Get the list of sample nodes as a slice.

👎Deprecated since 0.2.3: 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.

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.

Return an Iterator over the children of node u.

Errors

TskitError::IndexError if u is out of range.

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.

Return an Iterator over the roots of the tree.

Note

For a tree with multiple roots, the iteration starts at the left root.

Return all roots as a vector.

Return an Iterator over all nodes in the tree.

Parameters

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..

Calculate the total length of the tree via a preorder traversal.

Parameters
Errors

TskitError may be returned if a node index is out of range.

Get the number of samples below node u.

Errors

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. If lambda is 0, we only consider topology. If lambda is 1, we only consider branch lengths.

Return the virtual root of the tree.

Trait Implementations

Return const pointer
Return mutable pointer

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Drops the content pointed by this pointer and frees it. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.