diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index 97c7b449f729cb4937feb17325b1d5876ee76f4e..a2a8357d3008572384c7dcf2386e0a1d32d1e2de 100644 Binary files a/__pycache__/RotTable.cpython-37.pyc and b/__pycache__/RotTable.cpython-37.pyc differ diff --git a/__pycache__/croisement.cpython-37.pyc b/__pycache__/croisement.cpython-37.pyc index 14137ab2a364a8f37a255767bdb564b07c910feb..d198ea9d256280ccf31cd22357458311486cf9b6 100644 Binary files a/__pycache__/croisement.cpython-37.pyc and b/__pycache__/croisement.cpython-37.pyc differ diff --git a/__pycache__/individu.cpython-37.pyc b/__pycache__/individu.cpython-37.pyc index 3ef8c96f9616f2b5975f79ca003e59c0324ae6ae..49544ba734948726b642b284d58a3f5e1c39df81 100644 Binary files a/__pycache__/individu.cpython-37.pyc and b/__pycache__/individu.cpython-37.pyc differ diff --git a/__pycache__/population.cpython-37.pyc b/__pycache__/population.cpython-37.pyc index 3ff838dd3cc557205dd89fdb4f68cfc48e4fcaaf..c8b9251be885e62a4a09645d6eb683f983ea38da 100644 Binary files a/__pycache__/population.cpython-37.pyc and b/__pycache__/population.cpython-37.pyc differ diff --git a/croisement.py b/croisement.py index 95119ecfe8ad91ea23492e9e9eab8fb3ced18b09..e9942ef5b4d0c7e628dfbd1515587c22b1486c1f 100644 --- a/croisement.py +++ b/croisement.py @@ -2,37 +2,22 @@ import numpy from RotTable import RotTable from individu import Individu -ROT_TABLE = {\ - "AA": [35.62, 7.2, -154, 0.06, 0.6, 0],\ - "AC": [34.4, 1.1, 143, 1.3, 5, 0],\ - "AG": [27.7, 8.4, 2, 1.5, 3, 0],\ - "AT": [31.5, 2.6, 0, 1.1, 2, 0],\ - "CA": [34.5, 3.5, -64, 0.9, 34, 0],\ - "CC": [33.67, 2.1, -57, 0.07, 2.1, 0],\ - "CG": [29.8, 6.7, 0, 1.1, 1.5, 0],\ - "CT": [27.7, 8.4, -2, 1.5, 3, 0],\ - "GA": [36.9, 5.3, 120, 0.9, 6, 0],\ - "GC": [40, 5, 180, 1.2, 1.275, 0],\ - "GG": [33.67, 2.1, 57, 0.07, 2.1, 0],\ - "GT": [34.4, 1.1, -143, 1.3, 5, 0],\ - "TA": [36, 0.9, 0, 1.1, 2, 0],\ - "TC": [36.9, 5.3, -120, 0.9, 6, 0],\ - "TG": [34.5, 3.5, 64, 0.9, 34, 0],\ - "TT": [35.62, 7.2, -154, 0.06, 0.6, 0]\ - } - - def croisement_un_point(parent1, parent2): '''Croise les tables de rotation des parents pour former deux enfants en respectant les symétries du problème''' ''' Retourne deux enfants''' + enfant1 = Individu(RotTable()) enfant2 = Individu(RotTable()) comp = 0 point_crois= numpy.random.random_integers(0,8) - list_dinucleotides = sorted(ROT_TABLE) + list_dinucleotides = sorted(RotTable().orta()) + + #We look at the list of sorted dinucleotides and create the crossover for doublet in list_dinucleotides: if doublet == "GA": break + + #If it have a value smaller than the generated number it wont do the crossover if comp < point_crois: enfant1.table.rot_table[doublet] = parent1.table.rot_table[doublet] correspondent_doublet1 = enfant1.table.corr()[doublet] @@ -44,6 +29,7 @@ def croisement_un_point(parent1, parent2): enfant2.table.rot_table[correspondent_doublet2] = parent2.table.rot_table[correspondent_doublet2] enfant2.table.rot_table[correspondent_doublet2][2] *= -1 + #If it have a value bigger than the generated number it will crossover else : enfant1.table.rot_table[doublet] = parent2.table.rot_table[doublet] correspondent_doublet1 = enfant1.table.corr()[doublet] @@ -62,13 +48,19 @@ def croisement_un_point(parent1, parent2): def croisement_deux_points(parent1, parent2): ''' Croise les tables de rotationd des deux parents en croisant à deux points et respectant les symétries du problème''' ''' Retourne deux enfants''' + enfant1 = Individu(RotTable()) enfant2 = Individu(RotTable()) comp = 0 point_crois1= numpy.random.random_integers(0,8) point_crois2= numpy.random.random_integers(0,8) list_dinucleotides = sorted(ROT_TABLE) + + #We look at the list of sorted dinucleotides and create the crossover for doublet in list_dinucleotides: + + #If it have a value smaller than the first generated number it wont do the crossover + #unless it have a value bigger than the second generated number if comp < min(point_crois1,point_crois2) or comp > max(point_crois1,point_crois2): enfant1.table.rot_table[doublet] = parent1.table.rot_table[doublet] correspondent_doublet1 = enfant1.table.corr()[doublet] @@ -80,6 +72,7 @@ def croisement_deux_points(parent1, parent2): enfant2.table.rot_table[correspondent_doublet2] = parent2.table.rot_table[correspondent_doublet2] enfant2.table.rot_table[correspondent_doublet2][2] *= -1 + #If it have a value is located in between the generated values it will do the crossover else : enfant1.table.rot_table[doublet] = parent2.table.rot_table[doublet] correspondent_doublet1 = enfant1.table.corr()[doublet] @@ -92,11 +85,3 @@ def croisement_deux_points(parent1, parent2): enfant2.table.rot_table[correspondent_doublet2][2] *= -1 comp += 1 return enfant1, enfant2 - -# parent1 = Individu(RotTable()) -# parent2 = Individu(RotTable()) -# print("parent1: ", parent1.table.rot_table) -# print("parent2: ", parent2.table.rot_table) -# enfant1, enfant2 = croisement_un_point(parent1, parent2) -# print("enfant1: ", enfant1.table.rot_table) -# print("enfant2: ", enfant2.table.rot_table) \ No newline at end of file diff --git a/individu.py b/individu.py index c6b3ba2a49173b6f438e035534af508f0dc27049..abb27b113f15006c20f1cb1f9b0bda12297f46d8 100644 --- a/individu.py +++ b/individu.py @@ -8,6 +8,7 @@ P1 = 0.015 class Individu(): ''' Un individu est caractérisé par sa table de rotations (individu.table)''' + def __init__(self, table): self.table = table lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")] diff --git a/population.py b/population.py index c576750c6a07d703b25181a5bdf5a53d5a2a1281..2c89349ff371c58b15e405c5afa37c50eda00dc7 100644 --- a/population.py +++ b/population.py @@ -95,12 +95,10 @@ class Population: for _ in range(p-1): curseur = random()*n*(n+1)/2 - # print("curseur", curseur) j = 1 while j*(j+1)/2 < curseur : j+=1 #on doit prendre l'individu avec le jème score - # print("individus selectionés", individus_selectionnes) individus_selectionnes.append(liste_individus[j-1]) self = self.modifier_population(individus_selectionnes) @@ -164,7 +162,6 @@ class Population: def afficher(popu): for individu in popu.indiv : print("\n individu \n") - # print(individu.table.rot_table) print ("score", individu.score)