Skip to content
Snippets Groups Projects
Commit f245c2af authored by Gauthier Roy's avatar Gauthier Roy
Browse files

Merge branch 'master' of...

parents effcbbad 1ebb6d88
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -31,7 +31,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): ...@@ -31,7 +31,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
if individu.score>max: if individu.score>max:
best=individu best=individu
max=individu.score max=individu.score
afficher(People) # afficher(People)
L.append(max) L.append(max)
#print(L) #print(L)
plt.plot([i for i in range(tmax)], L) plt.plot([i for i in range(tmax)], L)
...@@ -39,7 +39,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): ...@@ -39,7 +39,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
return(best) return(best)
main(10,50,0,5) main(6,8,0.01,2)
...@@ -8,8 +8,6 @@ P1 = 0.015 ...@@ -8,8 +8,6 @@ P1 = 0.015
class Individu(): class Individu():
def __init__(self, table): def __init__(self, table):
self.table = table self.table = table
self.score = None self.score = None
...@@ -61,3 +59,9 @@ class Individu(): ...@@ -61,3 +59,9 @@ class Individu():
# test = Individu(table) # test = Individu(table)
# test.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA") # test.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
# print(test.score) # print(test.score)
qqun=Individu(RotTable())
qqun.table.rot_table={'AA': [35.576558502141, 7.433901511509349, -154], 'AC': [33.22048222654215, 5.25191751302917, 143], 'AG': [26.446029097301288, 6.052240462237622, -2], 'AT': [30.47045254036881, 1.333716025628036, 0], 'CA': [34.00734209585039, 33.70710613604862, -64], 'CC': [33.61019622767888, 3.713127032109607, -57], 'CG': [29.664061041382677, 6.725155507162601, 0], 'CT': [26.446029097301288, 6.052240462237622, 2], 'GA': [36.655773481637176, 10.45337581740701, 120], 'GC': [42.26984493493484, 3.5310453395352823, 180], 'GG': [33.61019622767888, 3.713127032109607, -57], 'GT': [33.22048222654215, 5.25191751302917, 143], 'TA': [36.951508786388914, -2.5174751178033303, 0], 'TC': [36.655773481637176, 10.45337581740701, -120], 'TG': [34.00734209585039, 33.70710613604862, -64], 'TT': [35.576558502141, 7.433901511509349, -154]}
qqun.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
print(qqun.score)
...@@ -31,7 +31,7 @@ class table_rotation(rotation): ...@@ -31,7 +31,7 @@ class table_rotation(rotation):
self.dict = {doublet : rotation(doublet) for doublet in ORIGINAL_ROT_TABLE} self.dict = {doublet : rotation(doublet) for doublet in ORIGINAL_ROT_TABLE}
table1 = table_rotation() table1 = table_rotation()
print(table1.dict["AA"].x) # print(table1.dict["AA"].x)
#table1.dict --> {'AA': <__main__.rotation object at 0x000001A722E1BAC8>, 'AC': <__main__.rotation object at 0x000001A722E1BB00>, 'AG': <__main__.rotation object at 0x000001A729A66A58>, 'AT': <__main__.rotation object at 0x000001A729A66A20>, 'CA': <__main__.rotation object at 0x000001A729A669E8>, 'CC': <__main__.rotation object at 0x000001A729A66A90>, 'CG': <__main__.rotation object at 0x000001A729A66B00>, 'CT': <__main__.rotation object at 0x000001A729A66B70>, 'GA': <__main__.rotation object at 0x000001A729B88D68>, 'GC': <__main__.rotation object at 0x000001A729B88DA0>, 'GG': <__main__.rotation object at 0x000001A729B88DD8>, 'GT': <__main__.rotation object at 0x000001A729B88E10>, 'TA': <__main__.rotation object at 0x000001A729B88E48>, 'TC': <__main__.rotation object at 0x000001A729B88E80>, 'TG': <__main__.rotation object at 0x000001A729B88EB8>, 'TT': <__main__.rotation object at 0x000001A729B88EF0>} #table1.dict --> {'AA': <__main__.rotation object at 0x000001A722E1BAC8>, 'AC': <__main__.rotation object at 0x000001A722E1BB00>, 'AG': <__main__.rotation object at 0x000001A729A66A58>, 'AT': <__main__.rotation object at 0x000001A729A66A20>, 'CA': <__main__.rotation object at 0x000001A729A669E8>, 'CC': <__main__.rotation object at 0x000001A729A66A90>, 'CG': <__main__.rotation object at 0x000001A729A66B00>, 'CT': <__main__.rotation object at 0x000001A729A66B70>, 'GA': <__main__.rotation object at 0x000001A729B88D68>, 'GC': <__main__.rotation object at 0x000001A729B88DA0>, 'GG': <__main__.rotation object at 0x000001A729B88DD8>, 'GT': <__main__.rotation object at 0x000001A729B88E10>, 'TA': <__main__.rotation object at 0x000001A729B88E48>, 'TC': <__main__.rotation object at 0x000001A729B88E80>, 'TG': <__main__.rotation object at 0x000001A729B88EB8>, 'TT': <__main__.rotation object at 0x000001A729B88EF0>}
#table1.dict["AA"] ---> <__main__.rotation object at 0x000001A722E1BAC8> (qui est l'object rotation) #table1.dict["AA"] ---> <__main__.rotation object at 0x000001A722E1BAC8> (qui est l'object rotation)
......
import random
from random import random, randint, randrange from random import *
from individu import Individu from individu import Individu
from RotTable import RotTable from RotTable import RotTable
from croisement import croisement_un_point, croisement_deux_points from croisement import croisement_un_point, croisement_deux_points
...@@ -45,25 +45,28 @@ class Population: ...@@ -45,25 +45,28 @@ class Population:
meilleur = self.indiv[0] meilleur = self.indiv[0]
for individu in self.indiv : for individu in self.indiv :
if meilleur.score < individu.score: if meilleur.score < individu.score:
print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu meilleur = individu
newself = [meilleur] newself = [meilleur]
print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score) # print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score)
vu=set()
t=randrange(0,self.n) t=randrange(0,self.n)
m=randrange(0,self.n) m=randrange(0,self.n)
non_vu = [i for i in range(0, self.n)]
while len(newself)<p: while len(newself)<p:
while m in vu: m = choice(non_vu)
m=randrange(0,self.n) non_vu.remove(m)
while t in vu: t = choice(non_vu)
t=randrange(0,self.n) non_vu.remove(t)
x=self.indiv[m] x=self.indiv[m]
y=self.indiv[t] y=self.indiv[t]
vu.add(t)
vu.add(m)
if x.score>=y.score: if x.score>=y.score:
newself.append(x) newself.append(x)
else: else:
newself.append(y) newself.append(y)
for i in range(0, len(newself)):
print(newself[i].score)
self = self.modifier_population(newself) self = self.modifier_population(newself)
def selection_par_rang(self,p = None): def selection_par_rang(self,p = None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment