Expand description
A rust interface to tskit.
This crate provides a mapping of the tskit
C API to rust.
The result is an interface similar to the tskit
Python interface,
but with all operations implemented using compiled code.
§Features
§Interface to the C library
TableCollection
wrapstsk_table_collection_t
.TreeSequence
wrapstsk_treeseq_t
.Tree
wrapstsk_tree_t
.- Tree iteration occurs via traits from streaming_iterator.
- Errors returned from C map to
TskitError::ErrorCode
. Their string messages can be obtained by printing the error type.
§Safety
- The types listed above handle all the memory management!
- All array accesses are range-checked.
- Object lifetimes are clear:
- Creating a tree sequence moves/consumes a table collection.
- Tree lifetimes are tied to that of the parent tree sequence.
- Table objects (
NodeTable
, etc..) are only represented by non-owning, immutable types.
§Prelude
The prelude
module contains definitions that are difficult/annoying to live without.
In particuar, this module exports various traits that make it so that client code does
not have to use
them a la carte.
We recomment that client code import all symbols from this module:
use tskit::prelude::*;
The various documentation examples manually use
each trait both in order
to illustrate which traits are needed and to serve as doc tests.
§Optional features
Some features are optional, and are activated by requesting them in your Cargo.toml
file.
-
provenance
- Enables
provenance
- Enables
-
derive
enables the following derive macros:crate::metadata::MutationMetadata
crate::metadata::IndividualMetadata
crate::metadata::SiteMetadata
crate::metadata::EdgeMetadata
crate::metadata::NodeMetadata
crate::metadata::MigrationMetadata
crate::metadata::PopulationMetadata
To see these derive macros in action, take a look
here
.
To add features to your Cargo.toml
file:
[dependencies]
tskit = {version = "0.2.0", features=["feature0", "feature1"]}
§What is missing?
- A lot of wrappers to the C functions.
- Tree sequence statistics!
Re-exports§
pub use bindings::TSK_NODE_IS_SAMPLE;
pub use bindings::tsk_flags_t;
pub use error::TskitError;
Modules§
- bindings
- Low-level (“unsafe”) bindings to the C API.
- error
- Error handling
- metadata
- Support for table row metadata
- prelude
- Export commonly-use types and traits
- provenance
provenance
- Optional module for table and tree sequence provenance tables.
- types
- “Other” tskit types live here.
Macros§
- handle_
metadata_ return - Convenience macro to handle implementing
crate::metadata::MetadataRoundtrip
Structs§
- Edge
Difference - An edge difference. Edge insertions and removals are differentiated by
marker types
Insertion
andRemoval
, respectively. - Edge
Differences - Concrete type implementing
Iterator
overEdgeInsertion
orEdgeRemoval
. Created byEdgeDifferencesIterator::edge_insertions
orEdgeDifferencesIterator::edge_removals
, respectively. - Edge
Differences Iterator - Manages iteration over trees to obtain edge differences.
- EdgeId
- An edge ID
- Edge
Table - An immutable view of an edge table.
- Edge
Table Row - Row of an
EdgeTable
- Individual
Flags - Individual flags
- Individual
Id - An individual ID
- Individual
Table - An immutable view of a individual table.
- Individual
Table Row - Row of a
IndividualTable
- Individual
Table Sort Options - Modify behavior of [
crate::TableCollection::sort_individuals
]. - Insertion
- Marker type for edge insertion.
- Location
- A newtype for the concept of location.
A
Location
may represent a location or the output of arithmetic involving locations. - Migration
Id - A migration ID
- Migration
Table - An immutable view of a migration table.
- Migration
Table Row - Row of a
MigrationTable
- Mutation
Id - A mutation ID
- Mutation
Table - An immutable view of site table.
- Mutation
Table Row - Row of a
MutationTable
- Node
Defaults - Defaults for node table rows without metadata
- Node
Defaults With Metadata - Notes
- Node
Flags - Node flags
- NodeId
- A node ID
- Node
Table - An immtable view of a node table.
- Node
Table Row - Row of a
NodeTable
- Owning
Edge Table - A standalone edge table that owns its data.
- Owning
Individual Table - A standalone individual table that owns its data.
- Owning
Migration Table - A standalone migration table that owns its data.
- Owning
Mutation Table - A standalone mutation table that owns its data.
- Owning
Node Table - A standalone node table that owns its data.
- Owning
Population Table - A standalone population table that owns its data.
- Owning
Site Table - A standalone site table that owns its data.
- Population
Id - A population ID
- Population
Table - An immutable view of site table.
- Population
Table Row - Row of a
PopulationTable
- Position
- A newtype for the concept of “genomic position”.
A
Position
can represent either a locus or a distance between loci. - Provenance
Id provenance
- A provenance ID
- Removal
- Marker type for edge removal.
- Simplification
Options - Control the behavior of
crate::TableCollection::simplify
andcrate::TreeSequence::simplify
- SiteId
- A site ID
- Site
Table - An immutable view of site table.
- Site
Table Row - Row of a
SiteTable
- Size
Type - Wraps
tsk_size_t
- Table
Clear Options - Modify behavior of
crate::TableCollection::clear
. - Table
Collection - A table collection.
- Table
Equality Options - Modify behavior of
crate::TableCollection::equals
. - Table
Integrity Check Flags - Flags to affect the behavior of
TableCollection::check_integrity
. - Table
Output Options - Modify behavior of
crate::TableCollection::dump
. - Table
Sort Options - Modify behavior of
crate::TableCollection::sort
. - Time
- A newtype for the concept of time.
A
Time
value can represent either a point in time or the output of arithmetic involving time. - Tree
- A Tree.
- Tree
Flags - Specify the behavior of iterating over [
Tree
] objects. See [TreeSequence::tree_iterator
]. - Tree
Interface - Tree
Sequence - A tree sequence.
- Tree
Sequence Flags - Modify behavior of
crate::TableCollection::tree_sequence
andcrate::TreeSequence::new
.
Enums§
- Node
Traversal Order - Specify the traversal order used by
TreeInterface::traverse_nodes
.
Traits§
- Individual
Location - Abstraction of individual location.
- Individual
Parents - Abstraction of individual parents.
Functions§
- c_
api_ major_ version - C API major version
- c_
api_ minor_ version - C API minor version
- c_
api_ patch_ version - C API patch version
- c_
api_ version - The C API version in MAJOR.MINOR.PATCH format
- version
- Version of the rust crate.
Type Aliases§
- Edge
Insertion - Type alias for
EdgeDifference<Insertion>
- Edge
Removal - Type alias for
EdgeDifference<Removal>
- RawFlags
- Alias for tsk_flags_t
- TskReturn
Value - Handles return codes from low-level tskit functions.