Created
September 25, 2019 21:09
-
-
Save Maransatto/27c90cf3955501e28ef615737bc68f93 to your computer and use it in GitHub Desktop.
DNA, Coding, Template e RNA e trinca com código genético
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DNA(object): | |
def __init__(self): | |
pass | |
def getSingleTemplate(self, std): | |
if std == 'A': | |
return 'T' | |
elif std == 'T': | |
return 'A' | |
elif std == 'G': | |
return 'C' | |
elif std == 'C': | |
return 'G' | |
def getSingleRNA(self, std): | |
if std == 'A': | |
return 'U' | |
elif std == 'T': | |
return 'A' | |
elif std == 'G': | |
return 'C' | |
elif std == 'C': | |
return 'G' | |
# 6 - Dado uma fita codificante (coding) faça a complementar (template); | |
def getFullTemplate(self, _coding): | |
template = '' | |
for i in _coding: | |
template += self.getSingleTemplate(i) | |
return template | |
# 7 - Dado uma fita complementar(template) encontre a sequência de RNA correspondente; | |
def getFullRNA(self, _type, _input): | |
template = _input | |
rna = '' | |
if _type == 'coding': | |
template = self.getFullTemplate(_input) | |
for i in template: | |
rna += self.getSingleRNA(i) | |
return rna | |
def getCodingFromRNA(self, _rna): | |
return _rna.replace('U','T') | |
def getTranslation(self, _tree_letters): | |
if _tree_letters in ('TTT', 'TTC'): | |
return 'Phe' | |
elif _tree_letters in ('TTA', 'TTG'): | |
return 'Leu' | |
elif _tree_letters in ('TCT', 'TCC', 'TCA', 'TCG'): | |
return 'Ser' | |
elif _tree_letters in ('TAT', 'TAC'): | |
return 'Tyr' | |
elif _tree_letters in ('TGT', 'TGC'): | |
return 'Cys' | |
elif _tree_letters in ('TGG'): | |
return 'Trp' | |
elif _tree_letters in ('CTT', 'CTC', 'CTA', 'CTG'): | |
return 'Leu' | |
elif _tree_letters in ('CCT', 'CCC', 'CCA', 'CCG'): | |
return 'Pro' | |
elif _tree_letters in ('CAT', 'CAC'): | |
return 'His' | |
elif _tree_letters in ('CAA', 'CAG'): | |
return 'Gin' | |
elif _tree_letters in ('CGT', 'CGC', 'CGA', 'CGG'): | |
return 'Arg' | |
elif _tree_letters in ('ATT', 'ATC', 'ATA'): | |
return 'Ile' | |
elif _tree_letters in ('ATG'): | |
return 'Met' | |
elif _tree_letters in ('ACT', 'ACC', 'ACA', 'ACG'): | |
return 'Thr' | |
elif _tree_letters in ('AAT', 'AAC'): | |
return 'Asn' | |
elif _tree_letters in ('AAA', 'AAG'): | |
return 'Lys' | |
elif _tree_letters in ('AGT', 'AGC'): | |
return 'Ser' | |
elif _tree_letters in ('AGA', 'AGG'): | |
return 'Arg' | |
elif _tree_letters in ('GTT', 'GTC', 'GTA', 'GTG'): | |
return 'Val' | |
elif _tree_letters in ('GCT', 'GCC', 'GCA', 'GCG'): | |
return 'Ala' | |
elif _tree_letters in ('GAT', 'GAC'): | |
return 'Asp' | |
elif _tree_letters in ('GAA', 'GAG'): | |
return 'Giu' | |
elif _tree_letters in ('GGT', 'GGC', 'GGA', 'GGG'): | |
return 'Gly' | |
else: | |
return False | |
def getFullTranslation(self, _rna): | |
full_translation = [] | |
aminoacidos = [] | |
translation = '' | |
trinca = '' | |
for i in _rna: | |
trinca += i | |
if len(trinca) == 3: | |
single = self.getTranslation(trinca) | |
if single: | |
aminoacidos.append(single) | |
else: | |
if len(aminoacidos) > 0: | |
full_translation.append(aminoacidos) | |
aminoacidos = [] | |
trinca = '' | |
return full_translation | |
dna = DNA() | |
sequence = 'AAAAGGTCCACGCTTTCGCGCCCCGGT' | |
template = dna.getFullTemplate(sequence) | |
print('') | |
print('----- TEMPLATE -------') | |
print(template) | |
print('') | |
rna = dna.getFullRNA(_type='coding', _input=sequence) | |
print('----- RNA -------') | |
print(rna) | |
print('') | |
print('----- CODING FROM RNA -------') | |
codingFromRNA = dna.getCodingFromRNA(rna) | |
print(codingFromRNA) | |
print('') | |
print('----- FULL TRANSLATION -------') | |
print(dna.getFullTranslation(rna)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment