Question: CODE: import random from collections import Counter class Seq: def _ _ init _ _ ( self ) : self.translation _ dict = { '

CODE: import random
from collections import Counter
class Seq:
def __init__(self):
self.translation_dict ={'ttt': 'F','tct': 'S', 'tat': 'Y','tgt': 'C',
'ttc': 'F','tcc': 'S', 'tac': 'Y','tgc': 'C',
'tta': 'L', 'tca': 'S', 'taa': '*', 'tga': '*',
'ttg': 'L','tcg': 'S', 'tag': '*','tgg': 'W',
'ctt': 'L','cct': 'P', 'cat': 'H','cgt': 'R',
'ctc': 'L','ccc': 'P', 'cac': 'H','cgc': 'R',
'cta': 'L', 'cca': 'P', 'caa': 'Q', 'cga': 'R',
'ctg': 'L','ccg': 'P', 'cag': 'Q','cgg': 'R',
'att': 'I', 'act': 'T', 'aat': 'N', 'agt': 'S',
'atc': 'I', 'acc': 'T', 'aac': 'N', 'agc': 'S',
'ata': 'I', 'aca': 'T', 'aaa': 'K', 'aga': 'R',
'atg': 'M', 'acg': 'T', 'aag': 'K', 'agg': 'R',
'gtt': 'V','gct': 'A', 'gat': 'D','ggt': 'G',
'gtc': 'V','gcc': 'A', 'gac': 'D','ggc': 'G',
'gta': 'V', 'gca': 'A', 'gaa': 'E', 'gga': 'G',
'gtg': 'V','gcg': 'A', 'gag': 'E','ggg': 'G'}
def prob(self):
proportion = input("Enter the proportion of A to C (e.g.,1:5 or 5:1): ")
if proportion =="1:5":
self.prob_A =5/6
self.prob_C =1/6
elif proportion =="5:1":
self.prob_A =1/6
self.prob_C =5/6
else:
print("Invalid proportion specified. Please use either '1:5' or '5:1'.")
def generate_rna_sequence(self):
nucleotides =['a','c','g','u']
sequence_length = random.randint(33,333)*3
sequence =''.join(random.choices(nucleotides, weights=[self.prob_A, self.prob_C,0,0], k=sequence_length))
#print(sequence)
return sequence
def translate_sequence(self, sequence, overlap_by_one=False, overlap_by_two=False):
if overlap_by_one:
codons =[sequence[i:i+3] for i in range(0, len(sequence),2)]
elif overlap_by_two:
codons =[sequence[i:i+3] for i in range(0, len(sequence),3)]
else:
codons =[sequence[i:i+3] for i in range(0, len(sequence),3)]
amino_acids =[self.translation_dict[codon] for codon in codons if len(codon)==3]
return amino_acids
def main():
s = Seq()
amino_acid_counts = Counter()
s.prob()
for _ in range(1000):
rna_sequence = s.generate_rna_sequence()
amino_acids = s.translate_sequence(rna_sequence)
amino_acid_counts.update(amino_acids)
total_amino_acids = sum(amino_acid_counts.values())
print("Amino Acid | Count | Relative Frequency")
print("-"*60)
for amino_acid, count in amino_acid_counts.items():
frequency = count / total_amino_acids
full_name =''
if amino_acid =='N':
full_name = 'Asparagine'
elif amino_acid =='Q':
full_name = 'Glutamine'
elif amino_acid =='H':
full_name = 'Histidine'
elif amino_acid =='K':
full_name = 'Lysine'
elif amino_acid =='P':
full_name = 'Proline'
elif amino_acid =='T':
full_name = 'Threonine'
else:
full_name = amino_acid
print(f"{full_name.ljust(17)}|{str(count).ljust(6)}|{frequency:.4f}")
if __name__=="__main__":
main()
Question: Are your results predictive with respect to the overlapping vs. non-overlapping possibilities for the code? To gain insight into this question, you can (re)write your translation method so that it accepts as an argument whether it should overlap by one, overlap by two, or not overlap when translating, and compare your earlier results!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!