DiffPrimer
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:
-
Clone the repository:
git clone https://github.com/omatheuspimenta/diffprimer.git cd diffprimer
-
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
-
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-specificityis 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
Release files for diffprimer 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| diffprimer-0.1.4.tar.gz | 471.7 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| diffprimer-0.1.4-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| diffprimer-0.1.4-cp39-abi3-win32.whl | CPython 3.9 | abi3 | Windows x86-32 | Details |
| diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-32 | Details |
| diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 4.2 MB
Release files / diffprimer-0.1.4.tar.gz
| Download URL | diffprimer-0.1.4.tar.gz |
|---|---|
| Size | 471.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd339c8b72481b2b16139cf49c32e18dfd80f9925fca10fe3e6be24a3ea0315b
|
|
BLAKE2b-256 checksum How to use checksums |
98d6203ab2b2298a7a0cf3e52465fee52bae851f879b20f5e0fe0d731d7067ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-win_amd64.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 414.2 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
754b08b5bf7fcef56c58bb68c51497c9c06f28c6be31062424199928ce04e9dc
|
|
BLAKE2b-256 checksum How to use checksums |
cf8b78df25a3838762446eda891ae4d762aa991ac2b7c215e5ac3aa6b140b8ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-win32.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-win32.whl |
|---|---|
| Size | 387.2 kB |
| Tags | CPython 3.9 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
bc8dcbd7730ecd7f496666e6d103a9d6ecdc070e7b22873a1c0fb8585cc776ec
|
|
BLAKE2b-256 checksum How to use checksums |
dccbb8caf9e9fc3a242e760172a2237f8e06a237e3c3c75b9a4ab3b2722a2515
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 631.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4713febdca017369d8779383aee579dfa22cc2d6f9b196370fbdcb554b550789
|
|
BLAKE2b-256 checksum How to use checksums |
83e3250245259a3e3eb000478d979435e8d7c42495c7cf0d174083d0d003320b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 638.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
58de3e59d751114f5eab88ec4cd9dd9aa38fbc565610c0560a072acbf3ab3fda
|
|
BLAKE2b-256 checksum How to use checksums |
ff012e49ffcc8533cc9e55025403da43efb5ee54ac5240c35558b8c26b645095
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 590.9 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0f898d55f4f1d52ded6161e60d8689a4a34d7d81b8c286c7d5e0048b54276865
|
|
BLAKE2b-256 checksum How to use checksums |
808266768bf80090991da58d3b26149d711b3d9de2f906dab73d29e6f7b476f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 529.3 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5999fddded63d279a74e0f1b21d99bd9af2a3f56552f6c5e17ff24f1de62ab9b
|
|
BLAKE2b-256 checksum How to use checksums |
e5774a46f3ed6dc03bff7ed741256af92aefd3f96d172f2ba5902069f27da48c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|
Release files / diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | diffprimer-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 539.5 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
fda8a3bff082a88fa4e8a67c49a10078cf189a008a459ee83ddcd3a1ded407d0
|
|
BLAKE2b-256 checksum How to use checksums |
233b33e4c22b7203d3c1dfd602162bfdfd716aefc6ce4faa420c5499cc9e1cce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.1
|