diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index ca59c79c5..d0350fc14 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -13,3 +13,4 @@ - [Initialization from a table collection](./tree_sequence_from_table_collection.md) - [Iterating over trees](./tree_sequence_iterate_trees.md) - [Working with trees](./tree_sequence_tree.md) + - [Miscellaneous operations](./tree_sequence_miscellaneous.md) diff --git a/book/src/tree_sequence_miscellaneous.md b/book/src/tree_sequence_miscellaneous.md new file mode 100644 index 000000000..71570fe76 --- /dev/null +++ b/book/src/tree_sequence_miscellaneous.md @@ -0,0 +1,37 @@ +## Miscellaneous operations + +### Writing to a file + +```rust, noplayground, ignore +treeseq.dump("file.trees", tskit::TableOutputOptions::default()).unwrap(); +``` + +### Loading from a file + +```rust, noplayground, ignore +let treeseq = tskit::TreeSequence::load("file.trees").unwrap(); +``` + +### Get a deep copy of the tables + +Get a *copy* of the table collection in the tree sequence: + +```rust, noplayground, ignore +let tables = treeseq.dump_tables.unwrap(); +``` + +This function can error because the `tskit-c` functions to copy ,may return an error code. + +This function is not necessary to access the tables. +See below. + +### Read-only table access + +A `TreeSequence` has a `Deref` target giving read-only access to the tables: + +```rust, noplayground, ignore +for _edge in treeseq.edges_iter() { +} +``` + +