| name | transcription-translation |
| description | Transcribe DNA to RNA (and back), translate coding sequences to protein using NCBI codon tables, and pick the right genetic code for mitochondria, plastids, or non-standard organisms. |
| license | MIT |
Transcription and Translation
Hard rules
- No fabricated citations. Every cited work must resolve to a verifiable
- No claim without provenance. Every quantitative or factual claim
- No silent failure. Every script invocation, API call, or tool use must declare its exit status and what to do on non-zero. A skill that silently swallows errors is a violation.
When to use
- mRNA from a coding sequence.
- Protein sequence from a CDS (or whole genome, for prokaryotes).
- Reverse transcription (mRNA → cDNA, U → T).
- Verifying that a predicted ORF really is a CDS (no internal stops, correct frame).
When NOT to use
- Gene finding (de novo ORF detection) → use
pyrodigal, prodigal, or MetaGeneAnnotator.
- Genome annotation → use
bakta or prokka.
- For translation with frameshifts / selenocysteine → custom logic with NCBITSite.
Prerequisites
Core workflow
- Pick the codon table — NCBI table 1 is the standard genetic code.
- Get the CDS — either a feature from GenBank, or your own extracted ORF.
- Translate with
cds=True if you want validation; cds=False for "translate whatever".
- Verify — length divisible by 3, no internal stops (or stops are expected for selenocysteine / pyrrolysine).
NCBI codon tables (most common, 2026)
| ID | Name | Use |
|---|
| 1 | Standard | Most organisms |
| 2 | Vertebrate Mitochondrial | Human mtDNA, mouse mtDNA |
| 3 | Yeast Mitochondrial | S. cerevisiae mtDNA |
| 4 | Mold / Protozoan / Coelenterate Mitochondrial | Invertebrate mtDNA |
| 5 | Invertebrate Mitochondrial | Many invertebrate mtDNAs |
| 6 | Ciliate Nuclear | Tetrahymena, Paramecium |
| 11 | Bacterial, Archaeal and Plant Plastid | Chloroplasts, bacteria |
Full list: https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
Code patterns
Basic transcription and translation
from Bio.Seq import Seq
coding_dna = Seq("ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG")
mrna = coding_dna.transcribe()
protein = coding_dna.translate()
Strict CDS validation (cds=True)
protein = coding_dna.translate(cds=True)
This raises Bio.Data.CodonTable.TranslationError if:
- Length is not a multiple of 3.
- The CDS doesn't start with ATG.
- The CDS doesn't end with a stop codon (TAA, TAG, TGA).
For mitochondrial code (table 2), stop codons are different (AGA, AGG, TAA, etc.):
protein = coding_dna.translate(table=2, cds=True)
Reverse transcription (mRNA → cDNA)
mrna = Seq("AUGGCCAUUGUAA")
cdna = mrna.back_transcribe()
Translate a non-standard genetic code
protein = coding_dna.translate(table=2)
protein = coding_dna.translate(table=3)
Translate to stop (drop the trailing stop)
protein = coding_dna.translate(to_stop=True)
Translate with full table object
from Bio.Data import CodonTable
std = CodonTable.unambiguous_dna_by_id[1]
mt = CodonTable.unambiguous_dna_by_id[2]
print(std.stop_codons)
print(mt.stop_codons)
print(std.start_codons)
Extract CDS from GenBank and translate
from Bio import SeqIO
rec = next(SeqIO.parse("chr1.gb", "genbank"))
for feat in rec.features:
if feat.type == "CDS":
nt = feat.extract(rec.seq)
protein = nt.translate(cds=True)
print(feat.qualifiers.get("gene", ["?"])[0], protein[:30])
Six-frame translation (for ORF finding)
def six_frames(seq: str, table: int = 1) -> list[str]:
from Bio.Seq import Seq
s = Seq(seq)
rc = s.reverse_complement()
return [str(s[i:].translate(table=table)) for i in range(3)] + \
[str(rc[i:].translate(table=table)) for i in range(3)]
Validate a predicted ORF
def validate_cds(seq: str, table: int = 1) -> bool:
from Bio.Seq import Seq
s = Seq(seq)
if len(s) % 3 != 0:
return False
if not s.upper().startswith("ATG"):
return False
try:
s.translate(table=table, cds=True)
return True
except Exception:
return False
Common pitfalls
- Translating raw genomic DNA. Eukaryotic genes have introns. Use the CDS feature, not the whole gene.
- Wrong codon table for mitochondria. In vertebrate mtDNA, AGA and AGG are stops, not Arg. In standard code, they code for Arg.
cds=True is strict. A genuine prokaryotic CDS that uses GTG as a start will fail. Use cds=False if you allow alternative starts.
- Frame confusion. A 900 bp CDS is 300 aa. If you get 297 or 303, your frame is off by 1.
- Forgetting
to_stop=True leaves the stop codon as * in the protein. Decide whether you want it.
Validation
- Length of protein ≈ length of CDS / 3.
- First amino acid is
M (or fM in mitochondria).
- Last character is
* if you didn't use to_stop=True.
- For a real CDS, no internal
*.
Open alternatives
| Need | Tool |
|---|
| Gene finding (prokaryotic) | pyrodigal, prodigal |
| Genome annotation | bakta, prokka |
| Codon usage bias | Bio.SeqUtils.CodonUsage (see codon-usage skill) |
| Six-frame ORF display | EMBOSS getorf, ORFfinder |
References
Changelog
- 1.0.0 (2026-06-10): Initial adaptation by Pradyumna Jayaram from
bio-transcription-translation (bioSkills-main/sequence-manipulation/transcription-translation).
Cross-references
Other skills in this category:
- batch-processing
- bowtie2-alignment
- bwa-alignment
- bwa-mem2-alignment
- codon-usage
- compressed-sequence-files
- fastq-quality-scores
- filter-sequences
- format-conversion
- hisat2-alignment
- motif-search
- paired-end-fastq
- pysam-genomics
- read-write-sequences
- reverse-complement
- sam-bam-basics
- samtools-bam-processing
- seq-objects
- sequence-properties
- sequence-slicing
- sequence-statistics
- star-alignment