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

fix of merge conflict

parents 8ea8b1c0 4ea361b8
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
......@@ -22,11 +22,11 @@ def main(N,tmax,pmutation, proportion):
People=Population(N)
S1=[]
for individu in People.indiv:
individu.evaluate(brin)
individu.evaluate()
S1.append(int(individu.score))
maximum=int(max(S1))
for i in range(tmax):
print(i)
#print(i)
mini=People.indiv[0].score
best=People.indiv[0]
People.reproduction(p = proportion, proba_mutation= pmutation)
......
......@@ -12,17 +12,20 @@ class Individu():
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
self.table = table
self.score = inf
def evaluate(self, brin):
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
self.brin = ''.join(lineList[1:])
#self.brin = "AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA"
self.score = self.evaluate()
def evaluate(self):
traj = Traj3D()
numb_ajout = 6
fisrt_seq = brin[0:numb_ajout]
last_seq = brin[-numb_ajout:]
fisrt_seq = self.brin[0:numb_ajout]
last_seq = self.brin[-numb_ajout:]
traj.compute(last_seq + brin + fisrt_seq, self.table)
traj.compute(last_seq + self.brin + fisrt_seq, self.table)
traj_array = np.array(traj.getTraj())
list_distance = []
......@@ -57,6 +60,25 @@ class Individu():
#sur l'axe z il y a un moins
table_rotations[doublet2][coord] = - table_rotations[doublet][coord]
def mutation_with_numbers(self, proba = P1, number_of_mutations = 5):
table_rotations = self.table.rot_table
for i in range(0,number_of_mutations):
tir = random()
if tir < proba :
doubletNumber = randrange(0,8)
counter = 0
for doublet in table_rotations:
if counter==doubletNumber:
break
counter+=1
for coord in range(3):
table_rotations[doublet][coord] =np.random.uniform(low = self.table.orta()[doublet][coord] - self.table.orta()[doublet][coord + 3], high = self.table.orta()[doublet][coord] + self.table.orta()[doublet][coord + 3])
doublet2 = self.table.corr()[doublet]
if coord == 0 or coord == 1 :
table_rotations[doublet2][coord] = table_rotations[doublet][coord]
else :
#sur l'axe z il y a un moins
table_rotations[doublet2][coord] = - table_rotations[doublet][coord]
# individu1 = Individu(RotTable())
# print(individu1.table.rot_table)
......
......@@ -15,7 +15,7 @@ class Population:
self.n = len(liste_individus)
self.indiv = liste_individus
for i in range(0,self.n):
self.indiv[i].evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
self.indiv[i].evaluate()
return self
......@@ -170,7 +170,7 @@ class Population:
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
child.mutation(proba_mutation)
child.evaluate(brin)
child.evaluate()
newself.append(couple_enfant[0])
newself.append(couple_enfant[1])
self = self.modifier_population(newself)
......@@ -186,7 +186,7 @@ def test():
popu = Population(4)
print("\n POPULATION INITIALE \n")
for individu in popu.indiv :
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
individu.evaluate()
afficher(popu)
popu.reproduction(selection = popu.selection_duel)
print("\n REPRODUCTION \n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment