Skip to content
Snippets Groups Projects
RotTable.py 2.96 KiB
Newer Older
Busson Loic's avatar
Busson Loic committed
import mathutils
import math
import numpy
Busson Loic's avatar
Busson Loic committed

class RotTable:
    """Represents the rotation table"""

    __ORIGINAL_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]\
Busson Loic's avatar
Busson Loic committed
        }

        "AA": "TT",\
        "AC": "GT",\
        "AG": "CT",\
        "AT": "AT",\
        "CA": "TG",\
        "CC": "GG",\
        "CG": "CG",\
        "CT": "AG",\
        "GA": "TC",\
        "GC": "GC",\
        "GG": "CC",\
        "GT": "AC",\
        "TA": "TA",\
        "TC": "GA",\
        "TG": "CA",\
Busson Loic's avatar
Busson Loic committed
        "TT": "AA"\
Busson Loic's avatar
Busson Loic committed
        }

Busson Loic's avatar
Busson Loic committed
    __SOUS_CORRESPONDANCE = {\
        "AA": "TT",\
        "AC": "GT",\
        "AG": "CT",\
        "AT": "AT",\
        "CA": "TG",\
        "CC": "GG",\
        "CG": "CG",\
        "GA": "TC",\
        "GC": "GC",\
        "TA": "TA"\
        }
    # get the angles in each axis (x, y, z), considering the deviation
Busson Loic's avatar
Busson Loic committed
    def __init__(self):
        self.rot_table = {}
Busson Loic's avatar
Busson Loic committed
        for dinucleotide in RotTable.__ORIGINAL_ROT_TABLE:
            self.rot_table[dinucleotide] = RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][:3]
        self.alea()
Busson Loic's avatar
Busson Loic committed

    # get a random deviation, considering the "limits" given in the last 3 columns
    # of __ORIGINAL_ROT_TABLE
Busson Loic's avatar
Busson Loic committed
    def alea(self):
Busson Loic's avatar
Busson Loic committed
        for dinucleotide in RotTable.__SOUS_CORRESPONDANCE:
Busson Loic's avatar
Busson Loic committed
            for i in range(2):
Busson Loic's avatar
Busson Loic committed
                delta = numpy.random.uniform(low = -RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3], high= RotTable.__ORIGINAL_ROT_TABLE[dinucleotide][i+3])
                self.rot_table[dinucleotide][i] += delta
                self.rot_table[RotTable.__SOUS_CORRESPONDANCE[dinucleotide]][i] += delta
Busson Loic's avatar
Busson Loic committed

    # return __ORIGINAL_ROT_TABLE
Kappes Marques Rodrigo's avatar
Kappes Marques Rodrigo committed
    def orta(self):
        return self.__ORIGINAL_ROT_TABLE
Busson Loic's avatar
Busson Loic committed

    ###################
    # WRITING METHODS #
    ###################
    #table = RotTable()
    #table.rot_table["AA"] --> [35.62, 7.2, -154]
Busson Loic's avatar
Busson Loic committed

    ###################
    # READING METHODS #
    ###################

    def getTwist(self, dinucleotide):
Gauthier Roy's avatar
Gauthier Roy committed
        return self.rot_table[dinucleotide][0]
Busson Loic's avatar
Busson Loic committed

    def getWedge(self, dinucleotide):
Gauthier Roy's avatar
Gauthier Roy committed
        return self.rot_table[dinucleotide][1]
Busson Loic's avatar
Busson Loic committed

    def getDirection(self, dinucleotide):
Gauthier Roy's avatar
Gauthier Roy committed
        return self.rot_table[dinucleotide][2]
Busson Loic's avatar
Busson Loic committed

    ###################
Busson Loic's avatar
Busson Loic committed

Gauthier Roy's avatar
Gauthier Roy committed
#table1 = RotTable()
#print(table1.orta())
Muller Sacha's avatar
Muller Sacha committed
# print(table1.rot_table)