pub struct OwnedMutationTable { /* private fields */ }
Expand description

A standalone mutation table that owns its data.

Examples

use tskit::OwnedMutationTable;

let mut mutations = OwnedMutationTable::default();
let rowid = mutations.add_row(1, 2, 0, 1.0, None).unwrap();
assert_eq!(rowid, 0);
assert_eq!(mutations.num_rows(), 1);

An example with metadata. This requires the cargo feature "derive" for tskit.

use tskit::OwnedMutationTable;

#[derive(serde::Serialize,
         serde::Deserialize,
         tskit::metadata::MutationMetadata)]
#[serializer("serde_json")]
struct MutationMetadata {
    value: i32,
}

let metadata = MutationMetadata{value: 42};

let mut mutations = OwnedMutationTable::default();

let rowid = mutations.add_row_with_metadata(0, 1, 5, 10.0, None, &metadata).unwrap();
assert_eq!(rowid, 0);

match mutations.metadata::<MutationMetadata>(rowid) {
    // rowid is in range, decoding succeeded
    Some(Ok(decoded)) => assert_eq!(decoded.value, 42),
    // rowid is in range, decoding failed
    Some(Err(e)) => panic!("error decoding metadata: {:?}", e),
    None => panic!("row id out of range")
}

Implementations

Clear the table.

Methods from Deref<Target = MutationTable>

Return the number of rows.

Return the site value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the node value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the parent value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the time value from row row of the table.

Errors

Will return IndexError if row is out of range.

Get the derived_state value from row row of the table.

Return

Will return None if there is no derived state.

Errors

Will return IndexError if row is out of range.

Retrieve decoded metadata for a row.

Returns
  • Some(Ok(T)) if row is valid and decoding succeeded.
  • Some(Err(_)) if row is not valid and decoding failed.
  • None if row is not valid.
Errors
Examples.

The big-picture semantics are the same for all table types. See crate::IndividualTable::metadata for examples.

Return an iterator over rows of the table. The value of the iterator is MutationTableRow.

Return row r of the table.

Parameters
  • r: the row id.
Returns
  • Some(row) if r is valid
  • None otherwise

Trait Implementations

Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more

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.