Skip to main content

PCR primer panel pipeline: CDS target generation, Primer3Plus-like primer design, in-silico specificity check

Project description

Primer Panel

Primer Panel is a Python CLI for building human hg38 PCR primer panels from gene symbols. It separates target planning, Primer3 primer design, and genome-wide in-silico PCR specificity checks into clear pipeline stages.

What It Does

Stage Purpose Main output
1. Target generation Select coding transcripts from Ensembl and build CDS target windows target_summary.tsv, targets.bed, targets.fa
2. Primer design Run Primer3 with Primer3Plus-like defaults primers.tsv, primers.xlsx
3. Specificity check Run UCSC isPcr and classify genome-wide hits primers_specificity.tsv, primers_unique.tsv

The pipeline targets CDS regions, not full exons or UTRs. Stage 1 creates the template and SEQUENCE_TARGET; Stage 2 records Primer3 design metrics; Stage 3 is the only stage that reports genomic PCR product coordinates.

Installation

Primer Panel does not bundle primer3_core or UCSC isPcr binaries.

# Create environment with all tools
micromamba create -n primer_panel -c conda-forge -c bioconda \
  python=3.11 primer3 ispcr ucsc-fatotwobit \
  requests openpyxl pyfaidx -y
micromamba activate primer_panel

# Install primer-panel itself
pip install primer-panel

Or for development: pip install -e .

Verify

primer-panel --doctor

Tool summary

Tool Stage Install Required?
primer3_core 2 micromamba install -c bioconda primer3 Required
isPcr 3 micromamba install -c bioconda ispcr Required
faToTwoBit 3 micromamba install -c bioconda ucsc-fatotwobit Optional (auto-.2bit)
bigBedToBed dbSNP micromamba install -c bioconda ucsc-bigbedtobed Optional (.bb support)
pyfaidx 1 pip install pyfaidx Required
openpyxl any pip install openpyxl Optional (XLSX)

Docker / Apptainer

FROM mambaorg/micromamba:latest
RUN micromamba install -y -c conda-forge -c bioconda \
    python=3.11 primer3 ispcr ucsc-fatotwobit \
    requests openpyxl pyfaidx && \
    micromamba clean -afy
RUN pip install primer-panel

Quick Start

# Stage 1 only: target coordinates, no genome needed
primer-panel --genes HFE HJV TFR2 SLC40A1 HAMP FTH1 \
  --stage targets --output-dir outputs/targets

# Full pipeline (default): targets + primers + specificity
primer-panel --genes HFE HJV TFR2 SLC40A1 HAMP FTH1 \
  --target-size 2700-3300 --primer-flank 500 \
  --genome-fasta /path/to/hg38.fa --output-dir outputs/full

# Finalize: select best unique primer per target
primer-panel-finalize --input-dir outputs/full \
  --output-dir outputs/panel_final --genome-fasta /path/to/hg38.fa

Common Options

Option Default Description
--genes (required) Gene symbols to process.
--stage all targets, design, specificity, or all.
--target-size MIN-MAX 2700-3300 CDS target extension size.
--primer-flank N 300 Flanking bases for primer search.
--genome-fasta PATH hg38 FASTA (required for Stage 2+).
--annotation-gtf PATH Local Ensembl GTF for offline annotation.
--common-dbsnp-bed PATH dbSNP file (.bed or .bb). See dbSNP.
--ispcr-db PATH auto Database for isPcr (auto-.2bit if faToTwoBit installed).
--ispcr-ooc PATH auto Overused-tile file.
--prepare-ispcr-db off Force (re)create .2bit.
--make-ispcr-ooc off Create .ooc file.
--doctor off Run dependency checks and exit.

isPcr Acceleration

isPcr over a full genome is slow. A .2bit binary database makes it fast. The pipeline auto-generates it on first run if faToTwoBit is installed (one-time, ~1-3 min). If faToTwoBit is missing, it falls back to FASTA with a one-time hint.

Also supported: .ooc overused-tile files (auto-discovered), and .nib databases (legacy). No flags needed — everything is automatic.

To force rebuild or pre-create: --prepare-ispcr-db (see primer-panel --help).

dbSNP Annotation

--common-dbsnp-bed annotates primers with common variants (MAF ≥ 1%) from dbSNP, flagging primers that overlap high-frequency SNPs — especially at the 3' end where mismatches impair extension. Accepts .bed and .bb (bigBed) files.

Method 1: BED via UCSC table dump (dbSNP 151, easy)

# Download and convert (~9 MB compressed)
wget https://hgdownload.soe.ucsc.edu/goldenPath/hg38/database/snp151Common.txt.gz
zcat snp151Common.txt.gz | cut -f2,3,4,5 > snp151Common_hg38.bed

primer-panel --genes HFE HJV TFR2 --genome-fasta /path/to/hg38.fa \
  --common-dbsnp-bed snp151Common_hg38.bed --output-dir outputs/run

Method 2: bigBed directly (dbSNP 155+, requires bigBedToBed)

# Install once
micromamba install -c bioconda ucsc-bigbedtobed

