Skip to content

Commit

Permalink
Removed class model - user now only interacts with cobra models v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djbajic committed Mar 13, 2019
1 parent 0b7858a commit d47ca85
Show file tree
Hide file tree
Showing 17 changed files with 173,482 additions and 292 deletions.
1,138 changes: 1,138 additions & 0 deletions .ipynb_checkpoints/colony-checkpoint.ipynb

Large diffs are not rendered by default.

659 changes: 659 additions & 0 deletions .ipynb_checkpoints/evolution-checkpoint.ipynb

Large diffs are not rendered by default.

753 changes: 753 additions & 0 deletions .ipynb_checkpoints/model_testing-checkpoint.ipynb

Large diffs are not rendered by default.

366 changes: 366 additions & 0 deletions .ipynb_checkpoints/serial_transfers-checkpoint.ipynb

Large diffs are not rendered by default.

1,112 changes: 1,112 additions & 0 deletions backup/comets (copy).py

Large diffs are not rendered by default.

File renamed without changes.
887 changes: 887 additions & 0 deletions backup/comets_BACKUP.py

Large diffs are not rendered by default.

366 changes: 366 additions & 0 deletions batch.ipynb

Large diffs are not rendered by default.

196 changes: 196 additions & 0 deletions colony.ipynb
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
}
Loading

0 comments on commit d47ca85

Please sign in to comment.