{ "cells": [ { "cell_type": "markdown", "id": "36af7001", "metadata": {}, "source": [ "# PyCoMo Maximum Growth-Rate #\n", "This tutorial show-cases how to find the maximum growth-rate of a community - across all possible abundance profiles.\n", "\n", "The expected runtime for this notebook is less than 10 minutes." ] }, { "cell_type": "code", "execution_count": 1, "id": "2cadb7fd-5d68-4c2b-b803-d6c39ebbf828", "metadata": { "tags": [] }, "outputs": [], "source": [ "from pathlib import Path\n", "import sys\n", "import os\n", "import cobra\n", "import math \n", "import time\n", "import warnings" ] }, { "cell_type": "code", "execution_count": 2, "id": "30fa3103-2733-43c7-800a-14db6486fe3e", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:01:29,406 - PyCoMo - INFO - Logger initialized.\n" ] } ], "source": [ "import pycomo\n", "pycomo.configure_logger(level=\"info\")" ] }, { "cell_type": "markdown", "id": "686051ed", "metadata": {}, "source": [ "## Load the Toy Models ##\n", "These are simple toy models of 2 organisms. In a community, they are expexted to grow at a maximum of 10/h, however one organism alone can grow as fast as 15/h. Both cases can be calculated." ] }, { "cell_type": "code", "execution_count": 3, "id": "3d8fef41-c444-4888-a560-b0f8c444d4e3", "metadata": { "tags": [] }, "outputs": [], "source": [ "# create two cobra models from sbml (change the path according to where the models are located)\n", "toy1 = cobra.io.read_sbml_model(\"../data/use_case/toy_models/toy_1.xml\")\n", "toy2 = cobra.io.read_sbml_model(\"../data/use_case/toy_models/toy_2_2.xml\")\n", "\n", "# create Single Organism Models from cobra models\n", "Toy1 = pycomo.SingleOrganismModel(toy1, \"toy1\")\n", "Toy2 = pycomo.SingleOrganismModel(toy2, \"toy2\")\n", "\n", "# create Community Model from Single Organism Models\n", "C = pycomo.CommunityModel([Toy1, Toy2], name = \"Toy_community\")\n", "# instantiate the model and set cplex as a solver (if available)\n", "#C.model.solver = \"cplex\"" ] }, { "cell_type": "markdown", "id": "8a5e3d76-7f16-4e9d-8c30-a08bce46d809", "metadata": {}, "source": [ "## Compute maximum community growth rate\n", "\n", "The method ```max_growth_rate``` calculates the overall maximum growth rate of the community, regardless of its composition." ] }, { "cell_type": "code", "execution_count": 4, "id": "4ffa3cd7-ab7f-46ec-af13-1b833c74bbbd", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:01:29,498 - PyCoMo - INFO - No community model generated yet. Generating now:\n", "2025-11-24 16:01:29,505 - PyCoMo - INFO - Identified biomass reaction from objective: R4\n", "2025-11-24 16:01:29,522 - PyCoMo - INFO - Identified biomass reaction from objective: R4\n", "2025-11-24 16:01:29,553 - PyCoMo - WARNING - Not all reactions in the model are mass and charge balanced. To check which reactions are imbalanced, please run the get_unbalanced_reactions method of this CommunityModel object\n", "2025-11-24 16:01:29,553 - PyCoMo - INFO - Generated community model.\n", "2025-11-24 16:01:29,554 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 2e-06\n", "2025-11-24 16:01:31,855 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:31,890 - PyCoMo - INFO - New round: lb: 10.0, ub: 1000.0, x: 10.000002\n", "2025-11-24 16:01:34,232 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:34,264 - PyCoMo - INFO - New round: lb: 15.000000000000002, ub: 1000.0, x: 15.000002000000002\n", "2025-11-24 16:01:36,526 - PyCoMo - WARNING - worker 11288: toy1_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:36,527 - PyCoMo - WARNING - worker 11288: toy1_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:36,528 - PyCoMo - WARNING - worker 11288: toy2_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:36,529 - PyCoMo - WARNING - worker 11288: toy2_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:36,529 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:36,557 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction NaN\n", "toy2_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:36,558 - PyCoMo - INFO - New round: lb: 15.000000000000002, ub: 15.000002000000002, x: 15.000001000000001\n", "2025-11-24 16:01:38,929 - PyCoMo - WARNING - worker 30056: toy1_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:38,930 - PyCoMo - WARNING - worker 30056: toy1_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:38,931 - PyCoMo - WARNING - worker 30056: toy2_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:38,932 - PyCoMo - WARNING - worker 30056: toy2_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:38,932 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:38,961 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction NaN\n", "toy2_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:38,964 - PyCoMo - INFO - Maximum growth-rate is 15.0\n" ] }, { "data": { "text/plain": [ "np.float64(15.0)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "C.max_growth_rate()" ] }, { "cell_type": "markdown", "id": "77e1e1bf-9532-4222-8120-d876fb1a4083", "metadata": {}, "source": [ "```max_growth_rate``` has the following parameters:\n", "* ```minimal_abundance``` (default = 0)\n", "* ```return_abundances``` (default = False)\n", "* ```sensitivity``` (default = 6)\n", "* ```gurobi``` (default = False)" ] }, { "cell_type": "markdown", "id": "19981da5-150c-40dc-86d0-9a391082c303", "metadata": { "tags": [] }, "source": [ "### Return Abundances\n", "By setting the parameter ```return_abundances``` to ```True```, additional information about the feasible community compositions at the maximum growth rate is returned in the form of a pandas dataframe.\n", "\n", "The minimal flux of x_fraction_reaction corresponds to the minimal abundance of member x in the community. Likewise, the maximal flux corresponds to the maximal abundance of member x." ] }, { "cell_type": "code", "execution_count": 5, "id": "ae13806a-8cf2-4ddc-b509-86ba9a2cce7f", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:01:38,975 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 2e-06\n", "2025-11-24 16:01:41,724 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:41,762 - PyCoMo - INFO - New round: lb: 10.0, ub: 1000.0, x: 10.000002\n", "2025-11-24 16:01:44,298 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:44,332 - PyCoMo - INFO - New round: lb: 15.000000000000002, ub: 1000.0, x: 15.000002000000002\n", "2025-11-24 16:01:46,793 - PyCoMo - WARNING - worker 22840: toy1_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:46,794 - PyCoMo - WARNING - worker 22840: toy1_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:46,795 - PyCoMo - WARNING - worker 22840: toy2_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:46,796 - PyCoMo - WARNING - worker 22840: toy2_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:46,797 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:46,826 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction NaN\n", "toy2_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:46,827 - PyCoMo - INFO - New round: lb: 15.000000000000002, ub: 15.000002000000002, x: 15.000001000000001\n", "2025-11-24 16:01:49,179 - PyCoMo - WARNING - worker 33748: toy1_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:49,180 - PyCoMo - WARNING - worker 33748: toy1_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:49,181 - PyCoMo - WARNING - worker 33748: toy2_fraction_reaction min flux is infeasible\n", "2025-11-24 16:01:49,182 - PyCoMo - WARNING - worker 33748: toy2_fraction_reaction max flux is infeasible\n", "2025-11-24 16:01:49,182 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:49,211 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction NaN\n", "toy2_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:51,602 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:51,633 - PyCoMo - INFO - Maximum growth-rate is reaction_id min_flux max_flux\n", "0 toy1_fraction_reaction 0.0 0.0\n", "1 toy2_fraction_reaction 1.0 1.0\n", "2 community_biomass 15.0 15.0\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
reaction_idmin_fluxmax_flux
0toy1_fraction_reaction0.00.0
1toy2_fraction_reaction1.01.0
2community_biomass15.015.0
\n", "
" ], "text/plain": [ " reaction_id min_flux max_flux\n", "0 toy1_fraction_reaction 0.0 0.0\n", "1 toy2_fraction_reaction 1.0 1.0\n", "2 community_biomass 15.0 15.0" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "C.max_growth_rate(return_abundances=True)" ] }, { "cell_type": "markdown", "id": "ca292ce1-73ba-4c76-9408-e7855d8fc925", "metadata": { "tags": [] }, "source": [ "### Minimal abundance\n", "Edge cases exist in which the highest growth rate of a community is not achieved by a combination of all the members. Instead, one member with an abundance of 100% may achieve the maximum growth rate. \n", "\n", "In order to exclude these cases, the parameter ```minimal_abundance``` must be set to a float greater than 0. This sets the minimal abundance of all members to the set float. Take care that the sum of the minimal abundances is not greater than 1, as this will result in an error." ] }, { "cell_type": "code", "execution_count": 6, "id": "5f78e750-989a-4020-993b-436f1cad954e", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:01:51,646 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 2e-06\n", "2025-11-24 16:01:54,179 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:54,210 - PyCoMo - INFO - New round: lb: 10.0, ub: 1000.0, x: 10.000002\n", "2025-11-24 16:01:56,748 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:56,778 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction 0.0\n", "toy2_fraction_reaction 1.0\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:56,779 - PyCoMo - INFO - New round: lb: 10.0, ub: 10.000002, x: 10.000001000000001\n", "2025-11-24 16:01:59,343 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:01:59,373 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "toy1_fraction_reaction 0.0\n", "toy2_fraction_reaction 1.0\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:01:59,373 - PyCoMo - INFO - New round: lb: 10.0, ub: 10.000001000000001, x: 10.0000005\n", "2025-11-24 16:02:01,805 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:01,840 - PyCoMo - INFO - Maximum growth-rate is 10.0\n" ] }, { "data": { "text/plain": [ "np.float64(10.0)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "C.max_growth_rate(minimal_abundance=0.1)" ] }, { "cell_type": "code", "execution_count": 7, "id": "af800adc-ed1a-4db0-aa44-2295b3d5add6", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Error thrown!\n" ] } ], "source": [ "# too large minimal_abundance value leads to an error\n", "try:\n", " C.max_growth_rate(minimal_abundance=0.6)\n", "except ValueError:\n", " print(\"Error thrown!\")\n", " \n", "# The community has two members: \n", "# 2 * 0.6 = 1.2\n", "# 1.2 > 1" ] }, { "cell_type": "markdown", "id": "221ee104-59a2-4510-a6d8-9f3d8b15b8d3", "metadata": {}, "source": [ "## Example: Biogas producing community ##\n", "The example for this part will be a three member community published by Koch et al. 2019 (https://doi.org/10.1371/journal.pcbi.1006759). The three member organisms are representatives of functional guilds in a biogas community." ] }, { "cell_type": "code", "execution_count": 8, "id": "97960ca4-12d8-4ea5-945e-1d080248c86a", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "'3PG' is not a valid SBML 'SId'.\n", "'2PG' is not a valid SBML 'SId'.\n", "'2PG__PEP' is not a valid SBML 'SId'.\n", "'3PG__2PG' is not a valid SBML 'SId'.\n", "'0Pyr__AcCoA' is not a valid SBML 'SId'.\n", "'5CHOMPT' is not a valid SBML 'SId'.\n", "'3PG' is not a valid SBML 'SId'.\n", "'2PG' is not a valid SBML 'SId'.\n", "'2PG__3PG' is not a valid SBML 'SId'.\n", "'3PG__DPG' is not a valid SBML 'SId'.\n", "'5CHOMPT__CHH4MPT' is not a valid SBML 'SId'.\n", "'3PG' is not a valid SBML 'SId'.\n", "'2PG' is not a valid SBML 'SId'.\n", "'5CHOMPT' is not a valid SBML 'SId'.\n", "'3PG__2PG__3PG' is not a valid SBML 'SId'.\n", "'5CHOMPT__CHH4MPT' is not a valid SBML 'SId'.\n", "2025-11-24 16:02:02,176 - PyCoMo - INFO - No community model generated yet. Generating now:\n", "2025-11-24 16:02:02,195 - PyCoMo - INFO - Identified biomass reaction from objective: r_BMDV2BMc\n", "2025-11-24 16:02:02,344 - PyCoMo - INFO - Identified biomass reaction from objective: BM_Synth\n", "2025-11-24 16:02:02,562 - PyCoMo - INFO - Identified biomass reaction from objective: BM_Synth\n", "2025-11-24 16:02:02,785 - PyCoMo - WARNING - No annotation overlap found for matching several metabolites (8). Please make sure that the matched metabolites are indeed representing the same substance in all models! The list of metaboliteswithout annotation overlap can be accessed via 'model.no_annotation_overlap'\n", "2025-11-24 16:02:02,876 - PyCoMo - WARNING - There are 320 metabolites without elements in the model. Mass balance checks may be unreliable.\n", "2025-11-24 16:02:02,878 - PyCoMo - INFO - Generated community model.\n" ] } ], "source": [ "# create cobra models from sbml\n", "dv = cobra.io.read_sbml_model(\"../data/use_case/koch/dv.xml\")\n", "mh = cobra.io.read_sbml_model(\"../data/use_case/koch/mh.xml\")\n", "mb = cobra.io.read_sbml_model(\"../data/use_case/koch/mb.xml\")\n", "\n", "# change infinite upper bounds to 1000\n", "for model in [dv,mh,mb]:\n", " for reaction in model.reactions:\n", " if reaction.upper_bound == math.inf:\n", " reaction.upper_bound = 1000.\n", " if reaction.lower_bound == -math.inf:\n", " reaction.lower_bound = -1000.\n", "\n", "# create Single Organism Models from cobra models\n", "DV = pycomo.SingleOrganismModel(dv, \"dv\")\n", "MH = pycomo.SingleOrganismModel(mh, \"mh\")\n", "MB = pycomo.SingleOrganismModel(mb, \"mb\")\n", "\n", "# create Community Model from Single Organism Models\n", "C2 = pycomo.CommunityModel([DV, MH, MB], name = \"dv_mh_mb_community\")\n", "\n", "# set solver to cplex (if available)\n", "#C2.model.solver = \"cplex\"\n", "\n", "# apply the same medium as in the paper by Koch et al.\n", "medium = {\n", " 'EX_CO2_EX_medium': 1000.0,\n", " 'EX_Eth_EX_medium': 1000.0,\n", " 'EX_BM_tot_medium': 1000.0\n", "}\n", "C2.medium = medium\n", "C2.apply_medium()\n", "\n", "# Formate and Hydrogen are not allowed to accumulate in the medium.\n", "C2.model.reactions.get_by_id(\"EX_Form_EX_medium\").upper_bound = 0.\n", "C2.model.reactions.get_by_id(\"EX_H2_EX_medium\").upper_bound = 0.\n" ] }, { "cell_type": "code", "execution_count": 9, "id": "46812556-3d00-40bb-8fc2-30940ad18269", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:02:02,895 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 2e-06\n", "2025-11-24 16:02:05,505 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:05,587 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 1000.0, x: 0.05213085425733051\n", "2025-11-24 16:02:05,665 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 0.05213085425733051, x: 0.05212985425733051\n", "2025-11-24 16:02:05,707 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 0.05212985425733051, x: 0.05212935425733051\n", "2025-11-24 16:02:08,307 - PyCoMo - WARNING - worker 19340: dv_fraction_reaction min flux is infeasible\n", "2025-11-24 16:02:08,308 - PyCoMo - WARNING - worker 34356: mh_fraction_reaction min flux is infeasible\n", "2025-11-24 16:02:08,309 - PyCoMo - WARNING - worker 19340: dv_fraction_reaction max flux is infeasible\n", "2025-11-24 16:02:08,311 - PyCoMo - WARNING - worker 34356: mh_fraction_reaction max flux is infeasible\n", "2025-11-24 16:02:08,336 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:08,367 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "dv_fraction_reaction NaN\n", "mh_fraction_reaction NaN\n", "mb_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:02:08,404 - PyCoMo - INFO - Maximum growth-rate is 0.052128\n" ] }, { "data": { "text/plain": [ "np.float64(0.052128)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# calculate max growth rate of community\n", "C2.max_growth_rate()" ] }, { "cell_type": "code", "execution_count": 10, "id": "1cd3c036-ebf1-4cf8-b89b-d6803e94aa16", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:02:08,414 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 2e-06\n", "2025-11-24 16:02:11,056 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:11,133 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 1000.0, x: 0.05213085425733051\n", "2025-11-24 16:02:11,210 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 0.05213085425733051, x: 0.05212985425733051\n", "2025-11-24 16:02:11,252 - PyCoMo - INFO - New round: lb: 0.052128854257330506, ub: 0.05212985425733051, x: 0.05212935425733051\n", "2025-11-24 16:02:13,837 - PyCoMo - WARNING - worker 20308: dv_fraction_reaction min flux is infeasible\n", "2025-11-24 16:02:13,838 - PyCoMo - WARNING - worker 29620: mh_fraction_reaction min flux is infeasible\n", "2025-11-24 16:02:13,839 - PyCoMo - WARNING - worker 29620: mh_fraction_reaction max flux is infeasible\n", "2025-11-24 16:02:13,840 - PyCoMo - WARNING - worker 20308: dv_fraction_reaction max flux is infeasible\n", "2025-11-24 16:02:13,865 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:13,896 - PyCoMo - WARNING - Not all upper bounds are bigger than the set minimal abundance:\n", "dv_fraction_reaction NaN\n", "mh_fraction_reaction NaN\n", "mb_fraction_reaction NaN\n", "Name: max_flux, dtype: float64\n", "2025-11-24 16:02:16,504 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:16,537 - PyCoMo - INFO - Maximum growth-rate is reaction_id min_flux max_flux\n", "0 dv_fraction_reaction 0.074553 0.393590\n", "1 mh_fraction_reaction 0.000000 0.681848\n", "2 mb_fraction_reaction 0.000000 0.925447\n", "3 community_biomass 0.052128 0.052128\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
reaction_idmin_fluxmax_flux
0dv_fraction_reaction0.0745530.393590
1mh_fraction_reaction0.0000000.681848
2mb_fraction_reaction0.0000000.925447
3community_biomass0.0521280.052128
\n", "
" ], "text/plain": [ " reaction_id min_flux max_flux\n", "0 dv_fraction_reaction 0.074553 0.393590\n", "1 mh_fraction_reaction 0.000000 0.681848\n", "2 mb_fraction_reaction 0.000000 0.925447\n", "3 community_biomass 0.052128 0.052128" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# calculate abundance profile as well\n", "C2.max_growth_rate(return_abundances=True)" ] }, { "cell_type": "markdown", "id": "529b5bcb-c4e9-46fc-9de5-4fa1c18ed8c8", "metadata": {}, "source": [ "### Sensitivity\n", "\n", "The ```sensitivity``` parameter describes the amount of decimal places that should be calculated. The default is set to 6, as the cplex solver may return inaccurate results at a higher value." ] }, { "cell_type": "code", "execution_count": 11, "id": "46bbb5fe-c38e-4ccf-93f6-21f555fe5f14", "metadata": { "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:02:16,548 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 0.0002\n", "2025-11-24 16:02:19,495 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:19,593 - PyCoMo - INFO - New round: lb: 0.052128854257330624, ub: 1000.0, x: 0.05232885425733062\n", "2025-11-24 16:02:19,684 - PyCoMo - INFO - New round: lb: 0.052128854257330624, ub: 0.05232885425733062, x: 0.05222885425733062\n", "2025-11-24 16:02:19,769 - PyCoMo - INFO - Maximum growth-rate is 0.0521\n" ] }, { "data": { "text/plain": [ "np.float64(0.0521)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# sensitivity = 4\n", "C2.max_growth_rate(sensitivity=4)" ] }, { "cell_type": "code", "execution_count": 12, "id": "7205745a-76dc-4566-b005-bc8f6b70defb", "metadata": { "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-24 16:02:19,777 - PyCoMo - INFO - New round: lb: 0.0, ub: 1000.0, x: 0.02\n", "2025-11-24 16:02:22,398 - PyCoMo - INFO - Processed 100.0% of fva steps\n", "2025-11-24 16:02:22,471 - PyCoMo - INFO - New round: lb: 0.05212885425733061, ub: 1000.0, x: 0.07212885425733061\n", "2025-11-24 16:02:22,552 - PyCoMo - INFO - New round: lb: 0.05212885425733061, ub: 0.07212885425733061, x: 0.06212885425733061\n", "2025-11-24 16:02:22,593 - PyCoMo - INFO - New round: lb: 0.05212885425733061, ub: 0.06212885425733061, x: 0.05712885425733061\n", "2025-11-24 16:02:22,669 - PyCoMo - INFO - Maximum growth-rate is 0.05\n" ] }, { "data": { "text/plain": [ "np.float64(0.05)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# sensitivity = 2\n", "C2.max_growth_rate(sensitivity=2)" ] }, { "cell_type": "code", "execution_count": null, "id": "3e41355c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.11.11" } }, "nbformat": 4, "nbformat_minor": 5 }