File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ List of Cookbooks
153153
154154 loading_molecules
155155 dumping_transformation
156+ jq_inspection
156157 choose_protocol
157158 generate_ligand_network
158159 rfe_alchemical_planners
Original file line number Diff line number Diff line change 1+ .. _jq_inspection :
2+
3+ Using ``jq `` to inspect OpenFE JSONs
4+ ==============================================
5+ Sometimes you may want to get a sense of the contents of JSON files, but the files are too unwieldy to inspect one-by-one in a code editor.
6+
7+ `jq <https://github.com/jqlang/jq >`_ is a helpful command-line tool that we recommend for for quickly inspecting JSON files.
8+
9+ Below is a common use-case to get you started, but you can do much more by checking out the `jq manual <https://jqlang.org/manual/ >`_.
10+
11+ To view all the top-level JSON keys, use ``jq "keys" filename.json ``, for example with a results JSON from the tutorial:
12+
13+ .. code :: bash
14+
15+ $ jq " keys" rbfe_lig_ejm_46_solvent_lig_jmc_28_solvent.json
16+ [
17+ " estimate" ,
18+ " protocol_result" ,
19+ " uncertainty" ,
20+ " unit_results"
21+ ]
22+
23+ .. note ::
24+
25+ You can use ``"keys[]" `` instead of ``"keys" `` for a cleaner output.
26+
27+ Now that we know ``estimate `` is at the top-level of the JSON, we can use the following command to see all the values for the ``estimate `` key:
28+
29+ .. code :: bash
30+
31+ $ jq " .estimate" rbfe_lig_ejm_46_solvent_lig_jmc_28_solvent.json
32+ {
33+ " magnitude" : 23.347074789078682,
34+ " unit" : " kilocalorie / mole" ,
35+ " :is_custom:" : true,
36+ " pint_unit_registry" : " openff_units"
37+ }
38+
39+ This can be very helpful for quickly checking results for many files, for example:
40+
41+ .. code :: bash
42+
43+ $ jq " .estimate.magnitude" rbfe* .json
44+ -14.925911852820793
45+ -40.72063957254803
46+ -27.76541486479537
47+ -16.023754604070007
48+ -57.38608716292447
49+ -15.748326155729705
50+ -39.933880531487326
51+ -27.780933075807425
52+ -16.76023951588401
53+ -58.36294851896545
54+ -19.038006312251575
55+ -20.26856586311034
56+ 17.338257573349775
57+ 15.775784163095102
58+ 23.134622420900932
59+ 17.071712542470248
60+ 15.873122071409249
61+ 23.347074789078682
Original file line number Diff line number Diff line change 1+ **Added: **
2+
3+ * Added a cookbook for using ``jq `` to inspect JSON files.
4+
5+ **Changed: **
6+
7+ * <news item>
8+
9+ **Deprecated: **
10+
11+ * <news item>
12+
13+ **Removed: **
14+
15+ * <news item>
16+
17+ **Fixed: **
18+
19+ * <news item>
20+
21+ **Security: **
22+
23+ * <news item>
You can’t perform that action at this time.
0 commit comments