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.ProcessPoolExecutorwith 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
gzipif 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
-
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.
-
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). -
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.
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7982b64d5ff4e0ed020e9ce3e9e72432c469b119e308a720e91fc8ce66181258
|
|
| MD5 |
022bd97bcb8cf880dd35ded960b31c99
|
|
| BLAKE2b-256 |
6435c3878d942a378d0cb5e7e6aab9b558405ceb3d69b613aad4582271f51426
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92321ad8f4783b606799e22b4d5cc2d9b5ae8fc2f3de55cc7dbd717affa7850f
|
|
| MD5 |
e11340d744128199332a91b4c5c83968
|
|
| BLAKE2b-256 |
36fd003d0f399e8ac24aeff7b43524f421f24e17967d3921aacb0e962c6c0287
|