Skip to main content

A tool to design primers that target specific variants in genomic sequences. Alingment-free and fast.

Project description

DiffPrimer

diffprimer_logo

DiffPrimer is a bioinformatics tool designed to identify unique genomic regions in a reference genome compared to a set of other "background" genomes and automatically design specific PCR primers for these markers.

It combines high-performance k-mer analysis (written in Rust) with standard primer design tools (Primer3) to generate diagnostic markers that are exclusive to your target organism.

Key Features

  • Exclusive Region Discovery: Identifies genomic regions present in your reference but absent in a database of other genomes.
  • Automated Primer Design: Integrated with Primer3 to design optimal primer pairs for identified unique regions.
  • Specificity Check:
    • Validates designed primers against all input background genomes.
    • Uses a hybrid Myers Bit-Vector Algorithm (Global) and Semiglobal Alignment (Local) to detect potential off-target amplification, even with insertions/deletions.
  • Annotation Integration: Cross-references unique regions with GFF3 annotation files to identify which genes (if any) the markers overlap with.
  • Parallel Processing: Fully parallelized core for fast execution on large datasets.

Installation

Quick install (recommended)

We recommend using uv to install diffprimer because it is incredibly fast and automatically handles virtual environments for you.

(If you don't have uv installed, it takes only a few seconds. Follow the official uv installation guide.)

uv tool install diffprimer

Alternative methods

If you prefer pipx, you can also use it to install diffprimer safely in an isolated environment. (If you don't have pipx installed, follow the official pipx installation guide.)

pipx install diffprimer

Or, using standard pip:

pip install diffprimer

Requirements

  • Python 3.13 or newer
  • Rust is NOT required for end users

Development install

If you want to contribute or build from source:

  1. Clone the repository:

    git clone https://github.com/omatheuspimenta/diffprimer.git
    cd diffprimer
    
  2. Create a Virtual Environment:

    # Using uv (Recommended)
    uv venv --python 3.13
    source .venv/bin/activate
    
    # OR using standard python
    python3.13 -m venv .venv
    source .venv/bin/activate
    
  3. Install:

    uv pip install -e .
    # OR
    pip install -e .
    

    Note: Rust is required to build the core engine from source. Install via rustup.


Usage

Running diffprimer executes the full pipeline: finding unique regions -> designing primers -> verifying specificity.

Basic Command

diffprimer \
    --reference-file reference.fasta \
    --sequences-path genomes_directory/ \

Complete Example

diffprimer \
    --reference-file data/target_species.fasta \
    --sequences-path data/background_species/ \
    --annotation-path data/target_annotations.gff3 \
    --config-file primer3_config.ini \
    --min-region-length 200 \
    --cpus 8 \
    --check-specificity

Arguments Explained

Argument Short Description
--reference-file -r Required. Path to the target reference genome (FASTA).
--sequences-path -s Required. Directory containing background genomes (FASTA) to compare against. Regions found in these genomes will be excluded.
--annotation-path -a (Optional) GFF3 file for the reference. Used to annotate output regions with gene names + product info.
--config-file -c (Optional) Primer3 configuration file defining Tm, GC%, and size constraints.
--reference-max-abundance Maximum allowed frequency of a k-mer in the reference genome to be considered a candidate marker. Use 1 for strictly unique markers (default). Increasing this value allows markers that are repeated a few times in the reference. (Default: 1)
--kmer-size -k K-mer size for uniqueness check (Default: 21).
--min-region-length -m Minimum length of unique regions to keep (Default: 200 bp).
--check-specificity Highly Recommended. Enables the rigorous cryptographic check of primer specificity. Without this, primers are only designed on unique regions but not physically verified against off-targets.
--similarity-threshold Global similarity threshold (%) for off-target flagging (Default: 80.0).
--local-mismatch-threshold Positional mismatch score threshold for the local specificity check. Standard mismatches add 1, 3' end mismatches add 3 (configurable via --penalty-array). Default is 7, allowing up to 2 mismatches in the 3' region to still be considered non-specific (capable of amplifying).
--penalty-array Penalty values for mismatches. Provide a comma-separated list of 6 values. The first value is the penalty outside the 3' region. The next 5 values are the penalties for the 5 nucleotides of the 3' region. (Default: 1,3,3,3,3,3)

Output Format

The output is a CSV file containing one row per designed primer pair. Key columns include:

  • Sequence_Header: Contig/Region name.
  • Region_Start/End: Coordinates of the unique region.
  • Forward_Primer / Reverse_Primer (and _Tm, _GC, etc.): Primer details.
  • Specificity_Tag: The result of the specificity analysis (if --check-specificity is used).
    • Specific_LowGlobalSim: The region is globally unique; off-targets are extremely dissimilar, so primers are specific.
    • Specific_PositionalMismatches: The region has high global similarity to a background genome, BUT the primers themselves are specific because they have biological mismatches in critical locations (like the 3' end) that prevent binding.
    • NonSpecific_Amplification: The primers bind perfectly or near-perfectly to a similar region in a background genome resulting in cross-reactivity. Do NOT use.
    • Not_Checked: Specificity check was skipped.
  • Gene_Name / Product: Annotation info (if GFF3 provided).

Configuration

You can customize Primer3 settings by providing a file with --config-file. Example format:

PRIMER_OPT_SIZE=20
PRIMER_MIN_SIZE=18
PRIMER_MAX_SIZE=27
PRIMER_OPT_TM=60.0
PRIMER_MIN_TM=57.0
PRIMER_MAX_TM=63.0
PRIMER_MIN_GC=20.0
PRIMER_MAX_GC=80.0

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

diffprimer-0.1.4.tar.gz (471.7 kB view details)

Uploaded Source

Built Distributions

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

diffprimer-0.1.4-cp39-abi3-win_amd64.whl (414.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

diffprimer-0.1.4-cp39-abi3-win32.whl (387.2 kB view details)

Uploaded CPython 3.9+Windows x86

diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.0 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (638.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (590.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl (529.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl (539.5 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file diffprimer-0.1.4.tar.gz.

File metadata

  • Download URL: diffprimer-0.1.4.tar.gz
  • Upload date:
  • Size: 471.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for diffprimer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cd339c8b72481b2b16139cf49c32e18dfd80f9925fca10fe3e6be24a3ea0315b
MD5 2084bac18419d207265ace13175bc32e
BLAKE2b-256 98d6203ab2b2298a7a0cf3e52465fee52bae851f879b20f5e0fe0d731d7067ac

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 754b08b5bf7fcef56c58bb68c51497c9c06f28c6be31062424199928ce04e9dc
MD5 9cf4a50065604828dee7c853ce452e41
BLAKE2b-256 cf8b78df25a3838762446eda891ae4d762aa991ac2b7c215e5ac3aa6b140b8ac

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-win32.whl.

File metadata

  • Download URL: diffprimer-0.1.4-cp39-abi3-win32.whl
  • Upload date:
  • Size: 387.2 kB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 bc8dcbd7730ecd7f496666e6d103a9d6ecdc070e7b22873a1c0fb8585cc776ec
MD5 68c4f9c265117c1f2e00faabca489584
BLAKE2b-256 dccbb8caf9e9fc3a242e760172a2237f8e06a237e3c3c75b9a4ab3b2722a2515

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4713febdca017369d8779383aee579dfa22cc2d6f9b196370fbdcb554b550789
MD5 4e12584b39b9df69dd1c36d4ed5fdafa
BLAKE2b-256 83e3250245259a3e3eb000478d979435e8d7c42495c7cf0d174083d0d003320b

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 58de3e59d751114f5eab88ec4cd9dd9aa38fbc565610c0560a072acbf3ab3fda
MD5 e0bb28e55104ef7623fbcc56098941ff
BLAKE2b-256 ff012e49ffcc8533cc9e55025403da43efb5ee54ac5240c35558b8c26b645095

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f898d55f4f1d52ded6161e60d8689a4a34d7d81b8c286c7d5e0048b54276865
MD5 cac090ab5473292e6f69b4391e41af00
BLAKE2b-256 808266768bf80090991da58d3b26149d711b3d9de2f906dab73d29e6f7b476f9

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5999fddded63d279a74e0f1b21d99bd9af2a3f56552f6c5e17ff24f1de62ab9b
MD5 7fc80a8d77beb1b997fd5c3752f26fd9
BLAKE2b-256 e5774a46f3ed6dc03bff7ed741256af92aefd3f96d172f2ba5902069f27da48c

See more details on using hashes here.

File details

Details for the file diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fda8a3bff082a88fa4e8a67c49a10078cf189a008a459ee83ddcd3a1ded407d0
MD5 5046116d5522f2d5e03fa99c39be0a44
BLAKE2b-256 233b33e4c22b7203d3c1dfd602162bfdfd716aefc6ce4faa420c5499cc9e1cce

See more details on using hashes here.

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