reverse-complement
Skill8 starsChanged 5 months agoMITView on GitHub
Compute reverse complements, complements, and strand-aware operations on DNA/RNA — including IUPAC ambiguity support, batch processing, and the orientation trap.
In this repository125 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/AGENTS.mdAGENTS.md
- batch-processingSkill
- bowtie2-alignmentSkill
- bwa-alignmentSkill
- bwa-mem2-alignmentSkill
- codon-usageSkill
- compressed-sequence-filesSkill
- fastq-quality-scoresSkill
- filter-sequencesSkill
- format-conversionSkill
- hisat2-alignmentSkill
- motif-searchSkill
- paired-end-fastqSkill
- pysam-genomicsSkill
- read-write-sequencesSkill
- sam-bam-basicsSkill
- samtools-bam-processingSkill
- seq-objectsSkill
- sequence-propertiesSkill
- sequence-slicingSkill
- sequence-statisticsSkill
- star-alignmentSkill
- transcription-translationSkill
- academic-cvSkill
- faculty-interviewSkill
- fellowship-applicationSkill
- industry-transitionSkill
- negotiationSkill
- tenure-dossierSkill
- admet-predictionSkill
- conformer-generationSkill
- covalent-designSkill
- docking-rescoringSkill
- free-energy-calculationsSkill
- generative-designSkill
- molecular-descriptorsSkill
- molecular-ioSkill
- molecular-standardizationSkill
- pharmacophore-modelingSkill
- pose-validationSkill
- protac-degradersSkill
- qsar-modelingSkill
- retrosynthesisSkill
- scaffold-analysisSkill
- shape-similaritySkill
- similarity-searchingSkill
- substructure-searchSkill
- virtual-screeningSkill
- snakemake-workflow-engineSkill
- ai-disclosureSkill
- data-privacySkill
- image-integritySkill
- irb-protocolSkill
- ai-detection-awarenessSkill
- ai-disclosure-statementSkill
- scientific-voice-styleSkill
- text-humanizing-editorialSkill
- cellprofiler-pipelinesSkill
- image-analysis-best-practicesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
No fabricated citations: Every cited work must resolve to a verifiable
- Distinctive: line 21
No claim without provenance: Every quantitative or factual claim
- Distinctive: line 22
No silent failure: Every script invocation, API call, or tool use must declare its exit status and what to do on non-zero.
- Very specific: line 166
Strand annotation lost: If you take feature.extract(record.seq), the extracted Seq is a fresh sequence and the feature's strand info is …
- Very specific: line 167
Assuming IUPAC ambiguity in hand-rolled code: Don't write your own s.translate(str.maketrans("ACGT", "TGCA")) — it breaks on N, R, Y, etc.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- metadata:
category: bioinformatics-sequence
oversight: low
version: 1.0.0
author: Pradyumna Jayaram
tags: [bioinformatics-sequence, research]
difficulty: intermediate
-->Reverse Complement and Strand Operations
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
- Computing reverse complements of DNA/RNA for primer/probe design.
- Translating minus-strand genes.
- Converting a feature's coordinates from one strand to the other.
- Building batch reverse-complement pipelines for FASTA/FASTQ.
When NOT to use
- You actually want just the complement (preserving 5'→3' direction) — use
.complement(). - For very high-throughput reverse-complement (millions of reads), use
seqkitorpyfastx.
Prerequisites
biopython>=1.83- For shell-scale:
seqkit seq -r(reverse) andseqkit seq -p(reverse-complement)
Core workflow
- Decide: complement or reverse-complement?
- Use
Bio.Seq's built-in methods (which handle IUPAC ambiguity correctly). - For batch, stream records through a generator.
- Always log a sanity check (e.g., reverse-complement of reverse-complement is the original).
The orientation decision
| You have | You want | Method |
| Coding strand (sense) | mRNA sequence | .transcribe() |
| Coding strand (sense) | Protein | .translate() |
| Template strand (antisense) | Coding strand | .reverse_complement() first, then .transcribe() |
| mRNA | cDNA (T for U) | .back_transcribe() |
| Coding strand, want other strand's sequence | Other strand | .reverse_complement() |
Code patterns
Basic reverse complement
from Bio.Seq import Seq
s = Seq("ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG")
s.reverse_complement()
# Seq('CTATCGGGCACCCTTTCAGCGGCCCATTACAATGGCCAT')Complement (no reversal)
s = Seq("ATGC")
s.complement() # Seq('TACG') — still 5'→3', just base-pairedIUPAC ambiguity is built-in
s = Seq("ATGNRYWSKM")
s.reverse_complement()
# Seq('MKRSWYNCAT') — all ambiguity codes are handledIUPAC complement table:
| A | T | C | G | R | Y | S | W | K | M | B | D | H | V | N |
| T | A | G | C | Y | R | S | W | M | K | V | H | D | B | N |
RNA reverse complement
from Bio.Seq import Seq
rna = Seq("AUGCCAUUG") # 5' → 3' mRNA
rna.reverse_complement_rna() # 5' → 3' of the antisense strandOr transcribe to DNA first:
dna = rna.back_transcribe()
dna.reverse_complement()Reverse-complement every record in a FASTA
from Bio import SeqIO
def rc_records(in_path, out_path):
with open(out_path, "w") as out:
for rec in SeqIO.parse(in_path, "fasta"):
rec.seq = rec.seq.reverse_complement()
rec.id = f"{rec.id}_rc"
rec.description = "reverse complement"
SeqIO.write(rec, out, "fasta")
rc_records("input.fasta", "rc.fasta")Batch with Polars/streaming
from Bio import SeqIO
with open("rc.fasta", "w") as out:
for rec in SeqIO.parse("primers.fasta", "fasta"):
rec.seq = rec.seq.reverse_complement()
SeqIO.write(rec, out, "fasta")Sanity check: revcomp of revcomp is identity
def assert_revcomp_identity(s):
assert s == s.reverse_complement().reverse_complement()Extract a feature and reverse-complement
from Bio import SeqIO
rec = next(SeqIO.parse("chr1.gb", "genbank"))
for feat in rec.features:
if feat.type == "CDS" and feat.location.strand == -1:
nt = feat.extract(rec.seq)
cds = nt.reverse_complement() # now on + strand
print(cds.translate())Reverse-complement a region of a chromosome
def rc_region(record, start, end):
return record.seq[start:end].reverse_complement()Common pitfalls
- Complement instead of reverse-complement. The most common bug. If you're on the minus strand and you call
.complement(), you'll be working on the wrong strand. - Lowercase sequences.
.reverse_complement()works on lowercase; just remember the output is whatever case the input was. - RNA vs DNA.
reverse_complement()is for DNA. For RNA, usereverse_complement_rna()or transcribe first. - Strand annotation lost. If you take
feature.extract(record.seq), the extractedSeqis a fresh sequence and the feature'sstrandinfo is gone. Reverse-complement explicitly when you need to flip strand. - Assuming IUPAC ambiguity in hand-rolled code. Don't write your own
s.translate(str.maketrans("ACGT", "TGCA"))— it breaks onN,R,Y, etc.
Validation
s.reverse_complement().reverse_complement() == s.- The first base of the reverse-complement is the complement of the last base of the input.
- Length is preserved.
- GC content is preserved (
gc_fractionof input and rc are equal).
Open alternatives
| Need | Tool |
| FASTA reverse-complement at scale | seqkit seq -p -r in.fasta |
| FASTX reverse-complement | seqtk seq -r in.fq |
| Reverse-complement in shell pipeline | bioawk -c fastx '{print ">"$name"_rc\n"revcomp($seq)}' in.fasta |
| Reverse-complement on huge genome | pyfastx (C-accelerated) |
References
- Biopython reverse-complement: https://biopython.org/docs/latest/api/Bio.Seq.html
- IUPAC codes: https://www.bioinformatics.org/sms/iupac.html
- Companion:
ors-bioinformatics-sequence-seq-objects,ors-bioinformatics-sequence-transcription-translation.
Changelog
- 1.0.0 (2026-06-10): Initial adaptation by Pradyumna Jayaram from
bio-reverse-complement(bioSkills-main/sequence-manipulation/reverse-complement).
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
- sam-bam-basics
- samtools-bam-processing
- seq-objects
- sequence-properties
- sequence-slicing
- sequence-statistics
- star-alignment
- transcription-translation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

