Expand description
§primer3
Safe, idiomatic Rust bindings to the primer3 C library for PCR primer design and oligonucleotide thermodynamic calculations.
§Quick Start
§Melting Temperature
use primer3::calc_tm;
let tm = calc_tm("GTAAAACGACGGCCAGT").unwrap();
println!("Tm = {tm:.1}°C");§Thermodynamic Analysis
use primer3::{calc_hairpin, calc_homodimer, calc_heterodimer};
let hairpin = calc_hairpin("CCCCCATCCGATCAGGGGG").unwrap();
println!("Hairpin Tm = {:.1}°C, dG = {:.0} cal/mol", hairpin.tm(), hairpin.dg());
let dimer = calc_heterodimer("AAAAAAAAAA", "TTTTTTTTTT").unwrap();
println!("Heterodimer Tm = {:.1}°C", dimer.tm());§Primer Design
use primer3::{design_primers, SequenceArgs, PrimerSettings};
let seq_args = SequenceArgs::builder()
.sequence("ATCGATCG...")
.target(100, 200) // start=100, length=200
.build()
.unwrap();
let settings = PrimerSettings::builder()
.primer_opt_tm(60.0)
.primer_min_tm(57.0)
.primer_max_tm(63.0)
.product_size_range(75, 150)
.build()
.unwrap();
let result = design_primers(&seq_args, &settings, None, None).unwrap();
for pair in result.pairs() {
println!("{}", pair.left().sequence());
}§Thread Safety
The underlying C library uses global state for thermodynamic parameters,
which are compiled in from thal_default_params.h (no file I/O needed).
Thermodynamic calculation functions (calc_tm, calc_hairpin, etc.) are
safe to call concurrently. Both design_primers() and align() are
mutex-guarded because the underlying C routines use mutable global state
(primer3’s internal bookkeeping and dpal’s ~40 MB scoring/traceback
matrices, respectively).
§Defaults
This crate uses primer3 C library v2 defaults (p3_create_global_settings()).
Some defaults differ from primer3-py – consult the primer3 manual for details.
Modules§
- boulder
- Boulder I/O format support for primer3 interoperability.
Structs§
- Alignment
Args - Parameters for dynamic programming alignment.
- Alignment
Result - Result of a dynamic programming alignment.
- Design
Result - Complete result of a primer design run.
- Interval
- A genomic interval as (start, length), both 0-based.
- OkRegion
Pair - A pair of OK regions for left and right primers.
- Oligo
Settings - Settings for an individual primer or internal oligo.
- Oligo
Weights - Weights for scoring individual primers or oligos.
- Pair
Weights - Weights for scoring primer pairs.
- Primer
Pair - A primer pair (left + right + optional internal oligo).
- Primer
Record - An individual primer or oligo record.
- Primer
Settings - Global settings for primer design.
- Primer
Settings Builder - Builder for
PrimerSettings. - Sequence
Args - Per-sequence arguments for primer design.
- Sequence
Args Builder - Builder for
SequenceArgs. - Sequence
Library - A library of sequences for mispriming or mishybridization checks.
- Solution
Conditions - Salt and buffer concentrations for thermodynamic calculations.
- Thermo
Args - Parameters for thermodynamic calculations (hairpin, dimer, end stability).
- Thermo
Result - Result of a thermodynamic calculation (hairpin, dimer, or end stability).
- TmParams
- Parameters for Tm calculation.
Enums§
- Alignment
Mode - Alignment mode specifying how sequences are aligned.
- Alignment
Output - Output mode for alignment computation.
- Oligo
Type - Type of oligo (left primer, right primer, or internal probe).
- Primer3
Error - Errors that can occur when using the primer3 library.
- Primer
Task - The task that primer3 should perform.
- Salt
Correction Method - Method for salt concentration correction.
- TmMethod
- Method for calculating melting temperature.
Constants§
- MAX_
ALIGN_ LENGTH - Maximum sequence length for alignment (1600 bp).
Functions§
- align
- Performs dynamic programming alignment of two DNA sequences.
- calc_
end_ oligodg - Calculates the delta G (Gibbs free energy) of the last
lenbases of a DNA oligonucleotide using the nearest-neighbor model. - calc_
end_ oligodg_ with - Calculates the delta G of the last
lenbases with a specific Tm method. - calc_
end_ stability - Calculates 3’ end stability of
seq1hybridized againstseq2. - calc_
end_ stability_ with - Calculates 3’ end stability with custom parameters.
- calc_
hairpin - Calculates hairpin formation thermodynamics for a DNA sequence.
- calc_
hairpin_ with - Calculates hairpin formation thermodynamics with custom parameters.
- calc_
heterodimer - Calculates heterodimer formation thermodynamics between two DNA sequences.
- calc_
heterodimer_ with - Calculates heterodimer formation thermodynamics with custom parameters.
- calc_
homodimer - Calculates homodimer formation thermodynamics for a DNA sequence.
- calc_
homodimer_ with - Calculates homodimer formation thermodynamics with custom parameters.
- calc_
oligodg - Calculates the delta G (Gibbs free energy) of disruption of a DNA oligonucleotide using the nearest-neighbor model.
- calc_
oligodg_ with - Calculates the delta G of disruption with a specific Tm method.
- calc_tm
- Calculates the melting temperature of a DNA sequence using default parameters.
- calc_
tm_ with - Calculates the melting temperature of a DNA sequence with custom parameters.
- design_
primers - Designs primers for the given sequence using the specified settings.
- divalent_
to_ monovalent - Converts divalent cation concentration to an equivalent monovalent concentration using the primer3 formula.
- is_
symmetric - Returns
trueif the DNA sequence is self-complementary (palindromic). - reverse_
complement - Returns the reverse complement of a DNA sequence.
Type Aliases§
- Result
- A
Resulttype alias usingPrimer3Error.