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

Prerequisites

  • Operating System: Linux (Recommended) or macOS.
  • Python: Version 3.13 or higher (Strict requirement).
  • Rust: Required to build the core engine. Install via rustup.

Quick Install (Recommended)

We recommend using uv or pip in a clean environment.

  1. Clone the repository:

    git clone https://github.com/yourusername/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 .
    # OR
    pip install .
    

Troubleshooting (Conda/Anaconda Users)

If you are working inside a Conda environment, the system linker may conflict with Rust, causing build errors (e.g., undefined symbol: getauxval). To fix this:

  1. Deactivate Conda completely for the build step.
  2. Use the system's standard PATH.
# In your terminal
unset CONDA_PREFIX
export PATH=/usr/local/bin:/usr/bin:/bin:$HOME/.cargo/bin
source .venv/bin/activate
uv pip install --force-reinstall .

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.3.tar.gz (471.8 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.3-cp39-abi3-win_amd64.whl (414.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

diffprimer-0.1.3-cp39-abi3-win32.whl (387.1 kB view details)

Uploaded CPython 3.9+Windows x86

diffprimer-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (630.9 kB view details)

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

diffprimer-0.1.3-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (638.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

diffprimer-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (591.4 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

diffprimer-0.1.3-cp39-abi3-macosx_11_0_arm64.whl (529.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

diffprimer-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl (539.1 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for diffprimer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7a500b5d5bc584eb405e0d0d20d7ad36563edbbd132ce93d8dcc4d3349f6e709
MD5 2ef5c0a5ae649909fa2e7059c06a1bc9
BLAKE2b-256 e6cdaf4adf93c7a947111ddfb53568eba745ecac2504d3eed34e0f6041bdff73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4102c4965f1eec8ffede335e8a6210f2ae1079917cb0b72adae9b01917c3260e
MD5 8c008cf1da77f0cb291ecfe758082da0
BLAKE2b-256 ceeb378c450b300bbbc23558979ac2f2076d8a1293703660ebfbf3fa9f555998

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffprimer-0.1.3-cp39-abi3-win32.whl
  • Upload date:
  • Size: 387.1 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.3-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 e9c0b658a2f9684979192a0eacffeeeb25f15465167c8937681b4d0894f206d3
MD5 798d919284d57a839748a3dca8b42a59
BLAKE2b-256 c5bc26906ebec5880a9dabdeb98bb457e633518f2c1af7953846f42170913156

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 65b8f5666547eea6a6476a51a952fcfda16094a70da18d4d421ab910d40fa836
MD5 c8e2b16958949659161d03ab0bdd8897
BLAKE2b-256 60aa0dc84c00754086ac5ebe7ab4ee43b13f36d2f1241c9dd9a32258c0b52002

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 0f92fab15f18747bbdfe20204243590206092081a995f0dafb385b408881c16a
MD5 7f6b65f883479795545971dc2baeeaca
BLAKE2b-256 e62ab5797bde0490eb67e30fcce424e79a46208b8c9ba739377b854715c36218

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1b4ba990e304a3a1a6b2027c8b8d2cad2ba2b4b32b104cc0043c298933f74571
MD5 e965982cab9e0b706d43a3b0d9659565
BLAKE2b-256 9c6a6fe50b80c2ee11eccf4837fd70d997f22dd3bd2a9c321315b0a3c6e18cc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f43365677b78a977efa63bbe24558deacb06da4aa9ba8f39cbbd2c1eac36676
MD5 acbaaa507df6fced03024988f0571b88
BLAKE2b-256 6800f737018b6118b0ea0b2578b26fdcc51a75b85b9a0ac92a07556d81879693

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 306d6de893e8d12c6a2f6a72b7f3be504b3eaf62e17df396cd6d7bd2832b1c20
MD5 e14a5a1062bec366aac522b53baba996
BLAKE2b-256 22b9250a46280a9608d3a0c5b0e2ae42df063335c3ed6852bb3bd5db98dd88e1

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