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

The main command is run. This executes the full pipeline: finding unique regions -> designing primers -> verifying specificity.

Basic Command

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

Complete Example

diffprimer run \
    --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.

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).
    • Unique_LowSim: The region is globally unique; primers are safe.
    • Specific_In_SimRegion: The region has some similarity to background, but the primers themselves are specific (mismatch locally). Safe to use.
    • NonSpecific_HighSim: The primers bind perfectly to a similar region in a background genome. 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.1.tar.gz (179.5 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.1-cp39-abi3-win_amd64.whl (393.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

diffprimer-0.1.1-cp39-abi3-win32.whl (368.3 kB view details)

Uploaded CPython 3.9+Windows x86

diffprimer-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (610.9 kB view details)

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

diffprimer-0.1.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (622.1 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

diffprimer-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (571.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

diffprimer-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (516.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

diffprimer-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl (528.1 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for diffprimer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 92ee4b7f3da4847cbf4c33d6eddf12ee7cde108a822dc6e7eeaa2f6073a799a9
MD5 41b1d26fcc81823eaf435b5d49c240b4
BLAKE2b-256 077e1458928bededde66159d8f3259c7a1c09c5b683bfa54195f84d9246ee4f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e5e620eb1a746c2901db2e50f05703d076454fa597d7d7dc0fb7b7c0b0889914
MD5 6c87fb0661c3909c5f2f483eb36a6259
BLAKE2b-256 5461449f9ecda873bb6206c40e56400872c52155943c1ff749d477d3a3b3b1bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffprimer-0.1.1-cp39-abi3-win32.whl
  • Upload date:
  • Size: 368.3 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.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 a50551e2bdf36e79fc3f6e26c436b6e09b86e1314652a34b7511f6666c1909dc
MD5 a14bc2c751e359079d83ba088d8942f8
BLAKE2b-256 c7952c150563b5f49952e70b81956ca1c5820de1303aeb0153e81eb73b5cbc25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dbe237bd339d0580576283702cd0c433ca51efc22e4904c085ad9c99bb93f049
MD5 ffc07a6b159e76ccf8f64e70e783e5b6
BLAKE2b-256 bedb97ca9e99acdeed32629f8d81cb0c0565b7090ff6ce7f80b7dbe6825e06a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 68d204ff9cc2604d2aa813cbc1c8faad5ba4a1f07f1df340a4529eebbced6e3c
MD5 d7f39011ff98b9350f103310d95be539
BLAKE2b-256 80b779b53e492aab6e4f904f07a5c1cb7d3b36ed40093c03155f202698843875

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 958918b3f4e9b593d5a642d953620364d656de33d4a70cd47cfc3fb63078f0e0
MD5 9352cb46771c2480c27c1ccb6a36f229
BLAKE2b-256 b5103d77a71dc8d5653fdc848b47a9b0d5973ed9c60f57258c02952bf9443b55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35106e9ccee86ad76e4f9f03d4d8727a2b7e9d9444565d0a2bd6f727a6fd8be8
MD5 7d5929e497ee1ec1743c8d8ab51639a8
BLAKE2b-256 ac1aabe4cbcefff26d943fdb299555a08f10f700db9fdd64bb369d165debf770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f331d82f2fc8ccc7f71dc4769034d6b48fe436a6ee0db8bbb166da5ab161542c
MD5 7db7d2d40af16322f4be441c448aef22
BLAKE2b-256 254e309f260ecb2f9c0e4021bf45df6341c1759090a7fb899702f123cd0b315b

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