Skip to main content

A python command line interface to demultiplex illumina reads by inline tags.

Project description

demultiplexer3

A Python CLI tool for demultiplexing paired-end Illumina sequencing reads using inline tags. Successor to demultiplexer2.

Key improvements over demultiplexer2

  • Output-oriented parallelism — workers write individual samples as soon as parsing is done, instead of blocking on the largest input file.
  • Cross-product tag validation — forward and reverse tags are checked jointly (concatenated Levenshtein distance), eliminating the infinite-loop risk of separate checks.
  • Configurable minimum distance (--min_dist) and optional tag trimming (--trim).
  • DAG-based scheduler using concurrent.futures.ProcessPoolExecutor with dynamic job submission.
  • Parquet intermediate format with sample identity classified once at parse time, for fast columnar filtering downstream.

Installation

pip install demultiplexer3

Dependencies

  • biopython
  • pandas
  • openpyxl
  • pyarrow
  • duckdb
  • psutil
  • tqdm
  • isal (faster gzip via Intel ISA-L; falls back to stdlib gzip if unavailable)

Usage

1. Create a primerset

demultiplexer3 create_primerset --name <name> --n_primers <n>

Creates an Excel file with three sheets (general_information, forward_tags, reverse_tags) for the user to fill in primer sequences and tag names/sequences. IUPAC ambiguity codes are supported. Saved as <name>_primerset.xlsx in the current working directory (same as the tagging scheme below).

2. Create a tagging scheme

demultiplexer3 create_tagging_scheme --name <name> --data_dir <dir> --primerset_path <path>

Scans data_dir for .fastq.gz file pairs, loads the primerset, and interactively asks which tag combinations were used. Produces a tagging scheme Excel file where sample names are filled in by the user.

3. Demultiplex

demultiplexer3 demultiplex --primerset_path <path> --tagging_scheme_path <path> --output_dir <dir> [--workers <n>] [--min_dist <d>] [--trim]
Parameter Description Default
--primerset_path Path to the primerset Excel file required
--tagging_scheme_path Path to the tagging scheme Excel file required
--output_dir Directory for output FASTQ files required
--workers Number of parallel workers physical cores − 2
--min_dist Minimum Levenshtein distance between tag combinations 2
--trim Remove original tag sequences from the start of each read off

How it works

  1. Tag validation & extension — Tags are equalized to the same length, IUPAC codes are expanded, and the cross-product of all (fwd+rev) combinations is checked for minimum Levenshtein distance. If the distance is too low, tags are extended base-by-base from the primer sequence.

  2. Parse phase — Each input FASTQ pair is read with BioPython's FastqGeneralIterator. The first N bases of each read are extracted as the tag and classified against that input's known tag combinations right away, storing the result as an integer sample index. All data is written to an lz4-compressed Parquet file (a purely transient intermediate — compression here favors speed over ratio).

  3. Write phase — For each sample, DuckDB filters the Parquet file on that integer index and writes matching reads in batches to gzipped FASTQ output files.

  4. Cleanup — Parquet files are deleted once all downstream write jobs for them complete. Unmatched reads are aggregated into unmatched_logfile.xlsx, keeping only the highest-count combinations per input file (the long tail of near-random spacer variants carries no diagnostic value).

License

MIT

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

demultiplexer3-1.0.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

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

demultiplexer3-1.0.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file demultiplexer3-1.0.0.tar.gz.

File metadata

  • Download URL: demultiplexer3-1.0.0.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for demultiplexer3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7982b64d5ff4e0ed020e9ce3e9e72432c469b119e308a720e91fc8ce66181258
MD5 022bd97bcb8cf880dd35ded960b31c99
BLAKE2b-256 6435c3878d942a378d0cb5e7e6aab9b558405ceb3d69b613aad4582271f51426

See more details on using hashes here.

File details

Details for the file demultiplexer3-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: demultiplexer3-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for demultiplexer3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92321ad8f4783b606799e22b4d5cc2d9b5ae8fc2f3de55cc7dbd717affa7850f
MD5 e11340d744128199332a91b4c5c83968
BLAKE2b-256 36fd003d0f399e8ac24aeff7b43524f421f24e17967d3921aacb0e962c6c0287

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