The Central Dogma, in one function
DNA → RNA → Protein. This puzzle covers the first arrow: transcription.
Given a coding-strand DNA sequence, produce the corresponding mRNA
sequence by swapping every T for a U. Biopython's Bio.Seq.Seq
class has a .transcribe() method that does exactly this — no
complementing, no reversing, just a base substitution.
from Bio.Seq import Seq
coding_strand = Seq("GATGGAACTTGACTACGTAAATT")
coding_strand.transcribe()
# Seq('GAUGGAACUUGACUACGUAAAUU')
Your task
Fill in transcribe_dna so it:
- Wraps the input string in a
Seq. - Calls
.transcribe(). - Returns the result as a plain
str(the test harness compares strings, notSeqobjects).
Your function will be run once per test case with the DNA sequence piped in on stdin, and your printed output is compared line-for-line against the expected mRNA.
Stretch goal
Nucleotide composition is often reported as %GC content:
Once the puzzle passes, try adding a gc_content(dna: str) -> float
helper and printing it to stderr for your own sequences — it won't be
graded, but it's good practice for the next lesson on variant calling.
Test cases · 3
| # | via | input | expected stdout |
|---|---|---|---|
| 1 | stdin | GATGGAACTTGACTACGTAAATT | GAUGGAACUUGACUACGUAAAUU |
| 2 | stdin | ATGC | AUGC |
| 3 | stdin | TTTTAAAACCCCGGGG | UUUUAAAACCCCGGGG |