{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# FAQ" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This document will address frequently asked questions not addressed in other pages of the documentation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How do I install cobrapy?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please see the [INSTALL.rst](https://github.com/opencobra/cobrapy/blob/stable/INSTALL.rst) file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How do I cite cobrapy?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please cite the 2013 publication: [10.1186/1752-0509-7-74](http://dx.doi.org/doi:10.1186/1752-0509-7-74)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How do I rename reactions or metabolites?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "TL;DR Use `Model.repair` afterwards\n", "\n", "When renaming metabolites or reactions, there are issues because cobra indexes based off of ID's, which can cause errors. For example:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Scaling...\n", " A: min|aij| = 1.000e+00 max|aij| = 1.000e+00 ratio = 1.000e+00\n", "Problem data seem to be well scaled\n" ] } ], "source": [ "from cobra.io import load_model\n", "model = load_model(\"iYS1720\")\n", "\n", "for metabolite in model.metabolites:\n", " metabolite.id = f\"test_{metabolite.id}\"\n", "\n", "try:\n", " model.metabolites.get_by_id(model.metabolites[0].id)\n", "except KeyError as e:\n", " print(repr(e))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Model.repair function will rebuild the necessary indexes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
Metabolite identifier | test_10fthf_c | \n", "
Name | 10-Formyltetrahydrofolate | \n", "
Memory address | \n", "0x7f9c91ec0a90 | \n", "
Formula | C20H21N7O7 | \n", "
Compartment | c | \n", "
In 9 reaction(s) | \n", " FTHFD, ULA4NFT, GARFT, AICART, TDPFRMT, MTHFC, BIOMASS_Ec_iAF1260_core_59p81M, BIOMASS_invivo, FMETTRS\n", " | \n", "