Skip to content
Snippets Groups Projects
individu.py 1.09 KiB
Newer Older
Gauthier Roy's avatar
Gauthier Roy committed
from RotTable import RotTable
from Traj3D import *
Gauthier Roy's avatar
Gauthier Roy committed
import numpy as np
from math import sqrt

class Individu():

Gauthier Roy's avatar
Gauthier Roy committed
    def __init__(self, table):
        self.table = table
Gauthier Roy's avatar
Gauthier Roy committed
        self.score = None
    
    def evaluate(self, brin):
        traj = Traj3D()

Gauthier Roy's avatar
Gauthier Roy committed
        fisrt_nuc = brin[0]
        last_nu = brin[-1]
Gauthier Roy's avatar
Gauthier Roy committed
        traj.compute(brin + fisrt_nuc, self.table)
        traj_array = np.array(traj.getTraj())
Gauthier Roy's avatar
Gauthier Roy committed
        first_nuc_coordonate = traj_array[0, 0:3]
        last_nuc_coordonate = traj_array[-2, 0:3]
Gauthier Roy's avatar
Gauthier Roy committed
        test = np.linalg.norm(first_nuc_coordonate - last_nuc_coordonate, ord=2)
        distance = sqrt(sum((first_nuc_coordonate - last_nuc_coordonate) ** 2))
        diff_ideal_distance = abs(3.38 - distance)
        diff_ideal_distance_2 = abs(3.38 - test)
        self.score = (1/(diff_ideal_distance ), 1/diff_ideal_distance_2)
Gauthier Roy's avatar
Gauthier Roy committed
        
    
    def mutation(self):
Gauthier Roy's avatar
Gauthier Roy committed
        mutation = 0
Gauthier Roy's avatar
Gauthier Roy committed
        return mutation
Gauthier Roy's avatar
Gauthier Roy committed

table = RotTable()
test = Individu(table)
test.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
Gauthier Roy's avatar
Gauthier Roy committed
print(table.rot_table)
Gauthier Roy's avatar
Gauthier Roy committed
print(test.score)