From 4d5681c4b6ec40078c776dfdbd41d0439ca34519 Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Mon, 25 Mar 2024 14:26:22 +0100 Subject: [PATCH] Load results from json --- ahfe_tutorial/python_tutorial.ipynb | 56 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/ahfe_tutorial/python_tutorial.ipynb b/ahfe_tutorial/python_tutorial.ipynb index 20574eb..c7105c7 100644 --- a/ahfe_tutorial/python_tutorial.ipynb +++ b/ahfe_tutorial/python_tutorial.ipynb @@ -812,18 +812,10 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "id": "d0f6b8fb-dde2-442a-b641-3160a70e2f84", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "AHFE dG: -0.8757588273304342 kilocalorie_per_mole, err 0.15236223232996626 kilocalorie_per_mole\n" - ] - } - ], + "outputs": [], "source": [ "# Get the complex and solvent results\n", "protocol_results = protocol.gather([dag_results])\n", @@ -833,7 +825,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "id": "847b5663-2e6c-4cb2-aa9d-39d132fcff3d", "metadata": {}, "outputs": [], @@ -852,17 +844,51 @@ " }\n", "}\n", "\n", - "with gzip.open(\"ahfe_benzene_json_results.gz\", 'wt') as zipfile:\n", - " json.dump(outdict, zipfile, cls=gufe.tokenization.JSON_HANDLER.encoder)" + "with open(\"ahfe_json/benzene_results.json\") as stream:\n", + " json.dump(outdict, stream, cls=gufe.tokenization.JSON_HANDLER.encoder)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "f62f69a1-09c0-4a4a-9b37-9663b51a75ac", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "import gzip\n", + "import json\n", + "import gufe\n", + "\n", + "outfile = \"ahfe_json/benzene_results.json\"\n", + "with open(outfile) as stream:\n", + " results = json.load(stream)\n", + " estimate = results['estimate']\n", + " uncertainty = results['uncertainty']" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "3b459b28-a4dc-4fa9-a961-b106c45d79ce", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'magnitude': -0.7536190151704971,\n", + " 'unit': 'kilocalorie_per_mole',\n", + " ':is_custom:': True,\n", + " 'pint_unit_registry': 'openff_units'}" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "estimate" + ] } ], "metadata": {