-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed class model - user now only interacts with cobra models v0.2.0
- Loading branch information
Showing
17 changed files
with
173,482 additions
and
292 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Simulating the growth of a colony\n", | ||
"\n", | ||
"We demonstrate here a simple `COMETS` simulation with space, the growth of an *E. coli* colony using a 2D spatial lattice." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import comets as c\n", | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"pd.options.display.max_rows = 10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As usual, we first create a parameters object using the `params` class." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"my_params = c.params()\n", | ||
"my_params.all_params['maxCycles'] = 300\n", | ||
"my_params.all_params['writeBiomassLog'] = True" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We next load a layout for our simulation " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Academic license - for non-commercial use only\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[[10.0, 10.0, 1e-07]]" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"my_layout = c.layout('test_colony/colony_layout')\n", | ||
"my_layout.initial_pop" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\n", | ||
"Running COMETS simulation ...\n", | ||
"Done!\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# create comets object from the loaded parameters and layout \n", | ||
"my_comets = c.comets(my_layout, my_params)\n", | ||
"\n", | ||
"# run comets simulation\n", | ||
"my_comets.run()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can print the stderr and stdout, which are stored in the `run_errors` and `run_output` fields:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"STDERR empty.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(my_comets.run_errors)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"And here is how our incipient *E. coli* colony looks like: " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"\n", | ||
"biomass_END = np.zeros((my_layout.grid[0], my_layout.grid[1]))\n", | ||
"\n", | ||
"aux = my_comets.biomass.loc[my_comets.biomass['Cycle'] == 300]\n", | ||
"for index, row in aux.iterrows():\n", | ||
" biomass_END[row['x'], row['y']] = row['biomass']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<matplotlib.image.AxesImage at 0x7f201a255518>" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"import matplotlib.cm, matplotlib.colors\n", | ||
"import copy\n", | ||
"\n", | ||
"my_cmap = copy.copy(matplotlib.cm.get_cmap('PuBu')) # copy the default cmap\n", | ||
"my_cmap.set_bad((0,0,0))\n", | ||
"\n", | ||
"plt.imshow(biomass_END, interpolation='nearest', \n", | ||
" norm=matplotlib.colors.LogNorm(), cmap=my_cmap)" | ||
] | ||
} | ||
], | ||
"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.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.