primer-design/primer-validation/SKILL.md
Validates chosen PCR/qPCR oligos for intramolecular thermodynamic liabilities with primer3-py - hairpins, self-dimers, cross-dimers (calc_hairpin/homodimer/heterodimer), and 3'-end stability (calc_end_stability) - returning ThermoResult dG/Tm and ASCII structures. Covers why a "dimer-free" verdict is a PREDICTION at the supplied salt/Mg/dNTP/oligo conditions and temp_c (so the same primer is fine or dimer-prone depending on conditions), why a 3'-END dimer or hairpin is the lethal class (polymerase-extendable into primer-dimer) so structures are ranked by dG at the annealing temperature and 3'-end involvement rather than global Tm, that ThermoResult dG is in cal/mol not kcal/mol, and that .structure_found must gate the numbers. Use when checking primer pairs before ordering, troubleshooting primer-dimers or smears, or screening oligos for secondary structure. Genome off-target/mispriming is primer-specificity; design is primer-basics; probe assays are qpcr-primers.
npx skillsauth add GPTomics/bioSkills bio-primer-design-primer-validationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference examples tested with: primer3-py 2.3+.
Before using code patterns, verify installed versions match. If versions differ:
pip show primer3-py then help(primer3.calc_heterodimer) to check signaturesIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Are these primers free of dimers and hairpins?" -> Predict the most stable intramolecular and inter-primer structures and judge them at the reaction conditions -- because a structure's harm is set by its dG at the annealing temperature and by whether it ties up the 3' end, not by a single global score.
primer3.calc_hairpin(seq), calc_homodimer(seq), calc_heterodimer(seq1, seq2), calc_end_stability(seq1, seq2) return a ThermoResult with .tm, .dg, .structure_found.Scope: thermodynamic validation of the OLIGOS themselves (hairpin, homodimer, heterodimer, 3'-end stability, pair Tm match) under stated conditions. Genome-wide off-target / mispriming / in-silico PCR -> primer-specificity. Designing primers -> primer-basics. qPCR primer+probe co-design -> qpcr-primers.
calc_hairpin/calc_homodimer/calc_heterodimer compute a dG/Tm under a specific monovalent/divalent/dNTP/oligo concentration and an evaluation temperature (temp_c). The same primer can read "fine" at default 37 C / default salt and "dimer-prone" at the real annealing temperature and Mg2+. Validate at the conditions and temp_c of the actual reaction, or the verdict is decorative.calc_end_stability and the ASCII structure) and judge at the annealing temperature.ThermoResult.dg, .dh are in cal/mol (and .ds in cal/(K.mol)) -- a value of -6000 is -6 kcal/mol, so divide by 1000 before comparing to kcal/mol heuristics. Always check .structure_found first: if no structure formed, the .tm/.dg are not a real duplex.| Function | Citation | Mechanism / role | When |
|----------|----------|------------------|------|
| calc_hairpin(seq) | Untergasser 2012 Nucleic Acids Res 40:e115 | most stable self-fold via thermodynamic alignment (ntthal) | screen a single primer/probe for hairpins |
| calc_homodimer(seq) | Untergasser 2012 Nucleic Acids Res 40:e115 | most stable self-self duplex | self-dimer of one oligo |
| calc_heterodimer(s1, s2) | Untergasser 2012 Nucleic Acids Res 40:e115 | most stable cross duplex of two oligos | forward-vs-reverse (and probe) cross-dimer |
| calc_end_stability(s1, s2) | SantaLucia & Hicks 2004 Annu Rev Biophys 33:415 | dG of the 3' end of s1 annealing to s2 | the 3'-anchored, extendable-dimer question |
| calc_*_tm (float) | Untergasser 2012 Nucleic Acids Res 40:e115 | the .tm only, no structure object | fast high-throughput screening |
| calc_tm(seq) | SantaLucia 1998 PNAS 95:1460 | nearest-neighbor Tm vs perfect complement | the pair Tm-match check |
| Scenario | Recommended | Why |
|----------|-------------|-----|
| Standard pre-order check of a pair | calc_hairpin/homodimer on each + calc_heterodimer on the pair, at reaction conditions and temp_c = Ta | the four-call panel that catches self-structure |
| Suspect a primer-dimer artifact (gel, low-Tm melt peak) | calc_heterodimer + calc_end_stability, read the ASCII structure for 3'-end pairing | 3'-end dimers are extendable; that is the artifact source. A dimer that appears only at LOW template is diagnostic -- with scarce target, primer-primer collisions win the kinetic competition |
| Screening hundreds of oligos | calc_hairpin_tm/calc_homodimer_tm (floats) | fast triage; promote flagged ones to full ThermoResult |
| One primer designed with a 5' tail | run the calls on the FULL tailed oligo | the tail exists physically (palindromic sites/Gibson arms dimerize) |
| Pair anneals unevenly / one strand dominates | compare calc_tm of the two primers | a Tm mismatch >2-3 C, not a dimer, is the cause |
| "Will it amplify only the target?" | -> primer-specificity | that is genome off-target, a different question and toolset |
Default when uncertain: run the four-call panel at the real salt/Mg/dNTP/oligo concentrations with temp_c set to the annealing temperature, flag any structure whose dG is strongly negative at Ta, and weight 3'-end involvement most.
Goal: Decide whether a chosen forward/reverse pair will misbehave through hairpins or dimers in the actual reaction, with the 3' end weighted appropriately.
Approach: Run hairpin and homodimer on each primer and heterodimer on the pair, all at the reaction's salt/Mg/dNTP/oligo concentrations and with temp_c set to the annealing temperature; gate every result on .structure_found; additionally compute calc_end_stability on the heterodimer to expose 3'-anchored (extendable) dimers; compare the two primer Tms for a match.
import primer3
fwd, rev = 'GTCTCCTCTGACTTCAACAGCG', 'ACCACCCTGTTGCTGTAGCCAA'
COND = dict(mv_conc=50.0, dv_conc=3.0, dntp_conc=0.8, dna_conc=250.0, temp_c=60.0) # match the qPCR/PCR reaction + Ta
def flag(label, res):
if res.structure_found:
print(f'{label}: Tm={res.tm:.1f}C dG={res.dg/1000:.2f} kcal/mol') # dg is cal/mol -> /1000
else:
print(f'{label}: no structure')
for name, seq in [('fwd', fwd), ('rev', rev)]:
flag(f'{name} hairpin', primer3.calc_hairpin(seq, **COND))
flag(f'{name} homodimer', primer3.calc_homodimer(seq, **COND))
flag('heterodimer', primer3.calc_heterodimer(fwd, rev, **COND))
end = primer3.calc_end_stability(fwd, rev, **COND) # 3'-end-anchored stability = the extendable-dimer risk
print(f"3'-end stability dG={end.dg/1000:.2f} kcal/mol")
dtm = abs(primer3.calc_tm(fwd, **{k: COND[k] for k in ('mv_conc','dv_conc','dntp_conc','dna_conc')})
- primer3.calc_tm(rev, **{k: COND[k] for k in ('mv_conc','dv_conc','dntp_conc','dna_conc')}))
print(f'pair Tm difference={dtm:.1f}C')
ThermoResult.dg is in cal/mol (divide by 1000 for kcal/mol). More negative = more stable = more concerning. But two structures with similar Tm can have very different dG at the annealing temperature, and the structure's own Tm is just where its dG crosses zero -- so judge by dG at temp_c = Ta, not by Tm. Print res.ascii_structure (or res.ascii_structure_lines) to SEE where the duplex sits: a dimer that pairs the recessed 3' ends is extendable and disqualifying even at modest dG, while a stronger structure with free 5'/internal pairing only transiently lowers free primer. calc_end_stability(fwd, rev) isolates exactly the 3'-end-of-fwd-against-rev stability, which is the right number for "will this dimer extend." It scores the 3' end of the FIRST argument, so check both directions (also calc_end_stability(rev, fwd)) -- either primer's 3' end can anchor the extendable dimer.
Trigger: Accepting/rejecting a structure on its overall dG or Tm. Mechanism: a weak dimer that locks the 3' ends is extended into artifact, while a strong dimer with free 3' ends is benign. Symptom: a "passing" pair still produces primer-dimer; a "failing" pair amplifies fine. Fix: inspect 3'-end involvement (calc_end_stability, ASCII structure) and weight it above whole-molecule dG.
Trigger: Using default temp_c=37 and default salt instead of the reaction's Ta and Mg2+. Mechanism: structure stability is strongly condition-dependent; a structure that melts below Ta is harmless. Symptom: false alarms (or false passes) that do not match the bench. Fix: set temp_c to the annealing temperature and pass the real mv/dv/dntp/dna concentrations.
Trigger: Reading .dg/.tm without checking .structure_found. Mechanism: when no structure forms the fields are not a real duplex. Symptom: nonsense or contradictory numbers. Fix: gate every result on .structure_found before reporting.
Trigger: Comparing .dg directly to a kcal/mol threshold. Mechanism: primer3-py reports dG in cal/mol, so -6000 is -6 kcal/mol. Symptom: thresholds off by 1000x; everything looks catastrophic or fine. Fix: divide .dg by 1000 before comparing.
Trigger: Checking the template-binding portion of a primer that carries a 5' tail. Mechanism: the full oligo (tail included) is what physically exists; palindromic restriction sites and complementary Gibson arms dimerize. Symptom: clean validation, dimers on the bench. Fix: run the calls on the FULL tailed oligo.
These are FLAGGING heuristics for inspection, not hard cutoffs; they are condition-dependent (salt, Mg2+, primer concentration, Ta). Read the structure and judge at Ta before accepting or rejecting.
| Threshold | Source | Rationale |
|-----------|--------|-----------|
| Hairpin Tm at least ~10 C below Ta | SantaLucia & Hicks 2004 Annu Rev Biophys 33:415 | a hairpin that melts well below the anneal step is largely denatured |
| Dimer dG flag if more negative than ~ -6 to -9 kcal/mol | -- | common practice line; below ~ -9 generally rejected; condition-dependent |
| 3'-END dimer dG: be stricter, flag ~ -3 to -5 kcal/mol | Kwok 1990 Nucleic Acids Res 18:999 | 3'-anchored dimers are extendable, so weight them above global dG |
| Pair Tm difference <= 2 C | Koressaar & Remm 2007 Bioinformatics 23:1289 | matched Tm so both primers anneal at one Ta |
| Evaluate at temp_c = annealing temperature | SantaLucia & Hicks 2004 Annu Rev Biophys 33:415 | dG at Ta, not at 37 C, is the harm-relevant quantity |
| Error / symptom | Cause | Solution |
|-----------------|-------|----------|
| AttributeError: calcHeterodimer | camelCase deprecated since primer3-py 1.0.0 | use snake_case calc_heterodimer |
| Validation disagrees with the bench | default temp_c/salt, not the real reaction | pass reaction mv/dv/dntp/dna and temp_c = Ta |
| A "clean" pair still makes primer-dimer | judged by global dG, missed the 3' end | check calc_end_stability and the ASCII structure |
| dG threshold seems 1000x off | .dg is cal/mol, not kcal/mol | divide by 1000 before comparing |
| .tm/.dg look meaningless | no structure formed | gate on .structure_found |
| Pair amplifies one strand only | Tm mismatch, not a dimer | compare calc_tm of the two primers; redesign Tm-matched (primer-basics) |
tools
End-to-end CLIP-seq pipeline from FASTQ to ENCODE-compliant binding sites, single-nucleotide crosslink maps, annotation, motifs, and (optionally) differential binding. Use when running the full Yeo lab eCLIP / iCLIP / iCLIP2 / iCLIP3 / irCLIP / PAR-CLIP analysis with SMInput control, protocol-specific UMI extraction, ENCODE STAR parameters, CLIPper or Skipper peak calling with stringent log2 FC and -log10 p thresholds, IDR rescue and self-consistency QC, and downstream motif registration with mCross or PEKA.
development
Detect, date, and contextualize whole-genome duplication (WGD / paleopolyploidy) events using wgd v2 (Chen et al 2024), KsRates (Sensalari 2022 substitution-rate-corrected Ks dating), DupGen_finder (Qiao 2019), MAPS (Li 2018 phylogenomic), POInT (Conant 2008 ordered-block), SLEDGe (2024 ML-based), Whale.jl (Bayesian DL+WGD), and synteny-anchored paranome construction. Use when identifying ancient polyploidy from Ks distributions and synteny block analysis, positioning WGD events relative to speciation, distinguishing tandem from segmental from WGD duplications, dating the 2R/3R vertebrate / fish / salmonid WGDs, building paranome and Ks-age mixture models, applying KsRates substitution-rate correction across lineages, or testing alternative biased-fractionation / dosage-balance models post-WGD.
tools
Build whole-genome alignments using Progressive Cactus (Armstrong 2020 reference-free clade-level WGA), Minigraph-Cactus (Hickey 2024 pangenome-aware), LASTZ chain/net (UCSC pipeline), MUMmer4 (Marçais 2018 pairwise), minimap2 -x asm5/10/20 (Li 2018 fast pairwise), AnchorWave (Song 2022 WGD-aware), and Mauve / progressiveMauve (bacterial). Operates the HAL toolkit (Hickey 2013) for downstream extraction including halSynteny, halLiftover, halBranchMutations, and hal2maf. Use when constructing multi-species alignments for comparative-annotation projection (TOGA), synteny detection, conservation analyses (phyloP / PhastCons), or pangenome graph construction; selecting between reference-free (Cactus) and reference-anchored (LASTZ chains/nets) approaches; tuning sensitivity for closely vs distantly related genomes; or producing HAL files for genome-wide downstream tools.
development
Detect syntenic blocks and structural rearrangements between genomes using MCScanX (Wang 2012), JCVI/MCScan (Tang 2008 Python), GENESPACE (Lovell 2022) for orthology-anchored riparian visualization, SyRI for structural variation, AnchorWave for sequence-level synteny, i-ADHoRe 3.0 for highly diverged species, SynNet for synteny networks, and ntSynt for multi-genome macrosynteny. Use when identifying collinear gene blocks across species, distinguishing macrosynteny from microsynteny, detecting inversions/translocations/duplications, anchoring orthology in WGD lineages, producing publication riparian plots, computing synteny block age via Ks (cross-references whole-genome-duplication), or running synteny-aware ortholog inference in polyploids.