# Download and use directly — no conversion (~2 GB)
wget https://hgdownload.soe.ucsc.edu/gbdb/hg38/snp/dbSnp155Common.bb

primer-panel --genes HFE HJV TFR2 --genome-fasta /path/to/hg38.fa \
  --common-dbsnp-bed dbSnp155Common.bb --output-dir outputs/run

Available builds: dbSnp153Common.bb, dbSnp155Common.bb. Check https://hgdownload.soe.ucsc.edu/gbdb/hg38/snp/ for newer releases.

snp151's ~6M common variants are generally sufficient — common variant calls (MAF ≥ 1%) are stable between builds.

Output annotation

primers_specificity.tsv includes: common_snp_risk (none/medium/high), *_common_snp_count, *_3p_common_snp_count, common_snp_hits.

Key Outputs

File Stage Description
target_summary.tsv / .xlsx 1 Coordinates, transcript, CDS coverage, QC status.
targets.bed 1 Design-template BED6.
required_regions.bed 1 Raw CDS regions that must be covered.
targets.fa 1 Template sequences (N-placeholder unless --genome-fasta).
failed_targets.tsv 1 Genes that could not be processed (if any).
primers.tsv / .xlsx 2 Primer3 pairs and design metrics.
primers_specificity.tsv 3 Primers + isPcr hit classification + dbSNP annotation.
primers_unique.tsv 3 Subset: unique_pass only.
stage3_summary.txt 3 Per-target specificity summary.
run_summary.txt all QC summary for the full run.

primer-panel-finalize

Selects the best unique primer per target from Stage 3 outputs.

primer-panel-finalize \
  --input-dir outputs/run \
  --output-dir outputs/panel_final \
  --genome-fasta /path/to/hg38.fa
File Description
recommended_primers.tsv / .xlsx Best unique_pass primer per target.
failed_or_needs_review_targets.tsv Targets without a unique primer.
panel_summary.txt Human-readable summary.

Rescue (experimental)

Re-runs Primer3 for targets without a unique primer. Must be explicitly requested. Currently only FTH1_cds1_4 has an implemented strategy.

primer-panel-finalize --input-dir outputs/run --output-dir outputs/panel_final \
  --genome-fasta /path/to/hg38.fa --rescue-target FTH1_cds1_4

See primer-panel-finalize --help for --rescue-all and --experimental-split-rescue.

Specificity Status

Status Meaning
unique_pass One hit, matching expected chromosome and coordinates.
unique_off_target One hit, but not at the expected location.
multi_hit Multiple genome-wide products.
no_hit No product detected.
pcr_error isPcr failed for the batch.

Dependency Doctor

primer-panel --doctor

Reports primer3_core, isPcr, faToTwoBit, bigBedToBed, genome FASTA, and common dbSNP status. Does not require --genes.

Offline Annotation (Ensembl GTF)

By default, Stage 1 queries the Ensembl REST API. For offline use (or to pin a specific release), provide a local Ensembl GTF:

primer-panel --genes HFE HJV TFR2 --stage targets \
  --annotation-gtf /path/to/Homo_sapiens.GRCh38.110.gtf.gz \
  --output-dir outputs/offline

GTF provides annotation only — for the full pipeline, also pass --genome-fasta. Use GTF and FASTA from the same Ensembl release.

Transcript selection priority: MANE_SelectEnsembl_canonical → longest CDS among protein_coding transcripts.

Development

python -m pytest
python -m compileall -q primer_panel tests
python -m build --no-isolation --sdist --wheel --outdir /tmp/primer-panel-build

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

primer_panel-0.6.1.tar.gz (80.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primer_panel-0.6.1-py3-none-any.whl (68.8 kB view details)

Uploaded Python 3

File details

Details for the file primer_panel-0.6.1.tar.gz.

File metadata

  • Download URL: primer_panel-0.6.1.tar.gz
  • Upload date:
  • Size: 80.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for primer_panel-0.6.1.tar.gz
Algorithm Hash digest
SHA256 359e0da134496589d986e9da358d76594ac3ef07b667ce83a6b5c54350a94745
MD5 5f2957573b0bda9b0b1fc635981a61f5
BLAKE2b-256 8a92b0fca87728b9a5e01c56ffd451f70c48f6b976fd43a4c74640df22906243

See more details on using hashes here.

Provenance

The following attestation bundles were made for primer_panel-0.6.1.tar.gz:

Publisher: publish.yml on d-jch/primer-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file primer_panel-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: primer_panel-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 68.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for primer_panel-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de9a8bae412e7431873f179b70ebf47ddab2d1907af34cef34e0d4dcfe3560a9
MD5 2fd0b1fa2229d4015e856eb74f9e2bec
BLAKE2b-256 f19a01f77e1a6acde2752f1a2bc02f615bbf685f61091b5d6c53334e136dee74

See more details on using hashes here.

Provenance

The following attestation bundles were made for primer_panel-0.6.1-py3-none-any.whl:

Publisher: publish.yml on d-jch/primer-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page