Team:Bordeaux/SourceCodeModelling

From 2012.igem.org

(Difference between revisions)
Line 122: Line 122:
<hr>
<hr>
</br>
</br>
-
<pre class="prettyprint ">
+
<pre class="prettyprint lang-py">
#!/usr/bin/python
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
# -*- coding: iso-8859-1 -*-
Line 148: Line 148:
def features_bacteria ():
def features_bacteria ():
-
r"""
+
r'''
Function attribute all features at the bacteria
Function attribute all features at the bacteria
-
"""
+
'''
#Coordinates
#Coordinates
x=random.uniform(0,10) # position x of the bacteria on the petri dish  
x=random.uniform(0,10) # position x of the bacteria on the petri dish  
Line 258: Line 258:
def active_state():
def active_state():
-
r"""
+
r'''
Function permit to active the state of the bacteria according the activation of these genes
Function permit to active the state of the bacteria according the activation of these genes
-
"""
+
'''
for j in range (0,len(list_bacteria)):
for j in range (0,len(list_bacteria)):
#State 1
#State 1
Line 281: Line 281:
def change_state():
def change_state():
-
r"""
+
r'''
Function permit to the bacteria changing state
Function permit to the bacteria changing state
-
"""
+
'''
for j in range (0,len(list_bacteria)):
for j in range (0,len(list_bacteria)):
# State 1 --> State 2
# State 1 --> State 2
Line 292: Line 292:
list_bacteria[j][9] =1
list_bacteria[j][9] =1
list_bacteria[j][10] =1
list_bacteria[j][10] =1
-
 
-
def stimulus_light():
 
-
r"""
 
-
Function create the first stimulation light
 
-
"""
 
-
for j in range (0,len(list_bacteria)):
 
-
proba_recepteur=random.uniform(0,1)
 
-
if ((list_bacteria[j][0]-5)*(list_bacteria[j][0]-5))+((list_bacteria[j][1]-5)*(list_bacteria[j][1]-5))<=diameter_light and list_bacteria[j][5]!=0  and list_bacteria[j][6]!=0  and list_bacteria[j][7]!=0:
 
-
proba=random.uniform(0,1)
 
-
if proba<=seuil_transfo_lumiere:
 
-
list_bacteria[j][5]=1
 
-
list_bacteria[j][6]=1
 
-
list_bacteria[j][7]=1
 
-
 
def noise(noise_pourcent):
def noise(noise_pourcent):
-
r"""
+
r'''
-
Create a noise before the first stimulation light. Take one argument :  
+
Create a noise before the first stimulation light. Take one argument : noise_pourcent = the noise that we want
-
        noise_pourcent = the noise that we want
+
'''
-
"""
+
for j in range (0,len(list_bacteria)):
for j in range (0,len(list_bacteria)):
proba=random.uniform(0,1)
proba=random.uniform(0,1)
Line 328: Line 313:
list_bacteria[j][12]=1
list_bacteria[j][12]=1
list_bacteria[j][13]=1
list_bacteria[j][13]=1
 +
 +
 +
def stimulus_light():
 +
r'''
 +
Function create the first stimulation light
 +
'''
 +
for j in range (0,len(list_bacteria)):
 +
proba_recepteur=random.uniform(0,1)
 +
if ((list_bacteria[j][0]-5)*(list_bacteria[j][0]-5))+((list_bacteria[j][1]-5)*(list_bacteria[j][1]-5))<=diameter_light and list_bacteria[j][5]!=0  and list_bacteria[j][6]!=0  and list_bacteria[j][7]!=0:
 +
proba=random.uniform(0,1)
 +
if proba<=seuil_transfo_lumiere:
 +
list_bacteria[j][5]=1
 +
list_bacteria[j][6]=1
 +
list_bacteria[j][7]=1
 +
 +
