diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index 20d277d55079d7a6401199aa6d99042a10aacd32..d0d2bee9e71c849781de9a96c497f02788ecaaf7 100644 Binary files a/__pycache__/RotTable.cpython-37.pyc and b/__pycache__/RotTable.cpython-37.pyc differ diff --git a/__pycache__/Traj3D.cpython-37.pyc b/__pycache__/Traj3D.cpython-37.pyc index 3051667333c64564621cb2fe405f2b8ac037b6bd..9f5f20ef7c01a060943e03ea5beaee567c92ae7e 100644 Binary files a/__pycache__/Traj3D.cpython-37.pyc and b/__pycache__/Traj3D.cpython-37.pyc differ diff --git a/__pycache__/individu.cpython-37.pyc b/__pycache__/individu.cpython-37.pyc index 98e1fc46b75b89e6b1481052c1f6d4bf92a9d04c..83b7aac12df9ffd210cc807f63745df4b2a39629 100644 Binary files a/__pycache__/individu.cpython-37.pyc and b/__pycache__/individu.cpython-37.pyc differ diff --git a/algogenetique.py b/algogenetique.py index 92034969ea1f0770c5ca3b46b79e7e4397b17972..e89effd2d09d553c9119e5b174ef0be757755c8e 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -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) diff --git a/individu.py b/individu.py index 7b7915bacbb733b06dc234f602de8817eda6e295..08744e8f0dc9a3ca276c4ff3b75c3ab6dd5cb4be 100644 --- a/individu.py +++ b/individu.py @@ -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) diff --git a/population.py b/population.py index d7649e54ca7bdc08663c955cd76a425082e93ba2..7d2507349ff1cdf2d946cdb03a6cdf7eca96da7a 100644 --- a/population.py +++ b/population.py @@ -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")