Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
doc: add book section on misc. ops on treeseqs
  • Loading branch information
molpopgen committed Nov 5, 2022
commit 0fc042375c3787218808904587a1486651847ca3
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
37 changes: 37 additions & 0 deletions book/src/tree_sequence_miscellaneous.md
Original file line number Diff line number Diff line change
@@ -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() {
}
```