Loading JSON serialised objects#
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 |
---|---|---|---|---|---|---|---|---|---|
0.8699 | 3.6640 | 0.9110 | 1.5907 | 2.1246 | 6.0241 | 8.2213 | 1.2295 | 0.6296 | 1.2502 |
T>C |
---|
3.4168 |
edge | parent | length |
---|---|---|
Galago | root | 0.1734 |
HowlerMon | root | 0.0450 |
Rhesus | edge.3 | 0.0215 |
Orangutan | edge.2 | 0.0078 |
Gorilla | edge.1 | 0.0025 |
Human | edge.0 | 0.0061 |
Chimpanzee | edge.0 | 0.0028 |
edge.0 | edge.1 | 0.0000 |
edge.1 | edge.2 | 0.0033 |
edge.2 | edge.3 | 0.0121 |
edge.3 | root | 0.0077 |
A | C | G | T |
---|---|---|---|
0.3757 | 0.1742 | 0.2095 | 0.2406 |