Skip to content
Snippets Groups Projects
individu.py 962 B
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
        traj.compute(brin, self.table)
Gauthier Roy's avatar
Gauthier Roy committed
        traj_array = np.array(traj.getTraj())
Gauthier Roy's avatar
Gauthier Roy committed
        print(traj_array)
Gauthier Roy's avatar
Gauthier Roy committed
        first_nucleotide = traj_array[0, 0:3]
        last_nucleotide = traj_array[-1, 0:3]
Gauthier Roy's avatar
Gauthier Roy committed
        print(first_nucleotide)
        print(last_nucleotide)
Gauthier Roy's avatar
Gauthier Roy committed
        distance = sqrt(sum((first_nucleotide - last_nucleotide) ** 2))
Gauthier Roy's avatar
Gauthier Roy committed
        diff_ideal_distance = abs(3.38 - distance)
Gauthier Roy's avatar
Gauthier Roy committed
        self.score = 1/(diff_ideal_distance )
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)