Skip to content

doc: add book section on misc. ops on treeseqs #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2022
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
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() {
}
```