Skip to content

Commit

Permalink
Merge pull request #6 from ROBACON/documentation
Browse files Browse the repository at this point in the history
Merged documentation made by Rémi
  • Loading branch information
fabriciocravo authored Jan 28, 2024
2 parents d9b10f5 + 5706358 commit 49be0bb
Show file tree
Hide file tree
Showing 273 changed files with 32,566 additions and 2 deletions.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
581 changes: 581 additions & 0 deletions docs/Notebooks/01_Basic_Intro.ipynb

Large diffs are not rendered by default.

245 changes: 245 additions & 0 deletions docs/Notebooks/02_Reaction_Inheritance.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8718382c-245b-472d-9346-560baf8ea4c9",
"metadata": {},
"source": [
"# Reaction Inheritance\n",
"\n",
"MobsPy allows Meta-Species to inherit reactions from other Meta-Species\n",
"\n",
"We start by defining the BaseSpecies we will use:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "115322c4-e3a8-4a0b-9d38-8d0d26c4c79b",
"metadata": {},
"outputs": [],
"source": [
"from mobspy import *\n",
"\n",
"Duplicator, Mortal, Eater, Food = BaseSpecies(4)"
]
},
{
"cell_type": "markdown",
"id": "bd283d31-7e59-4f4c-84e4-bb379fcbcb6a",
"metadata": {},
"source": [
"Next, we define the reactions for each of the BaseSpecies.\n",
"Zero is a meta-species that represents no species."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f9687e7a-abc5-4fde-a61c-aa8b6a2e8181",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<mobspy.modules.meta_class.Reactions at 0x7f9405c6fa30>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Duplicator >> 2*Duplicator [1]\n",
"Eater + Food >> Eater [1]\n",
"Mortal >> Zero [1]"
]
},
{
"cell_type": "markdown",
"id": "857582f8-7b9c-4ae2-b7e8-ef4c83f3af0a",
"metadata": {},
"source": [
"In MobsPy, the multiplication of meta-species allows for the inheritance of reactions from the factor species.\n",
"For example, we would like to define a Bacteria species that is also a Duplicator, an Eater, and a Mortal. This is done via:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "43d91f12-5c95-4789-b10d-ef88c0d02f74",
"metadata": {},
"outputs": [],
"source": [
"Bacteria = Duplicator*Eater*Mortal"
]
},
{
"cell_type": "markdown",
"id": "2da3dcdc-c434-457a-8c26-3d664c9969cc",
"metadata": {},
"source": [
"We now create new different types of bacteria from the previous ones, Ecoli and Strepto. As they will also be Bacteria, they inherit all the reactions. We can do this using the New call. "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2fc1888a-bbd9-431f-95fd-34b62f4865dd",
"metadata": {},
"outputs": [],
"source": [
"Ecoli, Strepto = New(Bacteria, 2)"
]
},
{
"cell_type": "markdown",
"id": "d4ac10e7-ccbf-4d3c-b02a-1966af2fed5d",
"metadata": {},
"source": [
"We also define two types of Food:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "30df3ac6-f019-43f0-87ae-c50beab9b0da",
"metadata": {},
"outputs": [],
"source": [
"Glucose, Amino = New(Food, 2)"
]
},
{
"cell_type": "markdown",
"id": "4d291352-6fee-4d98-9c39-b469df6d3042",
"metadata": {},
"source": [
"MobsPy will create all possible combinations for inheritance when defining the model, which means that both Ecoli and Strepto will eat Glucose and Amino.\n",
"\n",
"Finally, we define the species we want to simulate.\n",
"Since Duplicator, Eater, Mortal, and Food were just defined to construct the other meta-species, we don't pass them to Simulation."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "5f0c9765-b7d0-4e26-98ed-8660fcd74f26",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(<mobspy.modules.meta_class.Species at 0x7f94003403d0>,\n",
" <mobspy.modules.meta_class.Species at 0x7f94003401f0>,\n",
" <mobspy.modules.meta_class.Species at 0x7f9400340370>,\n",
" <mobspy.modules.meta_class.Species at 0x7f9400340550>)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"S = Simulation(Ecoli | Strepto | Glucose | Amino)\n",
"\n",
"# Adding some counts\n",
"Ecoli(50), Strepto(25), Glucose(10), Amino(100)"
]
},
{
"cell_type": "markdown",
"id": "2709519d-a951-4995-a3a3-d048f2b4a6c8",
"metadata": {},
"source": [
"Now we compile the simulation to show all defined reactions:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "98b7da18-0d3e-4e75-8e27-893e99c91a5f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Species\n",
"Amino,100\n",
"Ecoli,50\n",
"Glucose,10\n",
"Strepto,25\n",
"\n",
"Mappings\n",
"Amino :\n",
"Amino\n",
"Ecoli :\n",
"Ecoli\n",
"Glucose :\n",
"Glucose\n",
"Strepto :\n",
"Strepto\n",
"\n",
"Parameters\n",
"volume,1\n",
"\n",
"Reactions\n",
"reaction_0,{'re': [(1, 'Ecoli'), (1, 'Amino')], 'pr': [(1, 'Ecoli')], 'kin': 'Ecoli * Amino * 1 * volume^-1'}\n",
"reaction_1,{'re': [(1, 'Ecoli'), (1, 'Glucose')], 'pr': [(1, 'Ecoli')], 'kin': 'Ecoli * Glucose * 1 * volume^-1'}\n",
"reaction_2,{'re': [(1, 'Ecoli')], 'pr': [(2, 'Ecoli')], 'kin': 'Ecoli * 1'}\n",
"reaction_3,{'re': [(1, 'Ecoli')], 'pr': [], 'kin': 'Ecoli * 1'}\n",
"reaction_4,{'re': [(1, 'Strepto'), (1, 'Amino')], 'pr': [(1, 'Strepto')], 'kin': 'Strepto * Amino * 1 * volume^-1'}\n",
"reaction_5,{'re': [(1, 'Strepto'), (1, 'Glucose')], 'pr': [(1, 'Strepto')], 'kin': 'Strepto * Glucose * 1 * volume^-1'}\n",
"reaction_6,{'re': [(1, 'Strepto')], 'pr': [(2, 'Strepto')], 'kin': 'Strepto * 1'}\n",
"reaction_7,{'re': [(1, 'Strepto')], 'pr': [], 'kin': 'Strepto * 1'}\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Compiling model\n",
"\u001b[91mWARNING: Automatic data-saving setup failed. Please save manually\u001b[0m\n"
]
}
],
"source": [
"print(S.compile())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "24452c56-6dd9-47d8-98f7-df00cb895273",
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 49be0bb

Please sign in to comment.