def stimulus_factor(x,rayon_action):
def stimulus_factor(x,rayon_action):
-
r"""
+
r'''
Function create others stimulations
Function create others stimulations
-
"""
+
'''
change_state()
change_state()
Line 452: Line 453:
print "Production de GFP=",(float(cpt12)/float(len(list_bacteria)))*100,"%"
print "Production de GFP=",(float(cpt12)/float(len(list_bacteria)))*100,"%"
print "Recepteur à AHL=",(float(cpt14)/float(len(list_bacteria)))*100,"%","\n","\n"
print "Recepteur à AHL=",(float(cpt14)/float(len(list_bacteria)))*100,"%","\n","\n"
 +
 +
 +
 +
 +
def color():
def color():
-
r"""
+
r'''
Color function to attribute a color for the bacteria according this state
Color function to attribute a color for the bacteria according this state
-
"""
+
'''
for j in range (0,len(list_bacteria)):
for j in range (0,len(list_bacteria)):
#Bacteria with no state
#Bacteria with no state
Line 484: Line 490:
def do_plot(name,titre):
def do_plot(name,titre):
-
r"""
+
r'''
Create a plot figure. Take 2 arguments : Name = name of picture and Title = title of plot
Create a plot figure. Take 2 arguments : Name = name of picture and Title = title of plot
-
"""
+
'''
color()
color()
plot(lxw,lyw,"wo",ms=5,linewidth=0)
plot(lxw,lyw,"wo",ms=5,linewidth=0)
Line 534: Line 540:
do_plot("7","tours5")
do_plot("7","tours5")
-
os.system("python create_gif.py")
+
#os.system("python create_gif.py")
 +
 
 +
 

Revision as of 08:24, 24 September 2012

Modelling - iGEM Bordeaux 2012

iGEM - Bordeaux - Source Code

Init_PEB.py file



r"""
File contains var
"""

__projet__ = 'iGEM '
__author__ = 'Djemiel Christophe, Freche Arnaud'
__copyright__ = 'Copyright (c) 2012 BordeauxTeam'
__license__ = ''
__vcs_id__ = '$Id$'
__version__ = '1.0'

#var 
directory_pictures="pictures_simulation/"

#initial parameters 
nb_bacteria=8000

#features constitutive
seuil_acivation_recepteur1=0.75
seuil_acivation_recepteur2=0.75
seuil_acivation_recepteur3=0.75

#mutation
seuil_mutation_operon=0.05
seuil_mutation_LasR=0.05
seuil_mutation_LuxS=0.05
seuil_mutation_BetaGal=0.05
seuil_mutation_LuxBox=0.05
seuil_mutation_LuxI=0.05
seuil_mutation_MCherry=0.05
seuil_mutation_QBox=0.05
seuil_mutation_LasI=0.05

#change state
seuil_etat1_2=0.05

#noise
noise_pourcent=0.0001
seuil_bruit1=0.33
seuil_bruit2=0.66

#stimulus light
seuil_transfo_lumiere=0.7
diameter_light=1

rayon_action=0.075


 

PEP.py file



#!/usr/bin/python
# -*- coding: iso-8859-1 -*-


import random
from pylab import *
from numpy import *
from init_PEB import *
import os 


list_bacteria = []
lxw=[]
lyw=[]
lxb=[]
lyb=[]
lxr=[]
lyr=[]
lxg=[]
lyg=[]
lxn=[]
lyn=[]


def features_bacteria ():
	r'''
	Function attribute all features at the bacteria
	'''
	#Coordinates
	x=random.uniform(0,10) # position x of the bacteria on the petri dish 
	List[0]=x
	y=random.uniform(0,10) # position x of the bacteria on the petri dish 
	List[1]=y
	
	#States
	state1=None 
	List[2]=state1
	state2=None 
	List[3]=state2
	state3=None 
	List[4]=state3
	
	#Operon 1
	LasR_box=None
	List[5]=LasR_box
	LuxS=None
	List[6]=LuxS
	Beta_gal=None
	List[7]=Beta_gal
	
	#Operon 2
	Lux_box=None
	List[8]=Lux_box
	LuxI=None
	List[9]=LuxI
	m_cherry=None
	List[10]=m_cherry
	
	#Operon 3
	Q_box=None
	List[11]=Q_box
	LasI=None
	List[12]=LasI
	GFP=None
	List[13]=GFP
	
	#Operon constitutive
	recepteur1=None
	List[14]=recepteur1
	recepteur2=None
	List[15]=recepteur2
	recepteur3=None
	List[16]=recepteur3

	return List


	
