|
|
(13 intermediate revisions not shown) |
Line 64: |
Line 64: |
| <h4>Init_PEB.py file</h4> | | <h4>Init_PEB.py file</h4> |
| <hr> | | <hr> |
| + | </br> |
| + | <li><a href="http://cdjemiel.free.fr/igem2012/code/init_PEB.py" title="Mst" target="_blank">Download file PEP.py</a></li> |
| </br> | | </br> |
| | | |
Line 99: |
Line 101: |
| seuil_mutation_QBox=0.05 | | seuil_mutation_QBox=0.05 |
| seuil_mutation_LasI=0.05 | | seuil_mutation_LasI=0.05 |
| + | seuil_mutation_GFP=0.05 |
| | | |
| #change state | | #change state |
Line 119: |
Line 122: |
| | | |
| <p> | | <p> |
- | <h4>PEP.py file</h4> | + | <h4>PEB.py file (Main program)</h4> |
| <hr> | | <hr> |
| </br> | | </br> |
- | <pre class="prettyprint lang-py"> | + | <li><a href="http://cdjemiel.free.fr/igem2012/code/PEB.py" title="Mst" target="_blank">Download file PEB.py</a></li> |
- | #!/usr/bin/python
| + | </p> |
- | # -*- coding: iso-8859-1 -*-
| + | |
| | | |
- | | + | <p> |
- | import random
| + | <h4>Create a gif </h4> |
- | from pylab import *
| + | <hr> |
- | from numpy import *
| + | </br> |
- | from init_PEB import *
| + | <li><a href="http://cdjemiel.free.fr/igem2012/code/create_gif.py" title="Mst" target="_blank">Download file create_gif.py</a></li> |
- | import os
| + | <li><a href="http://cdjemiel.free.fr/igem2012/code/images2gif.py" title="Mst" target="_blank">Download file images2gif.py</a></li> |
- | | + | </br> |
- | | + | Reference : <a href="http://www.somethinkodd.com/oddthinking/2005/12/06/python-imaging-library-pil-and-animated-gifs/" target="_blank">Python Imaging Library (PIL) and Animated GIFs</a> |
- | 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<seuil_bruit1:
| + | |
- | list_bacteria[j][5]=1
| + | |
- | list_bacteria[j][6]=1
| + | |
- | list_bacteria[j][7]=1
| + | |
- | if seuil_bruit1<=proba2<seuil_bruit2:
| + | |
- | list_bacteria[j][8]=1
| + | |
- | list_bacteria[j][9]=1
| + | |
- | list_bacteria[j][10]=1
| + | |
- | if seuil_bruit2<=proba2<1:
| + | |
- | list_bacteria[j][11]=1
| + | |
- | list_bacteria[j][12]=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):
| + | |
- | r"""
| + | |
- | Function create others stimulations
| + | |
- | """
| + | |
- |
| + | |
- | change_state()
| + | |
- | active_state()
| + | |
- | for j in range (0,len(list_bacteria)):
| + | |
- | #stimulus facteur1
| + | |
- | if list_bacteria[j][2] ==None and list_bacteria[j][3]==None and list_bacteria[j][4]==None and list_bacteria[j][14]==1 and list_bacteria[j][8]!=0 and list_bacteria[j][9]!=0 and list_bacteria[j][10]!=0:
| + | |
- | for i in range (0,len(list_bacteria)):
| + | |
- | if ((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))<=rayon_action and list_bacteria[i][2]==1 and list_bacteria[i][6]==1 :
| + | |
- | distance_voisin=((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))
| + | |
- | proba=random.uniform(0,1)
| + | |
- | if proba*distance_voisin<=x:
| + | |
- | list_bacteria[j][8] =1
| + | |
- | list_bacteria[j][9] =1
| + | |
- | list_bacteria[j][10] =1
| + | |
- | change_state()
| + | |
- | active_state()
| + | |
- |
| + | |
- | for j in range (0,len(list_bacteria)):
| + | |
- | #stimulus facteur2
| + | |
- | if list_bacteria[j][2] ==None and list_bacteria[j][3]==None and list_bacteria[j][4]==None and list_bacteria[j][15]==1 and list_bacteria[j][11]!=0 and list_bacteria[j][12]!=0 and list_bacteria[j][13]!=0:
| + | |
- | for i in range (0,len(list_bacteria)):
| + | |
- | if ((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))<=rayon_action and list_bacteria[i][3]==1 and list_bacteria[i][9]==1 :
| + | |
- | distance_voisin=((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))
| + | |
- | proba=random.uniform(0,1)
| + | |
- | if proba*distance_voisin<=x:
| + | |
- | list_bacteria[j][11] =1
| + | |
- | list_bacteria[j][12] =1
| + | |
- | list_bacteria[j][13] =1
| + | |
- | change_state()
| + | |
- | active_state()
| + | |
- |
| + | |
- | for j in range (0,len(list_bacteria)):
| + | |
- | #stimulus facteur2
| + | |
- | if list_bacteria[j][2] ==None and list_bacteria[j][3]==None and list_bacteria[j][4]==None and list_bacteria[j][16]==1 and list_bacteria[j][5]!=0 and list_bacteria[j][6]!=0 and list_bacteria[j][7]!=0:
| + | |
- | for i in range (0,len(list_bacteria)):
| + | |
- | if ((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))<=rayon_action and list_bacteria[i][4]==1and list_bacteria[i][12]==1 :
| + | |
- | distance_voisin=((list_bacteria[j][0]-list_bacteria[i][0])*(list_bacteria[j][0]-list_bacteria[i][0]))+((list_bacteria[j][1]-list_bacteria[i][1])*(list_bacteria[j][1]-list_bacteria[i][1]))
| + | |
- | proba=random.uniform(0,1)
| + | |
- | if proba*distance_voisin<=x:
| + | |
- | list_bacteria[j][5] =1
| + | |
- | list_bacteria[j][6] =1
| + | |
- | list_bacteria[j][7] =1
| + | |
- | change_state()
| + | |
- | active_state()
| + | |
- | | + | |
- | | + | |
- | def statistic():
| + | |
- | cpt1=0
| + | |
- | cpt2=0
| + | |
- | cpt3=0
| + | |
- | cpt4=0
| + | |
- | cpt5=0
| + | |
- | cpt6=0
| + | |
- | cpt7=0
| + | |
- | cpt8=0
| + | |
- | cpt9=0
| + | |
- | cpt10=0
| + | |
- | cpt11=0
| + | |
- | cpt12=0
| + | |
- | cpt13=0
| + | |
- | cpt14=0
| + | |
- | cpt15=0
| + | |
- | cpt16=0
| + | |
- | for j in range (0,len(list_bacteria)):
| + | |
- | if list_bacteria[j][2]==1:
| + | |
- | cpt1=cpt1+1
| + | |
- | if list_bacteria[j][3]==1:
| + | |
- | cpt2=cpt2+1
| + | |
- | if list_bacteria[j][4]==1:
| + | |
- | cpt3=cpt3+1
| + | |
- | if list_bacteria[j][5]==1:
| + | |
- | cpt4=cpt4+1
| + | |
- | if list_bacteria[j][6]==1:
| + | |
- | cpt5=cpt5+1
| + | |
- | if list_bacteria[j][7]==1 and list_bacteria[j][2]==1:
| + | |
- | cpt6=cpt6+1
| + | |
- | if list_bacteria[j][8]==1:
| + | |
- | cpt7=cpt7+1
| + | |
- | if list_bacteria[j][9]==1:
| + | |
- | cpt8=cpt8+1
| + | |
- | if list_bacteria[j][10]==1 and list_bacteria[j][3]==1:
| + | |
- | cpt9=cpt9+1
| + | |
- | if list_bacteria[j][11]==1:
| + | |
- | cpt10=cpt10+1
| + | |
- | if list_bacteria[j][12]==1:
| + | |
- | cpt11=cpt11+1
| + | |
- | if list_bacteria[j][13]==1 and list_bacteria[j][4]==1:
| + | |
- | cpt12=cpt12+1
| + | |
- | if list_bacteria[j][14]==1:
| + | |
- | cpt13=cpt13+1
| + | |
- | if list_bacteria[j][15]==1:
| + | |
- | cpt14=cpt14+1
| + | |
- | if list_bacteria[j][16]==1:
| + | |
- | cpt15=cpt15+1
| + | |
- | if list_bacteria[j][5]==1 and list_bacteria[j][7]==1 and list_bacteria[j][8]==1 and list_bacteria[j][10]==1:
| + | |
- | cpt16=cpt16+1
| + | |
- | print "\n","\n"
| + | |
- | print "OPERON A:"
| + | |
- | print "etat1=",(float(cpt1)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "etat1 et etat2 à la fois=",(float(cpt16)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Las R actif=",(float(cpt4)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Production de Borat =",(float(cpt5)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Production BetaGal=",(float(cpt6)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Recepteur à PAI-1 actif=",(float(cpt15)/float(len(list_bacteria)))*100,"%","\n","\n"
| + | |
- |
| + | |
- | print "OPERON B:"
| + | |
- | print "etat2=",(float(cpt2)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Lux Box fonctionnelle=",(float(cpt7)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Production de AHL=",(float(cpt8)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Production de M-Cherry=",(float(cpt9)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Recepteur à Borat actif=",(float(cpt13)/float(len(list_bacteria)))*100,"%","\n","\n"
| + | |
- | | + | |
- |
| + | |
- | print "OPERON C:"
| + | |
- | print "etat3=",(float(cpt3)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Q Box fonctionnelle=",(float(cpt10)/float(len(list_bacteria)))*100,"%"
| + | |
- | print "Production de PAI-1=",(float(cpt11)/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"
| + | |
- | | + | |
- | def color():
| + | |
- | r"""
| + | |
- | Color function to attribute a color for the bacteria according this state
| + | |
- | """
| + | |
- | for j in range (0,len(list_bacteria)):
| + | |
- | #Bacteria with no state
| + | |
- | if list_bacteria[j][2]==0 or list_bacteria[j][2]==None or list_bacteria[j][3]==None or list_bacteria[j][4]==None: #white
| + | |
- | lxw.append(list_bacteria[j][0])
| + | |
- | lyw.append(list_bacteria[j][1])
| + | |
- |
| + | |
- | #Bacteria with State 1
| + | |
- | if list_bacteria[j][5]==1 and list_bacteria[j][7]==1: #blue
| + | |
- | lxb.append(list_bacteria[j][0])
| + | |
- | lyb.append(list_bacteria[j][1])
| + | |
- |
| + | |
- | #Bacteria with State 2
| + | |
- | if list_bacteria[j][8]==1 and list_bacteria[j][10]==1: #red
| + | |
- | lxr.append(list_bacteria[j][0])
| + | |
- | lyr.append(list_bacteria[j][1])
| + | |
- |
| + | |
- | #Bacteria with State 3
| + | |
- | if list_bacteria[j][11]==1 and list_bacteria[j][13]==1: #green
| + | |
- | lxg.append(list_bacteria[j][0])
| + | |
- | lyg.append(list_bacteria[j][1])
| + | |
- |
| + | |
- | #Bacteria with State 1 and State 2
| + | |
- | if list_bacteria[j][5]==1 and list_bacteria[j][7]==1 and list_bacteria[j][8]==1 and list_bacteria[j][10]==1: #black
| + | |
- | lxn.append(list_bacteria[j][0])
| + | |
- | lyn.append(list_bacteria[j][1])
| + | |
- |
| + | |
- | def do_plot(name,titre):
| + | |
- | r"""
| + | |
- | Create a plot figure. Take 2 arguments : Name = name of picture and Title = title of plot
| + | |
- | """
| + | |
- | color()
| + | |
- | plot(lxw,lyw,"wo",ms=5,linewidth=0)
| + | |
- | plot(lxr,lyr,"ro",ms=5,linewidth=0)
| + | |
- | plot(lxb,lyb,"bo",ms=5,linewidth=0)
| + | |
- | plot(lxg,lyg,"go",ms=5,linewidth=0)
| + | |
- | plot(lxn,lyn,"ko",ms=5,linewidth=0)
| + | |
- | axis((0,10,0,10))
| + | |
- | title(titre)
| + | |
- | savefig('fig'+name+'.png')
| + | |
- | | + | |
- | | + | |
- | | + | |
- | ################################################################
| + | |
- | ########################### MAIN ###############################
| + | |
- | ################################################################
| + | |
- | | + | |
- | for i in range (nb_bacteria):
| + | |
- | List = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
| + | |
- | features_bacteria()
| + | |
- | list_bacteria.append(List)
| + | |
- | | + | |
- | feature_constitutive()
| + | |
- | do_plot("0","temps0")
| + | |
- | mutation()
| + | |
- | noise(noise_pourcent)
| + | |
- | active_state()
| + | |
- | do_plot("1","bruit")
| + | |
- | stimulus_light()
| + | |
- | active_state()
| + | |
- | do_plot("2","light")
| + | |
- | stimulus_factor(0.05,rayon_action)
| + | |
- | mutation()
| + | |
- | do_plot("3","tours1")
| + | |
- | stimulus_factor(0.10,rayon_action)
| + | |
- | mutation()
| + | |
- | do_plot("4","tours2")
| + | |
- | stimulus_factor(0.15,rayon_action)
| + | |
- | mutation()
| + | |
- | do_plot("5","tours3")
| + | |
- | stimulus_factor(0.20,rayon_action)
| + | |
- | mutation()
| + | |
- | do_plot("6","tours4")
| + | |
- | statistic()
| + | |
- | stimulus_factor(0.25,rayon_action)
| + | |
- | mutation()
| + | |
- | do_plot("7","tours5")
| + | |
- | | + | |
- | os.system("python create_gif.py")
| + | |
- | | + | |
- | | + | |
- | | + | |
- | </pre>
| + | |
| </p> | | </p> |
| </div> | | </div> |