Loading JSON serialised objects#
Note
These docs now use the new_type
core objects via the following setting.
import os
# using new types without requiring an explicit argument
os.environ["COGENT3_NEW_TYPE"] = "1"
The load_json
app loads JSON serialised cogent3
objects from a file, returning whatever was stored.
In the writing JSON section, we wrote a likelihood function object to disk in JSON serialised format, now let’s load it back! All we need is the path to which it was written. Since write_json
writes to a data store, this will be <path_to_dstore>/<identifier>
.
Tip
To follow along with this example, first head to the writing JSON section to write out this data, or replace the path with a JSON file on your machine.
from cogent3 import get_app
load_json_app = get_app("load_json")
lf = load_json_app(f"{path_to_dstore}/gn_params.json")
lf
GN
log-likelihood = -6987.9632
number of free parameters = 22
A>C | A>G | A>T | C>A | C>G | C>T | G>A | G>C | G>T | T>A | T>C |
---|---|---|---|---|---|---|---|---|---|---|
0.87 | 3.66 | 0.91 | 1.59 | 2.12 | 6.02 | 8.22 | 1.23 | 0.63 | 1.25 | 3.42 |
edge | parent | length |
---|---|---|
Galago | root | 0.17 |
HowlerMon | root | 0.04 |
Rhesus | edge.3 | 0.02 |
Orangutan | edge.2 | 0.01 |
Gorilla | edge.1 | 0.00 |
Human | edge.0 | 0.01 |
Chimpanzee | edge.0 | 0.00 |
edge.0 | edge.1 | 0.00 |
edge.1 | edge.2 | 0.00 |
edge.2 | edge.3 | 0.01 |
edge.3 | root | 0.01 |
A | C | G | T |
---|---|---|---|
0.38 | 0.17 | 0.21 | 0.24 |