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

merge with carlos branch

parents 69e8a061 eaf11a4e
Branches
No related tags found
No related merge requests found
No preview for this file type
...@@ -8,14 +8,14 @@ import croisement ...@@ -8,14 +8,14 @@ import croisement
from Traj3D import * from Traj3D import *
from random import random from random import random
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import time import time
# Debut du decompte du temps # Debut du decompte du temps
start_time = time.time() start_time = time.time()
def main(N,tmax,pmutation, proportion): def main(N,tmax,pmutation, proportion):
L=[] L=[]
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")] lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:]) brin = ''.join(lineList[1:])
...@@ -35,7 +35,6 @@ def main(N,tmax,pmutation, proportion): ...@@ -35,7 +35,6 @@ def main(N,tmax,pmutation, proportion):
best=individu best=individu
mini=individu.score mini=individu.score
L.append(mini) L.append(mini)
plt.subplot(221) plt.subplot(221)
plt.plot([i for i in range(tmax)], L) plt.plot([i for i in range(tmax)], L)
......
...@@ -9,37 +9,38 @@ P1 = 0.015 ...@@ -9,37 +9,38 @@ P1 = 0.015
class Individu(): class Individu():
def __init__(self, table): def __init__(self, table):
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
self.table = table self.table = table
self.score = self.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA") self.score = inf
def evaluate(self, brin): def evaluate(self, brin):
traj = Traj3D() traj = Traj3D()
numb_ajout = 3 numb_ajout = 6
fisrt_seq = brin[0:numb_ajout] fisrt_seq = brin[0:numb_ajout]
last_seq = brin[-numb_ajout:] last_seq = brin[-numb_ajout:]
traj.compute(last_seq + brin + fisrt_seq, self.table) traj.compute(last_seq + brin + fisrt_seq, self.table)
traj_array = np.array(traj.getTraj()) traj_array = np.array(traj.getTraj())
list_distance = [] list_distance = []
for i in range(numb_ajout): begining = traj_array[0:2*numb_ajout, 0:3]
first_nuc_coordonate = traj_array[numb_ajout+i, 0:3] end = traj_array[-2*numb_ajout:, 0:3]
first_nuc_coordonate_compute = traj_array[-(numb_ajout-i), 0:3]
last_nuc_coordonate = traj_array[-(2*numb_ajout-i), 0:3]
last_nuc_coordonate_compute = traj_array[i, 0:3]
distance_first_nuc = np.linalg.norm(first_nuc_coordonate - first_nuc_coordonate_compute, ord=2) for i in range(numb_ajout):
distance_last_nuc = np.linalg.norm(last_nuc_coordonate - last_nuc_coordonate_compute, ord=2)
list_distance += [distance_first_nuc, distance_last_nuc] nuc_coordonate_beg = begining[i]
nuc_coordonate_end = end[i]
distance_nuc = np.linalg.norm(nuc_coordonate_beg - nuc_coordonate_end, ord=2)
list_distance += [distance_nuc]
self.score = max(list_distance) self.score = max(list_distance)
return max(list_distance) #return max(list_distance)
def mutation(self, proba = P1): def mutation(self, proba = P1):
...@@ -61,10 +62,10 @@ class Individu(): ...@@ -61,10 +62,10 @@ class Individu():
# print(individu1.table.rot_table) # print(individu1.table.rot_table)
# individu1.mutation() # individu1.mutation()
# table = RotTable() table = RotTable()
# test = Individu(table) test = Individu(table)
# test.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA") test.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
# print(test.score) print(test.score)
# qqun=Individu(RotTable()) # qqun=Individu(RotTable())
......
...@@ -68,7 +68,7 @@ class Population: ...@@ -68,7 +68,7 @@ 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) #print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu meilleur = individu
newself = [meilleur] newself = [meilleur]
vu=set() vu=set()
...@@ -83,7 +83,7 @@ class Population: ...@@ -83,7 +83,7 @@ class Population:
x=self.indiv[m] x=self.indiv[m]
y=self.indiv[t] y=self.indiv[t]
if x.score<y.score: if x.score<=y.score:
newself.append(x) newself.append(x)
else: else:
newself.append(y) newself.append(y)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment