SHARE
TWEET

Untitled

a guest Oct 14th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DNA(object):
  2.     def __init__(self):
  3.         pass
  4.  
  5.     def getSingleTemplate(self, std):
  6.         if std == 'A':
  7.             return 'T'
  8.         elif std == 'T':
  9.             return 'A'
  10.         elif std == 'G':
  11.             return 'C'
  12.         elif std == 'C':
  13.             return 'G'
  14.  
  15.     def getSingleRNA(self, std):
  16.         if std == 'A':
  17.             return 'U'
  18.         elif std == 'T':
  19.             return 'A'
  20.         elif std == 'G':
  21.             return 'C'
  22.         elif std == 'C':
  23.             return 'G'
  24.  
  25.     # 6 - Dado uma fita codificante (coding) faça a complementar (template);
  26.     def getFullTemplate(self, _coding):
  27.         template = ''
  28.         for i in _coding:
  29.             template += self.getSingleTemplate(i)
  30.         return template
  31.  
  32.     # 7 - Dado uma fita complementar(template) encontre a sequência de RNA correspondente;
  33.     def getFullRNA(self, _type, _input):
  34.         template = _input
  35.         rna      = ''
  36.  
  37.         if _type == 'coding':
  38.             template = self.getFullTemplate(_input)
  39.         for i in template:
  40.             rna += self.getSingleRNA(i)
  41.         return rna
  42.  
  43.     def getCodingFromRNA(self, _rna):
  44.         return _rna.replace('U','T')
  45.  
  46.     def getTranslation(self, _tree_letters):
  47.         if _tree_letters in ('TTT', 'TTC'):
  48.             return 'Phe'
  49.         elif _tree_letters in ('TTA', 'TTG'):
  50.             return 'Leu'
  51.         elif _tree_letters in ('TCT', 'TCC', 'TCA', 'TCG'):
  52.             return 'Ser'
  53.         elif _tree_letters in ('TAT', 'TAC'):
  54.             return 'Tyr'
  55.         elif _tree_letters in ('TGT', 'TGC'):
  56.             return 'Cys'
  57.         elif _tree_letters in ('TGG'):
  58.             return 'Trp'
  59.         elif _tree_letters in ('CTT', 'CTC', 'CTA', 'CTG'):
  60.             return 'Leu'
  61.         elif _tree_letters in ('CCT', 'CCC', 'CCA', 'CCG'):
  62.             return 'Pro'
  63.         elif _tree_letters in ('CAT', 'CAC'):
  64.             return 'His'
  65.         elif _tree_letters in ('CAA', 'CAG'):
  66.             return 'Gin'
  67.         elif _tree_letters in ('CGT', 'CGC', 'CGA', 'CGG'):
  68.             return 'Arg'
  69.         elif _tree_letters in ('ATT', 'ATC', 'ATA'):
  70.             return 'Ile'
  71.         elif _tree_letters in ('ATG'):
  72.             return 'Met'
  73.         elif _tree_letters in ('ACT', 'ACC', 'ACA', 'ACG'):
  74.             return 'Thr'
  75.         elif _tree_letters in ('AAT', 'AAC'):
  76.             return 'Asn'
  77.         elif _tree_letters in ('AAA', 'AAG'):
  78.             return 'Lys'
  79.         elif _tree_letters in ('AGT', 'AGC'):
  80.             return 'Ser'
  81.         elif _tree_letters in ('AGA', 'AGG'):
  82.             return 'Arg'
  83.         elif _tree_letters in ('GTT', 'GTC', 'GTA', 'GTG'):
  84.             return 'Val'
  85.         elif _tree_letters in ('GCT', 'GCC', 'GCA', 'GCG'):
  86.             return 'Ala'
  87.         elif _tree_letters in ('GAT', 'GAC'):
  88.             return 'Asp'
  89.         elif _tree_letters in ('GAA', 'GAG'):
  90.             return 'Giu'
  91.         elif _tree_letters in ('GGT', 'GGC', 'GGA', 'GGG'):
  92.             return 'Gly'
  93.  
  94.         else:
  95.             return False
  96.  
  97.  
  98.     def getFullTranslation(self, _rna):
  99.         full_translation = []
  100.         aminoacidos = []
  101.         translation = ''
  102.         trinca = ''
  103.         for i in _rna:
  104.             trinca += i
  105.             if len(trinca) == 3:
  106.                 single = self.getTranslation(trinca)
  107.                 if single:
  108.                     aminoacidos.append(single)
  109.                 else:
  110.                     if len(aminoacidos) > 0:
  111.                         full_translation.append(aminoacidos)
  112.                     aminoacidos = []
  113.                 trinca = ''
  114.  
  115.         return full_translation
  116.  
  117. dna = DNA()
  118. sequence = 'AAAAGGTCCACGCTTTCGCGCCCCGGT'
  119.  
  120. template = dna.getFullTemplate(sequence)
  121. print('')
  122. print('----- TEMPLATE -------')
  123. print(template)
  124. print('')
  125.  
  126. rna = dna.getFullRNA(_type='coding', _input=sequence)
  127. print('----- RNA -------')
  128. print(rna)
  129. print('')
  130.  
  131. print('----- CODING FROM RNA -------')
  132. codingFromRNA = dna.getCodingFromRNA(rna)
  133. print(codingFromRNA)
  134. print('')
  135. print('----- FULL TRANSLATION -------')
  136. print(dna.getFullTranslation(rna))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top