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
Modules
provenance
Macros
crate::metadata::MetadataRoundtrip
Structs
EdgeTable
IndividualTable
crate::TableCollection::sort_individuals
].Location
may represent a location or the
output of arithmetic involving locations.MigrationTable
MutationTable
NodeTable
PopulationTable
Position
can represent either a locus or a
distance between loci.provenance
crate::TableCollection::simplify
and crate::TreeSequence::simplify
SiteTable
tsk_size_t
crate::TableCollection::clear
.crate::TableCollection::equals
.crate::TableCollection::dump
.crate::TableCollection::sort
.Time
value can represent either a point in time
or the output of arithmetic involving time.Tree
] objects.
See [TreeSequence::tree_iterator
].crate::TableCollection::tree_sequence
and crate::TreeSequence::new
.Enums
TreeInterface::traverse_nodes
.Traits
TableAccess
.