Skip to content

Commit

Permalink
docs: add details on loading json result files
Browse files Browse the repository at this point in the history
reorder to mention command line results first as this is the easier route to follow
  • Loading branch information
richardjgowers committed Apr 2, 2024
1 parent 21cea74 commit dda3318
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions docs/guide/results/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ For exact details on what is produced consult the :ref:`pages for each Protocol<

.. todo crossref to HREX and MD Protocol docs from issue 743
How you can inspect these results depends on whether you are doing this from the Python or command line interface.

From a Python interface
-----------------------

Executing a :class:`.ProtocolDAG` using :func:`openfe.execute_DAG` will produce a :class:`.ProtocolDAGResult`,
representing a single iteration of estimating the free energy difference.
One or more of these can be put into the ``.gather()`` method of the ``Protocol`` to form a :class:`.ProtocolResult`,
this class takes care of the averaging and concatenation of different iterations of the estimation process.
This ``ProtocolResult`` class has ``.get_estimate()`` and ``.get_uncertainty()`` methods which return the estimates
of free energy difference along with its uncertainty.
How you can inspect these results depends on whether you are doing this from the command line or a Python script.

From the command line
---------------------
Expand All @@ -34,5 +24,33 @@ then a ``.json`` results log file as well as a directory of files will have been
Most importantly, the ``.json`` results file has ``estimate`` and ``uncertainty`` keys,
which serve the same purpose as the ``get_estimate()`` and ``get_uncertainty()`` methods described above.

The ``json`` results file can be loaded into a Python session as::

>>> import gufe
>>> import json
>>>
>>> with open('././Transformation-97d7223f918bbdb0570edc2a49bbc43e_results.json', 'r') as f:
... results = json.load(f, cls=gufe.tokenization.JSON_HANDLER.decoder)
>>> results['estimate']
-19.889719513104342 <Unit('kilocalorie_per_mole')>
>>> results['uncertainty']
0.574685524681712 <Unit('kilocalorie_per_mole')>


See Also
~~~~~~~~

The :ref:`openfe gather <cli_gather>` command offers a way to collate information across many different individual
simulations and prepare a table of results.


From a Python interface
-----------------------

Executing a :class:`.ProtocolDAG` using :func:`openfe.execute_DAG` will produce a :class:`.ProtocolDAGResult`,
representing a single iteration of estimating the free energy difference.
One or more of these can be put into the ``.gather()`` method of the ``Protocol`` to form a :class:`.ProtocolResult`,
this class takes care of the averaging and concatenation of different iterations of the estimation process.
This ``ProtocolResult`` class has ``.get_estimate()`` and ``.get_uncertainty()`` methods which return the estimates
of free energy difference along with its uncertainty.

0 comments on commit dda3318

Please sign in to comment.