{ "cells": [ { "cell_type": "markdown", "id": "767b3708-3165-41af-829b-cd59916f024c", "metadata": {}, "source": [ "# Escher Map" ] }, { "cell_type": "code", "execution_count": 10, "id": "bce239f7-e14a-44d3-a7d1-5af668db05c4", "metadata": {}, "outputs": [], "source": [ "import json\n", "import modelseedpy_escher\n", "import modelseedpy_escher.io" ] }, { "cell_type": "code", "execution_count": null, "id": "c16f029e-2adc-4fcf-aec3-bfc79ddfaaa6", "metadata": {}, "outputs": [], "source": [ "em_data = None\n", "with open('/home/fliu/workspace/data/sbml/iAnC892/iAnC892_mapped.core.json', 'r') as fh:\n", " em_data = json.load(fh)" ] }, { "cell_type": "code", "execution_count": null, "id": "1a5f01d6-5b83-46e9-b719-a331b4d7d194", "metadata": {}, "outputs": [], "source": [ "em = modelseed_escher.core.EscherMap(em_data)\n", "cpd_remap = {}\n", "rxn_remap = {}\n", "for o in em_data[1]['nodes']:\n", " n = em_data[1]['nodes'][o]\n", " if n['node_type'] == 'metabolite':\n", " cpd_remap[n['bigg_id']] = n['bigg_id'] + '1'\n", "for o in em_data[1]['reactions']:\n", " n = em_data[1]['reactions'][o]\n", " rxn_remap[n['bigg_id']] = n['bigg_id'] + '1'\n", "em.swap_ids(cpd_remap, rxn_remap)" ] }, { "cell_type": "code", "execution_count": null, "id": "57c4eadb-4388-4202-a551-89ae4d1aab00", "metadata": {}, "outputs": [], "source": [ "with open('/home/fliu/workspace/data/sbml/iAnC892/iAnC892_mapped.core_1.json', 'w') as fh:\n", " fh.write(json.dumps(em_data))" ] }, { "cell_type": "code", "execution_count": 2, "id": "4e7b0ce7-d85b-4478-ab49-8e1a91d063d8", "metadata": {}, "outputs": [], "source": [ "em1 = modelseedpy_escher.io.load_json_map('/home/fliu/workspace/data/sbml/iAnC892/iAnC892_mapped.core_0.json')\n", "em2 = modelseedpy_escher.io.load_json_map('/home/fliu/workspace/data/sbml/iAnC892/iAnC892_mapped.core_1.json')" ] }, { "cell_type": "code", "execution_count": 7, "id": "843bd680-a9a4-45f8-9474-c212a017d641", "metadata": {}, "outputs": [], "source": [ "grid = modelseedpy_escher.EscherGrid()\n", "master = grid.build([em1, em2], (2, 1))" ] }, { "cell_type": "code", "execution_count": 11, "id": "5990b447-b6d4-4268-9540-391b39c318f6", "metadata": {}, "outputs": [], "source": [ "with open('/home/fliu/workspace/data/sbml/iAnC892/iAnC892_mapped.core_1_0.json', 'w') as fh:\n", " fh.write(json.dumps(master.escher_data))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" } }, "nbformat": 4, "nbformat_minor": 5 }