seq-objects
Skill8 starsChanged 5 months agoMITView on GitHub
Master the Seq, MutableSeq, and SeqRecord objects — slicing, immutability, ambiguity codes, alphabets, and the 2026 Biopython alphabet deprecation reality.
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
- reverse-complementSkill
- sam-bam-basicsSkill
- samtools-bam-processingSkill
- 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
10 rules. About 0 are common, 3 are distinctive, and 7 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.
7
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 46
Mutate in place with
MutableSeq: only when you really need it. - Very specific: line 47
Convert back to
str: only at the file boundary or the Bio.* API edge. - Very specific: line 73
If you're on older code that imports Bio.Alphabet, you'll see deprecation warnings.
- Very specific: line 158
When in doubt about orientation, always use reverse_complement() to get back to "5' to 3' on the opposite strand".
- Very specific: line 185
Complement vs reverse-complement confusion: Use .reverse_complement() for mRNA/cDNA work, not .complement().
- Very specific: line 188
In-place edits to a record's
.seqdon't update features: If you mutate the Seq, the feature coordinates may no longer match. - Very specific: line 194
After MutableSeq → Seq, the new Seq is truly immutable (you can't assign s[0] = "A").
≈ “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
-->Biopython Seq and SeqRecord Objects
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
- Wrapping a plain Python string as a biological sequence.
- Slicing and indexing with biological semantics (
.complement(),.reverse_complement()). - Carrying per-record metadata: ID, description, annotations, features, dbxrefs.
- In-place edits via
MutableSeq.
When NOT to use
- Plain string manipulation — use Python str.
Seqis for biology. - Massive-scale sequence ops → use
pyfastxorparasailfor kernels. - File-level work → see
ors-bioinformatics-sequence-read-write-sequences.
Prerequisites
biopython>=1.83
Core workflow
- Create a
Seqfrom a string. - Index / slice like a string.
- Wrap in a
SeqRecordfor I/O, feature handling, and metadata. - Mutate in place with
MutableSeqonly when you really need it. - Convert back to
stronly at the file boundary or the Bio.* API edge.
Code patterns
Construct a Seq
from Bio.Seq import Seq
"
s = Seq("ACGTACGT")
print(s.complement()) # TGCATGCA
print(s.reverse_complement()) # TACGTACG... actually ACGTACGT (palindrome in this case)The IUPAC ambiguity alphabet (2026 reality)
Since Biopython 1.80, alphabet objects are deprecated. The new API is the
Bio.Seq + Bio.SeqUtils functions, which assume IUPAC by default:
from Bio.Seq import Seq
s = Seq("ACGTNRYWSKMBDHV") # 15 IUPAC codes
print(s.complement()) # full IUPAC complement tableIf you're on older code that imports Bio.Alphabet, you'll see deprecation
warnings. Migrate to:
# Old
from Bio.Alphabet import IUPAC
s = Seq("ACGT", IUPAC.unambiguous_dna)
# New
s = Seq("ACGT") # assumed unambiguous DNAMutableSeq — in-place editing
from Bio.Seq import MutableSeq
m = MutableSeq("ACGTACGT")
m[3] = "N"
print(m) # ACGNACGT
m.reverse()
print(m) # TGCANGCAConvert back to immutable with:
s = m.toseq()SeqRecord with metadata
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
rec = SeqRecord(
Seq("ATGAAATAA"),
id="seq1",
name="seq1",
description="example cDNA",
annotations={"molecule_type": "mRNA", "organism": "Homo sapiens"},
dbxrefs=["Project:PRJNA1"],
)Add features to a SeqRecord
from Bio.SeqFeature import SeqFeature, FeatureLocation, BeforePosition, AfterPosition
cds = SeqFeature(
location=FeatureLocation(0, 9, strand=1),
type="CDS",
qualifiers={"gene": ["ABC1"], "transl_table": [1]},
)
rec.features.append(cds)Slicing semantics
s = Seq("ACGTACGT")
s[2:5] # 'GTA' (Seq, not str)
s[0:3:2] # 'AG' (step)
s[-3:] # 'CGT' (Seq, supports negative indexing)Concatenation
Seq("ACGT") + Seq("AAAA")
# Seq('ACGTAAAA')
# Don't concat SeqRecord — use Biopython's `concat` carefullyComplement vs reverse-complement — the 5'/3' mental model
s = Seq("ATGC")
s.complement() # TACG (still 5'→3' but antiparallel)
s.reverse_complement() # GCAT (5'→3' of the opposite strand)When in doubt about orientation, always use reverse_complement() to get
back to "5' to 3' on the opposite strand". The plain .complement() keeps
the original coordinate frame.
Translate, transcribe
coding_dna = Seq("ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG")
coding_dna.transcribe() # mRNA (U for T)
coding_dna.translate() # MAIVMGR* — uses table 1
coding_dna.translate(table="Vertebrate Mitochondrial")
coding_dna.translate(to_stop=True) # 'MAIVMGR'Equality and hashing
Seq hashes to the same value as the underlying string. Two Seq("ACGT")
from different alphabets compare equal in 1.83+.
Seq("ACGT") == "ACGT" # True
hash(Seq("ACGT")) == hash("ACGT") # TrueCommon pitfalls
Seqis not astrin some methods. Some stdlib functions ("".join(...)) will reject it. Cast withstr(s)when in doubt.- Complement vs reverse-complement confusion. Use
.reverse_complement()for mRNA/cDNA work, not.complement(). - Translating genomic DNA directly. Eukaryotic genes have introns — don't translate raw genomic DNA. Use
feature.extract(rec.seq).translate()for CDS features. - MutableSeq leaks. Convert back to
Seqwithm.toseq()before handing the object to a function that assumes immutability. - In-place edits to a record's
.seqdon't update features. If you mutate theSeq, the feature coordinates may no longer match.
Validation
len(rec.seq) == len(str(rec.seq)).record.seq == record.seqround-trip identity.- After
MutableSeq→Seq, the newSeqis truly immutable (you can't assigns[0] = "A").
Open alternatives
| Need | Tool |
| Pure-Python DNA ops | primer3-py.calc_hairpin, custom code |
| Fast string ops | pyfastx.Fasta (C-accelerated) |
| RNA secondary structure | ViennaRNA (python-RNA bindings) |
| Protein sequences | Bio.Seq + Bio.SeqUtils.ProtParam |
References
- Biopython
Seqtutorial: https://biopython.org/docs/latest/Tutorial.html#chapter3 - IUPAC codes: https://www.bioinformatics.org/sms/iupac.html
- Companion:
ors-bioinformatics-sequence-reverse-complement,ors-bioinformatics-sequence-transcription-translation.
Changelog
- 1.0.0 (2026-06-10): Initial adaptation by Pradyumna Jayaram from
bio-seq-objects(bioSkills-main/sequence-manipulation/seq-objects).
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
- 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.