def feature_constitutive():

	for j in range (0,len(list_bacteria)):
		proba_active_14=random.uniform(0,1)
		proba_active_15=random.uniform(0,1)
		proba_active_16=random.uniform(0,1)
		
		if proba_active_14<=seuil_acivation_recepteur1:
			list_bacteria[j][14]=1
		else:
			list_bacteria[j][14]=0
			
		if proba_active_15<=seuil_acivation_recepteur2:
			list_bacteria[j][15]=1
		else:
			list_bacteria[j][15]=0
			
		if proba_active_16<=seuil_acivation_recepteur3:
			list_bacteria[j][16]=1
		else:
			list_bacteria[j][16]=0

def mutation():

	for j in range (0,len(list_bacteria)):
		proba_mutation=random.uniform(0.1)
		if proba_mutation<=0.05:
			proba_mutation_LasR=random.uniform(0.1)
			proba_mutation_LuxS=random.uniform(0.1)
			proba_mutation_BetaGal=random.uniform(0.1)
			proba_mutation_LuxBox=random.uniform(0.1)
			proba_mutation_LuxI=random.uniform(0.1)
			proba_mutation_MCherry=random.uniform(0.1)
			proba_mutation_QBox=random.uniform(0.1)
			proba_mutation_LasI=random.uniform(0.1)
			proba_mutation_GFP=random.uniform(0.1)
			if proba_mutation_LasR<=seuil_mutation_LasR:
				list_bacteria[j][5]=0
			if proba_mutation_LuxS<=seuil_mutation_LuxS:
				list_bacteria[j][6]=0
			if proba_mutation_BetaGal<=seuil_mutation_BetaGal:
				list_bacteria[j][7]=0
			if proba_mutation_LuxBox<=seuil_mutation_LuxBox:
				list_bacteria[j][8]=0
			if proba_mutation_LuxI<=seuil_mutation_LuxI:
				list_bacteria[j][9]=0
			if proba_mutation_MCherry<=seuil_mutation_MCherry:
				list_bacteria[j][10]=0
			if proba_mutation_QBox<=seuil_mutation_QBox:
				list_bacteria[j][11]=0
			if proba_mutation_LasI<=seuil_mutation_LasI:
				list_bacteria[j][12]=0
			if proba_mutation_GFP<=seuil_mutation_GFP:
				list_bacteria[j][13]=0
			

def active_state():
	r'''
	Function permit to active the state of the bacteria according the activation of these genes
	'''
	for j in range (0,len(list_bacteria)):
		#State 1
		if list_bacteria[j][5]==1 and list_bacteria[j][6]==1 and list_bacteria[j][7]==1:
				list_bacteria[j][2]=1
				list_bacteria[j][3]=0
				list_bacteria[j][4]=0
		
		#State 2
		if list_bacteria[j][8]==1 and list_bacteria[j][9]==1 and list_bacteria[j][10]==1:
				list_bacteria[j][2]=0
				list_bacteria[j][3]=1
				list_bacteria[j][4]=0
		
		#State 3	
		if list_bacteria[j][11]==1 and list_bacteria[j][12]==1 and list_bacteria[j][13]==1:
				list_bacteria[j][2]=0
				list_bacteria[j][3]=0
				list_bacteria[j][4]=1

def change_state():
	r'''
	Function permit to the bacteria changing state
	'''
	for j in range (0,len(list_bacteria)):
		# State 1 --> State 2
		if  list_bacteria[j][2]==1 and list_bacteria[j][5]==1 and list_bacteria[j][6]==1 and list_bacteria[j][14]==1:
			proba=random.uniform(0,1)
			if proba<=seuil_etat1_2:
				list_bacteria[j][8] =1
				list_bacteria[j][9] =1
				list_bacteria[j][10] =1
				
def noise(noise_pourcent):
	r'''
	Create a noise before the first stimulation light. Take one argument : noise_pourcent = the noise that we want
	'''
	for j in range (0,len(list_bacteria)):
		proba=random.uniform(0,1)
		if proba<=noise_pourcent:
			proba2=random.uniform(0,1)
			if 0<=proba2