{ "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": [], "source": [ "from __future__ import print_function\n", "import cobra.test\n", "model = cobra.test.create_test_model()\n", "\n", "for metabolite in model.metabolites:\n", " metabolite.id = \"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_dcaACP_c | \n", "
Name | Decanoyl-ACP-n-C100ACP | \n", "
Memory address | \n", "0x0110f09630 | \n", "
Formula | C21H39N2O8PRS | \n", "