Prismalign
N-color nucleotide-conversion alignment engine with pluggable backends.
Prismalign maps sequencing reads from any nucleotide-conversion chemistry
(bisulfite-seq C→T, SLAM-seq T→C, m6A / A-to-I A→G, MK/KM dual-base,
or a custom 3rd channel) using a HISAT-3N-style strategy:
- build a converted reference index (
scheme.ref_from → ref_to) - transform each read per color channel and align it to the converted index via a pluggable backend (bwamem by default; WFA2-lib; minimap2/mappy; minibwa, all optional)
- re-score every hit against the original reference so that real
conversions are rewarded (not counted as mismatches), emitting a
color-correct
MDplus per-channelY/Zcounts in BAM tags.
All per-read heavy kernels are native C (BWA-MEM / WFA2-lib / minimap2 / minibwa); the Python layer is a thin, friendly wrapper.
Install
pip install -e . # bwamem + built-in WFA2 C backends
pip install -e "./[mappy]" # + minimap2 backend
Usage — Python (clean wrapper)
import prismalign as ps
# one-shot mapping -> BAM (builds indexes, maps, cleans up)
ps.map_reads("reads.fq", "ref.fa", "out.bam",
scheme="MK", backend="bwamem", threads=4)
# object API / reuse
with ps.NColorMapper(scheme=ps.BS, backend="bwamem") as mapper:
mapper.map_file("reads.fq", ref_files=["ref.fa"], output_files=["bs.bam"])
Usage — CLI
# classic two-color (MK: A->G + C->T) on bwamem
prismalign map -s MK --backend bwamem -r ref.fa -o out.bam reads.fq
# bisulfite-seq (3-nt single channel C->T)
prismalign map -s BS -r genome.fa -o bs.bam --index-dir idx reads.fq
# parallel (2 copies of the reads, byte-identical output to -t 1)
prismalign map -s MK -r ref.fa -o out.bam -t 4 reads.fq
# list built-in schemes
prismalign schemes
Schemes
| name | reference index | channels | use case |
|---|---|---|---|
MK |
AC→GT |
2 | dual-base conversion A→G + C→T (classic two-color) |
KM |
GT→AC |
2 | reverse of MK |
BS |
C→T |
1 | bisulfite-seq (3-nt) |
SLAM |
T→C |
1 | SLAM-seq |
A2G |
A→G |
1 | m6A / A-to-I editing |
THREE |
AC→GT |
3 | three-color demo (add your 3rd base pair in schemes.py) |
Python API
from prismalign import NColorMapper, BS
mapper = NColorMapper(scheme=BS, backend="bwamem", index_dir="idx")
mapper.map_file(r1_file="reads.fq", ref_files=["genome.fa"],
output_files=["out.bam"])
Backends
Prismalign's engine only needs align() -> [RawHit] from a backend (re-scoring
against the original reference is engine-side), so adding one is easy:
| backend | engine | notes |
|---|---|---|
bwamem |
BWA-MEM via the bwamem package |
default, fast C backend (SE + PE) |
minibwa |
lh3/minibwa (bwa-mem successor) via PyO3 pip binding minibwa (fg-labs) |
~2-3x faster than bwa-mem; pip install minibwa (SE + PE) |
mappy |
minimap2 via mappy |
official minimap2 Python binding (SE + PE) |
wfa2 |
WFA2-lib (vendored v2.3.6, MIT) compiled in-process | exact gapped (indel-aware) wavefront alignment; SE only |
Note on external-tool adapters.
--backendselects the four native in-process backends above. To wrap an aligner prismalign has no binding for (e.g.bwa-mem2,bowtie2,hisat-3n,strobealign), useprismalign.adapters(SamAdapter,BwaMem2Adapter,Bowtie2Adapter,StrobealignAdapter) — these are not--backend-selectable.Full inventory — including where each Python wrapper lives — is in
docs/backends.md.
Speed & IO
- Parallel mapping:
-t/--threads Nmaps reads in an ordered fork+COW process pool (any backend); batches are drained in read order so the BAM is byte-identical tothreads=1.--batch-sizetunes reads per worker. - Reduced repeated IO: references are copy+converted once even when reused across layers (cache keyed by path+scheme); per-hit reference fetch is cached in memory for small contigs (RNA/transcript references), so only one indexed read per contig.
Limitations (v0.2.x)
- paired-end is supported natively by the
bwamem,mappyandminibwabackends;wfa2is single-end for now (the subprocesssam/strobealign/bowtie2/bwa_mem2adapters are also SE). - hierarchical (layered) mapping uses the
PLAINidentity scheme for non-converted short-RNA references.minibwais the fastest native backend but needs standard (non-free-threaded) CPython ≤ 3.13, so on 3.14tmappyis the fastest available.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file prismalign-0.2.2.tar.gz.
File metadata
- Download URL: prismalign-0.2.2.tar.gz
- Upload date:
- Size: 159.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb5524a6307ead62d8f6d9ed4a4986991e21b3a4b5f632ad1a88eae368eeb3e9
|
|
| MD5 |
380f4513b4556ca0cd0d492f7f2381bb
|
|
| BLAKE2b-256 |
17170e9e8cd3cd59a0c4261acf1ed287ca2178d8d891e6e9ba5216e179dd7c09
|
Provenance
The following attestation bundles were made for prismalign-0.2.2.tar.gz:
Publisher:
workflow.yml on y9c/prismalign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prismalign-0.2.2.tar.gz -
Subject digest:
fb5524a6307ead62d8f6d9ed4a4986991e21b3a4b5f632ad1a88eae368eeb3e9 - Sigstore transparency entry: 2709433793
- Sigstore integration time:
-
Permalink:
y9c/prismalign@c6c4c59039ef9ff72df121b435223de4e9f6209a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/y9c
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@c6c4c59039ef9ff72df121b435223de4e9f6209a -
Trigger Event:
push
-
Statement type: