/data-science:bio-restriction-golden-gate-assemblyfrom data-science
Design and validate Type IIS scarless DNA assembly (Golden Gate, MoClo) using Biopython Bio.Restriction. Screens parts for internal BsaI/BsmBI/BbsI/SapI sites, previews fusion overhangs, and validates overhang sets for distinctness and fidelity.
Ships in data-science. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Reference examples tested with: BioPython 1.83+ (API verified on 1.86)
Before using code patterns, verify installed versions match. If versions differ:
pip show biopython then help(Bio.Restriction.BsaI.search) to confirm the search APIIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Design (or check) my Golden Gate assembly" -> Make each part free of the assembly enzyme's internal sites, and give every junction a distinct, well-behaved fusion overhang, so one tube of enzyme plus ligase builds the construct directionally and scarlessly.
Bio.Restriction to find internal Type IIS sites and read the overhang a cut exposes; the overhang-set rules are sequence logic, not a database call.The whole method rests on one property: a Type IIS enzyme cuts outside its recognition sequence, so the 4-nt overhang it leaves is set by the user's flanking DNA, and the recognition site is placed to be removed from the final product. Because the ligated junction no longer contains the site, the enzyme cannot re-cut it, so digestion and ligation run together in one pot. Two design obligations follow, and both are what this skill checks: (1) domestication -- no part may contain an internal copy of the assembly enzyme's site, or it will be fragmented during assembly; (2) a set of distinct, non-palindromic fusion overhangs -- one per junction -- so parts assemble in exactly one order.
| Enzyme | Recognition | Overhang | Typical role |
|---|---|---|---|
| BsaI (Eco31I) | GGTCTC(1/5) | 4 nt 5' | The default Golden Gate / MoClo Level 1 enzyme; BsaI-HFv2 for fidelity |
| BsmBI (Esp3I) | CGTCTC(1/5) | 4 nt 5' | MoClo Level 0 / Level 2 (alternates with BsaI between levels) |
| BbsI (BpiI) | GAAGAC(2/6) | 4 nt 5' | Alternative when BsaI/BsmBI sites cannot be domesticated out |
| SapI (LguI) | GCTCTTC(1/4) | 3 nt 5' | 3-nt (codon-length) overhangs for reading-frame-preserving fusions |
Hierarchical systems (MoClo, Golden Braid) alternate enzymes between levels so each assembly round removes the previous level's sites: assemble Level 0 -> 1 with one enzyme, 1 -> 2 with the other. Pick the level's enzyme first, then domesticate every part against it.
| Golden Gate (Type IIS) | Classic restriction-ligation (Type IIP) | Gibson assembly | |
|---|---|---|---|
| Junction defined by | user-designed 4-nt overhang (3 for SapI) | the enzyme's fixed overhang | ~20-40 bp designed homology |
| Scar | none (site removed from product) | a restriction-site scar at each junction | none |
| Reaction | one-pot, one-step (37/16 C cycling) | sequential digest -> purify -> ligate | isothermal 50 C |
| Fragments per reaction | many (20-30+, more with optimized sets) | few | several |
| Main constraint | domestication; distinct overhang set | needs available compatible sites | terminal homology only |
Choose Golden Gate when assembling several parts repeatedly from a standardized library; classic digestion for a one-off two-piece clone with convenient sites; Gibson when parts cannot be domesticated or no site layout works.
Goal: Confirm a part carries no internal copy of the assembly enzyme's site (on either strand), and locate any that must be removed.
Approach: enzyme.search(seq) finds Type IIS sites on both strands (the recognition sequence is asymmetric, so its reverse-complement is detected too). Any hit inside a part is a defect to silently mutate away.
from Bio import SeqIO
from Bio.Restriction import BsaI, BsmBI, BbsI, SapI
record = SeqIO.read('part.fasta', 'fasta')
for enzyme in (BsaI, BsmBI, BbsI, SapI):
hits = enzyme.search(record.seq) # both strands; recognition site is asymmetric
status = 'clean' if not hits else f'{len(hits)} internal site(s) at {hits} -> domesticate'
print(f'{enzyme} ({enzyme.site}): {status}')
Goal: Remove an internal site from a coding part without changing the protein.
Approach: Anchor on the recognition sequence itself (on both strands), not the cut position -- a Type IIS enzyme cuts outside its site, so mutating the codon at the cut would not touch the site. Walk the codons overlapping each recognition-site occurrence, swap one for a synonymous codon that breaks the site, and assert the protein is unchanged. This needs the reading frame.
from Bio.Data import CodonTable
from Bio.Seq import Seq
def domesticate_cds(cds, enzyme, frame=0):
'''Remove an enzyme's internal sites from a CDS by synonymous codon swaps (reading frame `frame`).'''
table = CodonTable.unambiguous_dna_by_id[1]
syn = {}
for codon, aa in table.forward_table.items():
syn.setdefault(aa, []).append(codon)
s = list(str(cds).upper())
end = frame + 3 * ((len(s) - frame) // 3)
protein = str(Seq(''.join(s[frame:end])).translate())
site = str(enzyme.site)
motifs = (site, str(Seq(site).reverse_complement())) # both strands; Type IIS sites are unambiguous
for _ in range(len(s)):
seqstr = ''.join(s)
if not enzyme.search(Seq(seqstr)):
break
hit = max(seqstr.find(m) for m in motifs) # a recognition-site start (either strand)
for ci in range(((hit - frame) // 3) * 3 + frame, hit + len(site), 3):
if ci < frame or ci + 3 > len(s):
continue
codon = ''.join(s[ci:ci + 3])
alt = next((a for a in syn.get(table.forward_table.get(codon), ())
if a != codon and not enzyme.search(Seq(''.join(s[:ci] + list(a) + s[ci + 3:])))), None)
if alt:
s = s[:ci] + list(alt) + s[ci + 3:]
break
assert str(Seq(''.join(s[frame:end])).translate()) == protein # protein unchanged
return Seq(''.join(s))
# A site that overlaps only Met/Trp codons (no synonyms) is rare but cannot be silently broken;
# always confirm the result is clean: assert not enzyme.search(domesticate_cds(cds, enzyme))
Goal: Read the actual 4-nt overhang each Type IIS cut would leave, to confirm junctions match as designed.
Approach: Anchor on the literal forward recognition sequence so only forward-oriented sites are read (a reverse-oriented site cuts on the other side and would otherwise return a misleading overhang). The 5' overhang starts fst5 bases after the recognition-site start.
from Bio.Restriction import BsaI
def forward_overhangs(seq, enzyme=BsaI, width=4):
'''4-nt overhangs at FORWARD-oriented Type IIS sites, anchored on the recognition sequence.'''
s, site, out = str(seq).upper(), str(enzyme.site), []
i = s.find(site)
while i >= 0:
cut = i + enzyme.fst5 # top-strand cut offset from the site start
out.append(s[cut:cut + width])
i = s.find(site, i + 1)
return out
# Reverse-oriented sites cut on the other side; for a full construct, design the overhangs
# explicitly (below) rather than inferring every one from sequence.
Goal: Check that the overhangs chosen for all junctions assemble uniquely and ligate efficiently.
Approach: Apply the design rules: every overhang distinct; none palindromic (self-ligates); no overhang equal to the reverse complement of another (cross-ligates); avoid all-identical bases. High-throughput ligation-fidelity data (Potapov 2018) underlies curated high-fidelity sets used for large assemblies.
from Bio.Seq import Seq
def validate_overhang_set(overhangs):
issues = []
if len(set(overhangs)) != len(overhangs):
issues.append('duplicate overhangs (parts assemble ambiguously)')
for o in overhangs:
if o == str(Seq(o).reverse_complement()):
issues.append(f'{o} is palindromic (self-ligates)')
if len(set(o)) == 1:
issues.append(f'{o} is a homopolymer (low ligation fidelity)')
rc = {o: str(Seq(o).reverse_complement()) for o in overhangs}
for a in overhangs:
for b in overhangs:
if a != b and rc[a] == b:
issues.append(f'{a} is the reverse complement of {b} (cross-ligates)')
return issues or ['overhang set OK']
print(validate_overhang_set(['AATG', 'GCTT', 'TACT', 'GGGG']))
| Symptom | Cause | Fix |
|---|---|---|
| Assembly drops or scrambles a part | An internal Type IIS site fragmented it | Domesticate every part against the level's enzyme before assembly |
| Junctions ligate in the wrong order or orientation | Two junctions share an overhang, or one is the reverse complement of another | Use a distinct, non-self-complementary overhang per junction; check with validate_overhang_set |
| Empty or low-efficiency assembly | Palindromic or homopolymer overhang, or wrong enzyme/buffer cycling | Avoid palindromic/homopolymer overhangs; cycle 37/16 C with a Type IIS enzyme + T4 ligase |
search() misses a reverse-oriented site | Site too close to the sequence end so the cut falls off it | Domesticate on the full part in context, not a trimmed fragment |
| Recognition site still present in the product | Site placed so the cut does not remove it | Orient Type IIS sites so cleavage excises them from the assembled junction |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub hackernoon/cuttlefish-agent-skills --plugin data-science599 skills in this plugin
/airflow-dag-patternsBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs./ai-traffic-trackingCompatibility pointer for AI assistant referrals and generative search visibility; maintained in Open Analytics./analytics-trackingCompatibility pointer for GA4 event, key-event and User-ID tracking; maintained in Open Analytics.Other plugins' skills for the same job