Skip to main content

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

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.1.tar.gz (33.5 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.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: demultiplexer3-1.0.1.tar.gz
  • Upload date:
  • Size: 33.5 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.1.tar.gz
Algorithm Hash digest
SHA256 5b7aafa67abbdaeda83869b6cb6b48fb6d672fd1a3c024abc806625d60125959
MD5 a222595f785844ca2f33693aa7d3dd93
BLAKE2b-256 c6f2dd964016c6182be35ed54ccf8281a8885e5b7368e163a8c5bb5984da33c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: demultiplexer3-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc8807c69f0b265f48423606cd924af05bfd7313036d6be5dff551a308c39531
MD5 3c6771e47573b226ddfdee38b0105263
BLAKE2b-256 2710dfcc426af355b22cc84f8759c723efd0c919ac6bfee52a4e988203ebbe5d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page