You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your metadata are generated in `JSON` format via `serde` (see [here](metadata_derive.md)), then the metadata are simple to access from Python.
6
+
The code repository for `tskit-rust` contains examples in the `python/` subdirectory.
7
+
8
+
You may work with `JSON` metadata with or without a metadata schema (see [here](https://tskit.dev/tskit/docs/stable/metadata.html)).
9
+
A schema is useful for data validation but there is an unfortunate inefficiency if your input to Python is a tree sequence rather than a table collection.
10
+
You will have to copy the tables, add the metadata schema, and regenerate a tree sequence.
11
+
See the examples mentioned above.
12
+
13
+
## Other formats
14
+
15
+
The `tskit-python` API only supports `JSON` and Python's `struct` data formats.
16
+
It is useful to use a format other than `JSON` in order to minimize storage requirements.
17
+
However, doing so will require that you provide a method to covert the data into a valid Python object.
18
+
19
+
An easy way to provide conversion methods is to use [pyo3](https://pyo3.rs) to create a small Python module to deserialize your metadata into Python objects.
20
+
The `tskit-rust` code repository contains an example of this in the `python/` subdirectory.
21
+
The module is shown in its entirety below:
22
+
23
+
```rust, noplaygound, ignore
24
+
{{#include ../../python/tskit_glue/src/lib.rs}}
25
+
```
26
+
27
+
Using it in Python is just a matter of importing the module:
0 commit comments