Skip to content

Commit

Permalink
gapfilling.ipynb bug fix (#1331)
Browse files Browse the repository at this point in the history
* gapfilling.ipynb bug fix

Hi,
I noticed that the gapfilling.ipynb notebook in the documentation has an error in the second cell:
First the reaction is not called correctly. I changed add_reaction() for add_reactions() which the correct way of calling it.
Second, the argument in the add_reactions() function needs to be an iterable so I enclosed the reaction.copy() in [].
Third, the cell needs to import cobra to work.

Finally, some of the output that I got in the following cells differ a little bit from what you have in the original notebook.

I hope you find these changes useful.

* Solver updated to "glpk"

Here is an updated version of the notebook with the "GLPK" solver. Nevertheless, there are still little changes in the output compared to the original notebook. Specifically, the final output is "PGI" instead of "F6PA"
  • Loading branch information
pablodig committed May 2, 2023
1 parent 4d2cffe commit b535a4f
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions documentation_builder/gapfilling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"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"
]
}
],
"outputs": [],
"source": [
"from cobra.io import load_model\n",
"from cobra.flux_analysis import gapfill\n",
Expand All @@ -70,14 +60,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import cobra\n",
"universal = cobra.Model(\"universal_reactions\")\n",
"for i in [i.id for i in model.metabolites.f6p_c.reactions]:\n",
" reaction = model.reactions.get_by_id(i)\n",
" universal.add_reaction(reaction.copy())\n",
" universal.add_reactions([reaction.copy()])\n",
" model.remove_reactions([reaction])"
]
},
Expand All @@ -90,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -99,7 +90,7 @@
"0.0"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -117,15 +108,15 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GF6PTA\n",
"TALA\n"
"TALA\n",
"GF6PTA\n"
]
}
],
Expand All @@ -144,26 +135,26 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"---- Run 1 ----\n",
"GF6PTA\n",
"TALA\n",
"---- Run 2 ----\n",
"GF6PTA\n",
"---- Run 2 ----\n",
"TALA\n",
"GF6PTA\n",
"---- Run 3 ----\n",
"TKT2\n",
"GF6PTA\n",
"FBP\n",
"PGI\n",
"---- Run 4 ----\n",
"GF6PTA\n",
"TALA\n"
"TALA\n",
"GF6PTA\n"
]
}
],
Expand All @@ -184,14 +175,14 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"F6PA\n"
"PGI\n"
]
}
],
Expand Down Expand Up @@ -227,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit b535a4f

Please sign in to comment.