Skip to content
Snippets Groups Projects
Commit a7eeb77d authored by Muller Sacha's avatar Muller Sacha
Browse files

creation de la fonction mutation et correction de RotTable et individu.py

parent e65fba6d
No related branches found
No related tags found
No related merge requests found
......@@ -25,23 +25,23 @@ class RotTable:
}
def __init__(self):
self.Rot_Table = {}
self.rot_table = {}
for dinucleotide in RotTable.__ORIGINAL_ROT_TABLE:
self.Rot_Table[dinucleotide] = RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][:3]
self.rot_table[dinucleotide] = RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][:3]
self.alea()
def alea(self):
for dinucleotide in RotTable.__ORIGINAL_ROT_TABLE:
for i in range(2):
self.Rot_Table[dinucleotide][i] += numpy.random.uniform(low = -RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3], high= RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3])
self.rot_table[dinucleotide][i] += numpy.random.uniform(low = -RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3], high= RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3])
###################
# WRITING METHODS #
###################
#table = RotTable()
#table.__Rot_Table["AA"] --> [35.62, 7.2, -154]
#table.rot_table["AA"] --> [35.62, 7.2, -154]
###################
# READING METHODS #
......@@ -59,4 +59,4 @@ class RotTable:
###################
table1 = RotTable()
print(table1.Rot_Table["AA"])
print(table1.rot_table["AA"])
from Initialisation import table_rotation
from RotTable import RotTable
from Traj3D import *
import numpy as np
from math import sqrt
from random import random
P1 = 0.015
class Individu():
def __init__(self, rot_table):
self.rot_table = rot_table
def __init__(self, table):
self.table = table
self.score = None
def evaluate(self, brin):
traj = Traj3D()
traj.compute(brin, self.rot_table)
traj.compute(brin, self.table)
traj_array = np.array(traj.getTraj())
first_nucleotide = traj_array[0, :]
......@@ -21,16 +24,24 @@ class Individu():
first_name = brin[0]
last_name = brin[-1]
rot_computed = self.rot_table[last_name+first_name]
rot_computed = self.table[last_name+first_name]
rot_traj = first_name - last_name
diff_angle = sum(abs(rot_computed - rot_traj))
self.score = 1/(distance + diff_angle)
# def mutation(self):
# return mutation
individu1 = Individu(table_rotation())
print(individu1.rot_table.dict["AA"].x)
\ No newline at end of file
def mutation(self, proba = P1):
table_rotations = self.table.rot_table
for doublet in table_rotations :
for coord in range(3):
tir = random()
if tir < proba :
print("mutation", doublet, coord)
print("table", table_rotations[doublet][coord])
table_rotations[doublet][coord] =np.random.uniform(low = self.table.__ORIGINAL_ROT_TABLE[doublet][coord] - self.table.__ORIGINAL_ROT_TABLE[doublet][coord + 3], high = self.table.__ORIGINAL_ROT_TABLE[doublet][coord] + self.table.__ORIGINAL_ROT_TABLE[doublet][coord + 3])
print("table", table_rotations[doublet][coord])
individu1 = Individu(RotTable())
print(individu1.table.rot_table)
individu1.mutation()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment