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.0.tar.gz (180.0 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.0-cp39-abi3-win_amd64.whl (394.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

diffprimer-0.1.0-cp39-abi3-win32.whl (369.3 kB view details)

Uploaded CPython 3.9+Windows x86

diffprimer-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (611.9 kB view details)

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

diffprimer-0.1.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (623.1 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

diffprimer-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (572.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

diffprimer-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (517.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

diffprimer-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (529.1 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for diffprimer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fea0dd4bb531105dcef91c859d8f56fcdd13383c0941c80f7afa38870c07ff36
MD5 33f0b9f97eff9fbcb1983709aabb1b9a
BLAKE2b-256 45c472308719d804c46816cc65101642fed05c35522a842e6754dfce3abff892

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d901d52c907b31b4c7d1ce6ec68b1be215a52da709111dcba2f218ccab06e497
MD5 e33e02e54a994a81bb118af9b24467f6
BLAKE2b-256 d989febf5fccd266e7360c4ce607784d1eaad57247092fe64b41698e36eddf5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffprimer-0.1.0-cp39-abi3-win32.whl
  • Upload date:
  • Size: 369.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.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 762eff0273374a33b4268739671ad0ed31f3819195f591b5b93815d96fdc4264
MD5 c810a62be5cafc6fb8e438d6190218a0
BLAKE2b-256 3c6281470413ca38d023e2da552d10f8008dd10671a9c74a97391460d2698cdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e4d9e2e604a88a07e6b72404dadf7fe1eb98f68f17b46f98e1f53545bf7f3a8
MD5 82e9ee6df15f30832f58e75ec29613a7
BLAKE2b-256 dacc5bb05726552c9de1b277fa676ac1c30f2f68fc9473b85844a803ceceef06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 612443afd0414e402e058c52d9bdde67e337e666d17182ac9adce7f585205711
MD5 34b2de2f4148686dc50edc78569bcf62
BLAKE2b-256 06e3bc42b9adf604c4ee5655bd146a635e30d3488f07a5ba4a21550cd2060807

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bea7c643b2344f88ec730dea60244e26a9ac0ae2b8e1ce7d4cafa3f2019a2439
MD5 4447718e74753c700ab98e4442c6bf31
BLAKE2b-256 32e232149c12863a470185efcc61f61bf24f0ada211f2adfee88cc6048f6b447

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d2e683f8c02267e53e5bda54b7eea652c158f23abea108e115210b76e5735b5
MD5 22f0ee8017f5931a60a295aa6c9c57c4
BLAKE2b-256 cd1e44966d8aabfd6cd81468f3e16cedd45777b2202781d5b7b5a6e7e7aa9c8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffprimer-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 58ee580058ad0135e106fa03be404343b5cfd38b37458a5317574964a196b8fb
MD5 e5298e691617b35985f278409e0f400e
BLAKE2b-256 200138e6a0d94d1903aa6d39548b8e21006137cfd64cf724f9aa87dc8513fa0a

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