pub struct TableViews { /* private fields */ }

Implementations

Get reference to the EdgeTable.

Get reference to the NodeTable.

Get mutable reference to the NodeTable.

Get reference to the SiteTable.

Get reference to the MutationTable.

Get reference to the IndividualTable.

Get reference to the PopulationTable.

Get reference to the MigrationTable.

Available on crate feature provenance only.

Get reference to the ProvenanceTable

Return an iterator over the edges.

Return an iterator over the nodes.

Return an iterator over the sites.

Return an iterator over the mutations.

Return an iterator over the individuals.

Return an iterator over the populations.

Return an iterator over the migrations.

Available on crate feature provenance only.

Return an iterator over provenances

Obtain a vector containing the indexes (“ids”) of all nodes for which crate::TSK_NODE_IS_SAMPLE is true.

The provided implementation dispatches to crate::NodeTable::samples_as_vector.

Obtain a vector containing the indexes (“ids”) of all nodes satisfying a certain criterion.

The provided implementation dispatches to crate::NodeTable::create_node_id_vector.

Parameters
  • f: a function. The function is passed the current table collection and each crate::node_table::NodeTableRow. If f returns true, the index of that row is included in the return value.
Examples

Get all nodes with time > 0.0:

use tskit::bindings::tsk_id_t;

let mut tables = tskit::TableCollection::new(100.).unwrap();
tables
    .add_node(tskit::TSK_NODE_IS_SAMPLE, 0.0, tskit::PopulationId::NULL,
    tskit::IndividualId::NULL)
    .unwrap();
tables
    .add_node(tskit::TSK_NODE_IS_SAMPLE, 1.0, tskit::PopulationId::NULL,
    tskit::IndividualId::NULL)
    .unwrap();
let samples = tables.create_node_id_vector(
    |row: &tskit::NodeTableRow| row.time > 0.,
);
assert_eq!(samples[0], 1);

// Get all nodes that have a mutation:

fn node_has_mutation(
    // dyn trait here means this
    // will work with TreeSequence, too.
    tables_type: &dyn std::ops::Deref<Target=tskit::table_views::TableViews>,
    row: &tskit::NodeTableRow,
) -> bool {
    for mrow in tables_type.mutations_iter() {
        if mrow.node == row.id {
            return true;
        }
    }
    false
}

// Get all nodes that have a mutation:

tables.add_mutation(0, 0, tskit::MutationId::NULL, 0.0, None).unwrap();
let samples_with_mut = tables.create_node_id_vector(
    |row: &tskit::NodeTableRow| node_has_mutation(&tables, row));
assert_eq!(samples_with_mut[0], 0);

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.