Transcription, reverse complement and translation
Reverse complement
DNA strands pair A with T and C with G. To write the reverse complement, complement each base and reverse the order.
from bioinfo_practice import reverse_complement
print(reverse_complement("AAGC")) # GCTTTranscription
For a coding-strand DNA representation, replace T with U to write the corresponding RNA sequence.
from bioinfo_practice import transcribe
print(transcribe("ATGGCTTAA")) # AUGGCUUAATranslate a coding frame
Translation reads groups of three bases, called codons. The bundled function uses the standard genetic code, accepts frame 0, 1 or 2, requires complete codons, and stops at the first stop codon.
from bioinfo_practice import translate
print(translate("ATGGCTTAA")) # MA*Frame is essential: starting at index 0, 1 or 2 yields different codons. This example assumes the supplied sequence is already the coding strand in the intended frame. A DNA sequence alone does not establish its strand, gene boundaries or genetic code.
Exercises
- Translate
ATG GCT TAA. - What is the reverse complement of
AAGC? - Why is
ATGAArejected by this translator?
Worked answers
MA*; GCTT; the length is not divisible by three in the chosen frame, so the final partial codon cannot be translated by this simple function.