I need to generate 3 frames(1,2,3) for the cDNA (top) strand and 3 frames(4,5,6) for the complementary (bottom) strand. so the code should go through every 3 letters in the strands and find its corresponding amino acid from a file. for the bottom strand, this translation should occur backward (from right to left) to generate the frames. based on my understanding from the picture, to generate frame 5, the last 2 letters(on the right) in the complementary strand should be skipped and the translation should start from the last third letter backward, and for frame 6, only the last letter in the complementary strand should be skipped. I am struggling with how to code for frames 5 and 6. Could you please help me with how to write the code? note: the picture only shows two chunks of the strands. the actual length is 1170 letters.
I have tried many ways but none of them generated the correct frame. for example, I used this code to generate frame 5:
def translate_complementary_frame5(complementary_strand, codon_table):
protein_sequence = ''
for i in range(2, len(complementary_strand)):
if i % 3 == 2:
codon = complementary_strand[i-2:i+1][::-1]
amino_acid = codon_table[codon]
protein_sequence += amino_acid
return protein_sequence
protein_sequence_frame5 = translate_complementary_frame5(complementary_strand, codon
Thank you for your reply. Unfortunately, I have to write the codes myself for my project and cannot use any function from BioPython.
Is that a requirement for an academic project or examination?
yes, it is. I have to write a program that generates 6 reading frames for a given cDNA.
And you're absolutely sure you cannot use BioPython - as in, "do not use existing tools" is an explicitly stated request? If not, I'd check with your professor - reinventing the wheel is not a great way to test people, although this is a borderline worth-it sort of exercise.
this is what it says in the instructions: "You must not use pre-existing modules from BioPython or other repositories."