System Architecture
PrimerLab uses a three-tier architecture for maintainability and flexibility.Overview
Layer 1: User Interface
Command Line Interface
The CLI is the primary entry point for most users:primerlab/cli/main.py— Command routing and argument parsing- Rich library for formatted output
Python API
For programmatic access:primerlab/api/public.py— 15+ public functions
Layer 2: Workflow Orchestration
Workflows coordinate multi-step processes.PCR Workflow
- Load and validate configuration
- Call Primer3 for candidate generation
- Apply quality control filters
- Rank candidates
- (Optional) Run in-silico PCR validation
- (Optional) Run BLAST off-target check
- Generate reports
- Save to database
qPCR Workflow
Same as PCR, plus:- Probe design
- Probe-primer compatibility check
- Melt curve prediction (SYBR)
Database
All designs are persisted to SQLite:~/.primerlab/history.db
- Design history tracking
- Result comparison
- Reproducibility
Layer 3: Core Utilities
Primer3 Wrapper
Interfaces with the Primer3 tool:Quality Control
Evaluates primer quality:| Check | Threshold |
|---|---|
| Self-dimer ΔG | > -5 kcal/mol |
| Hairpin ΔG | > -2 kcal/mol |
| 3’ stability | No G/C runs |
| GC content | 40-60% |
In-silico PCR
Simulates amplification to validate primer binding:Off-target Finder
BLAST-based specificity analysis:Configuration Pipeline
Priority: CLI args > YAML file > DefaultsError Handling
Standardized exception hierarchy:error_code— Standardized code (e.g.,ERR_CONFIG_001)message— Human-readable descriptiondetails— Context dictionary