Skip to content
Snippets Groups Projects
Commit 69e8a061 authored by Santos Garcia Carlos's avatar Santos Garcia Carlos
Browse files

minimiser distance, histogrammes et brin affiché

parent d6b865f7
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -8,32 +8,59 @@ import croisement
from Traj3D import *
from random import random
import matplotlib.pyplot as plt
import time
# Debut du decompte du temps
start_time = time.time()
def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
'''lineList = [line.rstrip('\n') for line in open(brin)]
brin = ''.join(lineList[1:])'''
def main(N,tmax,pmutation, proportion):
L=[]
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
People=Population(N)
S1=[]
for individu in People.indiv:
individu.evaluate(brin)
S1.append(int(individu.score))
maximum=int(max(S1))
for i in range(tmax):
print(i)
max=0
best=None
mini=People.indiv[0].score
best=People.indiv[0]
People.reproduction(p = proportion, proba_mutation= pmutation)
for individu in People.indiv:
if individu.score>max:
if individu.score<mini:
best=individu
max=individu.score
L.append(max)
mini=individu.score
L.append(mini)
plt.subplot(221)
plt.plot([i for i in range(tmax)], L)
plt.subplot(223)
plt.hist(S1, range = (0, maximum+10), bins = 20, color = 'red')
S2=[individu.score for individu in People.indiv]
print("Score final: ",best.score)
plt.subplot(224)
plt.hist(S2, range = (0,maximum+10), bins = 20, color = 'blue')
plt.show()
return(best,People)
return(best,People)
best,People = main(100,100,0.01,50)
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
best,People = main(10,10,0.01,5)
test = Traj3D()
test.compute("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA", best.table)
test.compute(brin, best.table)
test.draw("first_plot")
# Affichage du temps d execution
print("Temps d'execution : %s secondes " % (time.time() - start_time))
......@@ -37,9 +37,9 @@ class Individu():
list_distance += [distance_first_nuc, distance_last_nuc]
self.score = 1/max(list_distance)
self.score = max(list_distance)
return 1/max(list_distance)
return max(list_distance)
def mutation(self, proba = P1):
......
......@@ -67,7 +67,7 @@ class Population:
p = (self.n)//2
meilleur = self.indiv[0]
for individu in self.indiv :
if meilleur.score < individu.score:
if meilleur.score > individu.score:
print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu
newself = [meilleur]
......@@ -83,7 +83,7 @@ class Population:
x=self.indiv[m]
y=self.indiv[t]
if x.score>=y.score:
if x.score<y.score:
newself.append(x)
else:
newself.append(y)
......@@ -167,8 +167,10 @@ class Population:
y=copy.deepcopy(newself[t])
couple_enfant = enfant(x,y)
for child in couple_enfant :
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
child.mutation(proba_mutation)
child.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
child.evaluate(brin)
newself.append(couple_enfant[0])
newself.append(couple_enfant[1])
self = self.modifier_population(newself)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment