prismalign 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of prismalign might be problematic. Click here for more details.
- {prismalign-0.2.1/prismalign.egg-info → prismalign-0.2.2}/PKG-INFO +25 -27
- {prismalign-0.2.1 → prismalign-0.2.2}/README.md +24 -26
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/__init__.py +26 -11
- prismalign-0.2.2/prismalign/adapters/__init__.py +29 -0
- prismalign-0.2.2/prismalign/adapters/bowtie2/__init__.py +73 -0
- prismalign-0.2.2/prismalign/adapters/bwa_mem2/__init__.py +68 -0
- {prismalign-0.2.1/prismalign/backends → prismalign-0.2.2/prismalign/adapters}/sam/__init__.py +21 -9
- {prismalign-0.2.1/prismalign/backends → prismalign-0.2.2/prismalign/adapters}/strobealign/__init__.py +10 -9
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/__init__.py +11 -16
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/base.py +2 -2
- prismalign-0.2.2/prismalign/backends/mappy/__init__.py +77 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/minibwa/__init__.py +44 -14
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/registry.py +8 -10
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/__init__.py +40 -13
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wrap.c +5 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/cli.py +29 -1
- prismalign-0.2.2/prismalign/em.py +444 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/engine.py +51 -27
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/schemes.py +18 -1
- {prismalign-0.2.1 → prismalign-0.2.2/prismalign.egg-info}/PKG-INFO +25 -27
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign.egg-info/SOURCES.txt +9 -5
- {prismalign-0.2.1 → prismalign-0.2.2}/pyproject.toml +11 -7
- {prismalign-0.2.1 → prismalign-0.2.2}/setup.py +3 -10
- prismalign-0.2.2/tests/test_adapters.py +95 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_backends.py +7 -18
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_backends_matrix.py +11 -15
- prismalign-0.2.2/tests/test_em.py +124 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_engine.py +14 -18
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_hierarchy.py +5 -5
- prismalign-0.2.2/tests/test_pe_minibwa.py +91 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_sam_backend.py +12 -20
- prismalign-0.2.1/prismalign/backends/mappy/__init__.py +0 -39
- prismalign-0.2.1/prismalign/backends/python/__init__.py +0 -55
- prismalign-0.2.1/prismalign/backends/python/pyalign.c +0 -393
- prismalign-0.2.1/tests/test_pyalign.py +0 -133
- {prismalign-0.2.1 → prismalign-0.2.2}/LICENSE +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/MANIFEST.in +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/bwamem/__init__.py +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/LICENSE.wfa2 +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/affine2p_penalties.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/affine2p_penalties.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/affine_penalties.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/affine_penalties.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/cigar.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/cigar.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/cigar_utils.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/cigar_utils.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/linear_penalties.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/score_matrix.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/alignment/score_matrix.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/mm_allocator.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/mm_allocator.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/mm_stack.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/mm_stack.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/profiler_counter.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/profiler_counter.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/profiler_timer.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/system/profiler_timer.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/bitmap.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/bitmap.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/commons.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/commons.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/dna_text.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/dna_text.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/heatmap.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/heatmap.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/sequence_buffer.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/sequence_buffer.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/vector.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/utils/vector.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_align.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_align.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_aligner.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_aligner.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_attributes.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_attributes.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace_buffer.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace_buffer.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace_offload.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_backtrace_offload.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_bialign.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_bialign.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_bialigner.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_bialigner.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_components.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_components.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_affine.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_affine.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_affine2p.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_affine2p.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_edit.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_edit.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_linear.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_compute_linear.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_debug.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_debug.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_display.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_display.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_extend.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_extend.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_extend_kernels.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_extend_kernels.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_extend_kernels_avx.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_heuristic.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_heuristic.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_offset.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_pcigar.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_pcigar.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_penalties.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_penalties.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_plot.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_plot.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_sequences.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_sequences.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_slab.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_slab.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_termination.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_termination.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_unialign.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wavefront_unialign.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/backends/wfa2/wfa2lib/wavefront/wfa.h +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/colorops.py +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign/seqops.c +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign.egg-info/dependency_links.txt +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign.egg-info/entry_points.txt +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign.egg-info/requires.txt +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/prismalign.egg-info/top_level.txt +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/setup.cfg +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_colorops.py +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_parity.py +0 -0
- {prismalign-0.2.1 → prismalign-0.2.2}/tests/test_wfa2_backend.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prismalign
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: N-color (2-color / 3-color / 3-nt) nucleotide-conversion alignment engine with pluggable backends
|
|
5
5
|
Author-email: Chang Ye <yech1990@gmail.com>
|
|
6
6
|
License-Expression: GPL-3.0-only
|
|
@@ -29,19 +29,19 @@ or a custom 3rd channel) using a **HISAT-3N-style** strategy:
|
|
|
29
29
|
|
|
30
30
|
1. build a *converted* reference index (`scheme.ref_from → ref_to`)
|
|
31
31
|
2. transform each read per color channel and align it to the converted index
|
|
32
|
-
via a pluggable backend (**bwamem** by default;
|
|
33
|
-
|
|
32
|
+
via a pluggable backend (**bwamem** by default; **WFA2-lib**;
|
|
33
|
+
**minimap2/mappy**; **minibwa**, all optional)
|
|
34
34
|
3. **re-score every hit against the *original* reference** so that real
|
|
35
35
|
conversions are rewarded (not counted as mismatches), emitting a
|
|
36
36
|
color-correct `MD` plus per-channel `Y`/`Z` counts in BAM tags.
|
|
37
37
|
|
|
38
|
-
All per-read kernels are
|
|
39
|
-
|
|
38
|
+
All per-read heavy kernels are native C (BWA-MEM / WFA2-lib / minimap2 /
|
|
39
|
+
minibwa); the Python layer is a thin, friendly wrapper.
|
|
40
40
|
|
|
41
41
|
## Install
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
pip install -e . # bwamem + built-in C
|
|
44
|
+
pip install -e . # bwamem + built-in WFA2 C backends
|
|
45
45
|
pip install -e "./[mappy]" # + minimap2 backend
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ ps.map_reads("reads.fq", "ref.fa", "out.bam",
|
|
|
55
55
|
scheme="MK", backend="bwamem", threads=4)
|
|
56
56
|
|
|
57
57
|
# object API / reuse
|
|
58
|
-
with ps.NColorMapper(scheme=ps.BS, backend="
|
|
58
|
+
with ps.NColorMapper(scheme=ps.BS, backend="bwamem") as mapper:
|
|
59
59
|
mapper.map_file("reads.fq", ref_files=["ref.fa"], output_files=["bs.bam"])
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -103,24 +103,16 @@ against the original reference is engine-side), so adding one is easy:
|
|
|
103
103
|
|
|
104
104
|
| backend | engine | notes |
|
|
105
105
|
|---------|--------|-------|
|
|
106
|
-
| `bwamem` | BWA-MEM via the `bwamem` package | default, fast C backend |
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
>
|
|
115
|
-
>
|
|
116
|
-
> (subprocess) backends are `sam` (generic) and `strobealign` (ultra-fast short
|
|
117
|
-
> reads — no Rust→Python binding). `wfa2` reuses `PythonBackend`'s k-mer seeding
|
|
118
|
-
> to anchor a diagonal and runs WFA2's exact gap-affine alignment for true
|
|
119
|
-
> I/D CIGARs — the same "one core algorithm" as wfmash/gem3, minus the CLI
|
|
120
|
-
> layer. On exact / simple-mismatch reads every backend's output is identical;
|
|
121
|
-
> on gapped reads WFA2 may pick a *different-but-equally-valid* split of the
|
|
122
|
-
> M-runs around an indel than BWA (same position and I/D set), so byte-identity
|
|
123
|
-
> applies to the mapping, not to the exact CIGAR representation.
|
|
106
|
+
| `bwamem` | BWA-MEM via the `bwamem` package | default, fast C backend (SE + PE) |
|
|
107
|
+
| `minibwa` | **lh3/minibwa** (bwa-mem successor) via **PyO3 pip binding `minibwa`** (fg-labs) | ~2-3x faster than bwa-mem; `pip install minibwa` (SE + PE) |
|
|
108
|
+
| `mappy` | minimap2 via `mappy` | official minimap2 Python binding (SE + PE) |
|
|
109
|
+
| `wfa2` | **WFA2-lib** (vendored v2.3.6, MIT) compiled in-process | exact gapped (indel-aware) wavefront alignment; SE only |
|
|
110
|
+
|
|
111
|
+
> **Note on external-tool adapters.** `--backend` selects the four *native*
|
|
112
|
+
> in-process backends above. To wrap an aligner prismalign has no binding for
|
|
113
|
+
> (e.g. `bwa-mem2`, `bowtie2`, `hisat-3n`, `strobealign`), use
|
|
114
|
+
> `prismalign.adapters` (`SamAdapter`, `BwaMem2Adapter`, `Bowtie2Adapter`,
|
|
115
|
+
> `StrobealignAdapter`) — these are *not* `--backend`-selectable.
|
|
124
116
|
>
|
|
125
117
|
> Full inventory — including **where each Python wrapper lives** — is in
|
|
126
118
|
> [`docs/backends.md`](docs/backends.md).
|
|
@@ -135,6 +127,12 @@ against the original reference is engine-side), so adding one is easy:
|
|
|
135
127
|
is cached in memory for small contigs (RNA/transcript references), so only
|
|
136
128
|
one indexed read per contig.
|
|
137
129
|
|
|
138
|
-
## Limitations (v0.
|
|
130
|
+
## Limitations (v0.2.x)
|
|
139
131
|
|
|
140
|
-
* paired-end
|
|
132
|
+
* paired-end is supported natively by the `bwamem`, `mappy` and `minibwa`
|
|
133
|
+
backends; `wfa2` is single-end for now (the subprocess `sam`/
|
|
134
|
+
`strobealign`/`bowtie2`/`bwa_mem2` *adapters* are also SE).
|
|
135
|
+
* hierarchical (layered) mapping uses the `PLAIN` identity scheme for
|
|
136
|
+
non-converted short-RNA references. `minibwa` is the fastest native backend
|
|
137
|
+
but needs standard (non-free-threaded) CPython ≤ 3.13, so on 3.14t `mappy`
|
|
138
|
+
is the fastest available.
|
|
@@ -8,19 +8,19 @@ or a custom 3rd channel) using a **HISAT-3N-style** strategy:
|
|
|
8
8
|
|
|
9
9
|
1. build a *converted* reference index (`scheme.ref_from → ref_to`)
|
|
10
10
|
2. transform each read per color channel and align it to the converted index
|
|
11
|
-
via a pluggable backend (**bwamem** by default;
|
|
12
|
-
|
|
11
|
+
via a pluggable backend (**bwamem** by default; **WFA2-lib**;
|
|
12
|
+
**minimap2/mappy**; **minibwa**, all optional)
|
|
13
13
|
3. **re-score every hit against the *original* reference** so that real
|
|
14
14
|
conversions are rewarded (not counted as mismatches), emitting a
|
|
15
15
|
color-correct `MD` plus per-channel `Y`/`Z` counts in BAM tags.
|
|
16
16
|
|
|
17
|
-
All per-read kernels are
|
|
18
|
-
|
|
17
|
+
All per-read heavy kernels are native C (BWA-MEM / WFA2-lib / minimap2 /
|
|
18
|
+
minibwa); the Python layer is a thin, friendly wrapper.
|
|
19
19
|
|
|
20
20
|
## Install
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
pip install -e . # bwamem + built-in C
|
|
23
|
+
pip install -e . # bwamem + built-in WFA2 C backends
|
|
24
24
|
pip install -e "./[mappy]" # + minimap2 backend
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -34,7 +34,7 @@ ps.map_reads("reads.fq", "ref.fa", "out.bam",
|
|
|
34
34
|
scheme="MK", backend="bwamem", threads=4)
|
|
35
35
|
|
|
36
36
|
# object API / reuse
|
|
37
|
-
with ps.NColorMapper(scheme=ps.BS, backend="
|
|
37
|
+
with ps.NColorMapper(scheme=ps.BS, backend="bwamem") as mapper:
|
|
38
38
|
mapper.map_file("reads.fq", ref_files=["ref.fa"], output_files=["bs.bam"])
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -82,24 +82,16 @@ against the original reference is engine-side), so adding one is easy:
|
|
|
82
82
|
|
|
83
83
|
| backend | engine | notes |
|
|
84
84
|
|---------|--------|-------|
|
|
85
|
-
| `bwamem` | BWA-MEM via the `bwamem` package | default, fast C backend |
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
>
|
|
94
|
-
>
|
|
95
|
-
> (subprocess) backends are `sam` (generic) and `strobealign` (ultra-fast short
|
|
96
|
-
> reads — no Rust→Python binding). `wfa2` reuses `PythonBackend`'s k-mer seeding
|
|
97
|
-
> to anchor a diagonal and runs WFA2's exact gap-affine alignment for true
|
|
98
|
-
> I/D CIGARs — the same "one core algorithm" as wfmash/gem3, minus the CLI
|
|
99
|
-
> layer. On exact / simple-mismatch reads every backend's output is identical;
|
|
100
|
-
> on gapped reads WFA2 may pick a *different-but-equally-valid* split of the
|
|
101
|
-
> M-runs around an indel than BWA (same position and I/D set), so byte-identity
|
|
102
|
-
> applies to the mapping, not to the exact CIGAR representation.
|
|
85
|
+
| `bwamem` | BWA-MEM via the `bwamem` package | default, fast C backend (SE + PE) |
|
|
86
|
+
| `minibwa` | **lh3/minibwa** (bwa-mem successor) via **PyO3 pip binding `minibwa`** (fg-labs) | ~2-3x faster than bwa-mem; `pip install minibwa` (SE + PE) |
|
|
87
|
+
| `mappy` | minimap2 via `mappy` | official minimap2 Python binding (SE + PE) |
|
|
88
|
+
| `wfa2` | **WFA2-lib** (vendored v2.3.6, MIT) compiled in-process | exact gapped (indel-aware) wavefront alignment; SE only |
|
|
89
|
+
|
|
90
|
+
> **Note on external-tool adapters.** `--backend` selects the four *native*
|
|
91
|
+
> in-process backends above. To wrap an aligner prismalign has no binding for
|
|
92
|
+
> (e.g. `bwa-mem2`, `bowtie2`, `hisat-3n`, `strobealign`), use
|
|
93
|
+
> `prismalign.adapters` (`SamAdapter`, `BwaMem2Adapter`, `Bowtie2Adapter`,
|
|
94
|
+
> `StrobealignAdapter`) — these are *not* `--backend`-selectable.
|
|
103
95
|
>
|
|
104
96
|
> Full inventory — including **where each Python wrapper lives** — is in
|
|
105
97
|
> [`docs/backends.md`](docs/backends.md).
|
|
@@ -114,6 +106,12 @@ against the original reference is engine-side), so adding one is easy:
|
|
|
114
106
|
is cached in memory for small contigs (RNA/transcript references), so only
|
|
115
107
|
one indexed read per contig.
|
|
116
108
|
|
|
117
|
-
## Limitations (v0.
|
|
109
|
+
## Limitations (v0.2.x)
|
|
118
110
|
|
|
119
|
-
* paired-end
|
|
111
|
+
* paired-end is supported natively by the `bwamem`, `mappy` and `minibwa`
|
|
112
|
+
backends; `wfa2` is single-end for now (the subprocess `sam`/
|
|
113
|
+
`strobealign`/`bowtie2`/`bwa_mem2` *adapters* are also SE).
|
|
114
|
+
* hierarchical (layered) mapping uses the `PLAIN` identity scheme for
|
|
115
|
+
non-converted short-RNA references. `minibwa` is the fastest native backend
|
|
116
|
+
but needs standard (non-free-threaded) CPython ≤ 3.13, so on 3.14t `mappy`
|
|
117
|
+
is the fastest available.
|
|
@@ -17,7 +17,7 @@ Quick start
|
|
|
17
17
|
references="genome.fa",
|
|
18
18
|
output="out.bam",
|
|
19
19
|
scheme="MK", # or "BS", "SLAM", "A2G", "KM", "THREE"
|
|
20
|
-
backend="bwamem",
|
|
20
|
+
backend="bwamem", # "minibwa"(fast, opt-in), "mappy", "wfa2"
|
|
21
21
|
threads=4, # ordered parallel pool, byte-identical to 1
|
|
22
22
|
)
|
|
23
23
|
|
|
@@ -34,20 +34,26 @@ How it works (HISAT-3N-style "convert, then map"):
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
from . import colorops, schemes
|
|
37
|
+
from . import em as _em
|
|
38
|
+
from .em import em_allocate, EMResult, nm_from_md, read_nm
|
|
37
39
|
from .engine import NColorMapper, score_to_mapq
|
|
40
|
+
from . import adapters
|
|
41
|
+
from .adapters import (
|
|
42
|
+
SamAdapter,
|
|
43
|
+
StrobealignAdapter,
|
|
44
|
+
Bowtie2Adapter,
|
|
45
|
+
BwaMem2Adapter,
|
|
46
|
+
)
|
|
38
47
|
from .backends import (
|
|
39
48
|
RawHit,
|
|
40
49
|
Backend,
|
|
41
50
|
BwaMemBackend,
|
|
42
|
-
PythonBackend,
|
|
43
51
|
MappyBackend,
|
|
44
52
|
MinibwaBackend,
|
|
45
|
-
SamBinaryBackend,
|
|
46
53
|
Wfa2Backend,
|
|
47
|
-
StrobealignBackend,
|
|
48
54
|
get_backend,
|
|
49
55
|
)
|
|
50
|
-
from .schemes import MK, KM, BS, SLAM, A2G, THREE, ColorScheme, ColorChannel
|
|
56
|
+
from .schemes import MK, KM, BS, SLAM, A2G, THREE, PLAIN, ColorScheme, ColorChannel
|
|
51
57
|
|
|
52
58
|
# Single source of truth is pyproject.toml; never hardcode here.
|
|
53
59
|
try:
|
|
@@ -70,15 +76,23 @@ __all__ = [
|
|
|
70
76
|
"schemes",
|
|
71
77
|
"RawHit",
|
|
72
78
|
"Backend",
|
|
73
|
-
#
|
|
79
|
+
# EM expression-weighted multimapping allocation
|
|
80
|
+
"em_allocate",
|
|
81
|
+
"EMResult",
|
|
82
|
+
"nm_from_md",
|
|
83
|
+
"read_nm",
|
|
84
|
+
# native backends
|
|
74
85
|
"get_backend",
|
|
75
86
|
"BwaMemBackend",
|
|
76
|
-
"PythonBackend",
|
|
77
87
|
"MappyBackend",
|
|
78
88
|
"MinibwaBackend",
|
|
79
|
-
"SamBinaryBackend",
|
|
80
89
|
"Wfa2Backend",
|
|
81
|
-
|
|
90
|
+
# external-tool adapters (not selectable via --backend)
|
|
91
|
+
"adapters",
|
|
92
|
+
"SamAdapter",
|
|
93
|
+
"StrobealignAdapter",
|
|
94
|
+
"Bowtie2Adapter",
|
|
95
|
+
"BwaMem2Adapter",
|
|
82
96
|
# schemes
|
|
83
97
|
"MK",
|
|
84
98
|
"KM",
|
|
@@ -86,6 +100,7 @@ __all__ = [
|
|
|
86
100
|
"SLAM",
|
|
87
101
|
"A2G",
|
|
88
102
|
"THREE",
|
|
103
|
+
"PLAIN",
|
|
89
104
|
"ColorScheme",
|
|
90
105
|
"ColorChannel",
|
|
91
106
|
]
|
|
@@ -146,8 +161,8 @@ def map_reads(
|
|
|
146
161
|
scheme : str
|
|
147
162
|
Color scheme name: MK (default), KM, BS, SLAM, A2G, THREE.
|
|
148
163
|
backend : str
|
|
149
|
-
"bwamem" (default), "
|
|
150
|
-
|
|
164
|
+
"bwamem" (default), "minibwa" (fast, opt-in), "mappy", "wfa2". To wrap
|
|
165
|
+
an external SAM-emitting tool, use ``prismalign.adapters`` instead.
|
|
151
166
|
threads : int
|
|
152
167
|
Worker processes for the ordered parallel pool (output identical to 1).
|
|
153
168
|
batch_size : int
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""prismalign.adapters — external-tool adapters (NOT native alignment backends).
|
|
3
|
+
|
|
4
|
+
These are subprocess wrappers that adapt an **external** SAM-emitting aligner's
|
|
5
|
+
output to prismalign's ``Backend`` protocol (``align(seq) -> [RawHit]``), so the
|
|
6
|
+
engine — and its color re-scoring against the *original* reference — works on
|
|
7
|
+
them unchanged. They are deliberately **separate from ``prismalign.backends``**
|
|
8
|
+
(the native in-process engines: bwamem, minibwa, mappy, wfa2) and are *not*
|
|
9
|
+
selectable via ``--backend``; construct one directly when you need to wrap a
|
|
10
|
+
tool prismalign has no binding for (e.g. ``bwa-mem2``, ``bowtie2``,
|
|
11
|
+
``hisat-3n``, ``strobealign``).
|
|
12
|
+
|
|
13
|
+
Every adapter still conforms to the ``Backend`` interface, so it can be passed
|
|
14
|
+
to an ``NColorMapper`` via ``backend_kwargs``/a custom ``get_backend`` override.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from .sam import SamAdapter, _cigar_refspan, _sam_to_rawhits
|
|
18
|
+
from .strobealign import StrobealignAdapter
|
|
19
|
+
from .bowtie2 import Bowtie2Adapter
|
|
20
|
+
from .bwa_mem2 import BwaMem2Adapter
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"SamAdapter",
|
|
24
|
+
"StrobealignAdapter",
|
|
25
|
+
"Bowtie2Adapter",
|
|
26
|
+
"BwaMem2Adapter",
|
|
27
|
+
"_cigar_refspan",
|
|
28
|
+
"_sam_to_rawhits",
|
|
29
|
+
]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""prismalign.adapters.bowtie2 — subprocess adapter for the bowtie2 binary.
|
|
3
|
+
|
|
4
|
+
bowtie2 is a universal short-read aligner (present in nearly every conda env).
|
|
5
|
+
It is a *plain* aligner (no conversion chemistry), so prismalign does all
|
|
6
|
+
conversion itself — use it with any scheme (MK/BS/SLAM/...): prismalign builds
|
|
7
|
+
a converted reference, converts each read, and this adapter maps the converted
|
|
8
|
+
read to the converted index. Re-scoring against the original reference is
|
|
9
|
+
engine-side as usual.
|
|
10
|
+
|
|
11
|
+
Needs the ``bowtie2`` + ``bowtie2-build`` binaries on PATH (or ``BOWTIE2_BIN``).
|
|
12
|
+
A bowtie2 index is created on demand from the (converted) reference FASTA if
|
|
13
|
+
missing/stale.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
from ..sam import SamAdapter
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Bowtie2Adapter(SamAdapter):
|
|
22
|
+
"""bowtie2 via subprocess (plain aligner; conversion is engine-side).
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
fasta_path : str
|
|
27
|
+
The (converted) reference FASTA the engine hands us.
|
|
28
|
+
bin : str, optional
|
|
29
|
+
Path to the ``bowtie2`` binary (default ``$BOWTIE2_BIN`` or
|
|
30
|
+
``bowtie2`` on PATH). The index builder is ``<bin>-build``.
|
|
31
|
+
preset : str, optional
|
|
32
|
+
bowtie2 preset flags, e.g. ``"--very-sensitive"`` (default
|
|
33
|
+
``"--end-to-end"``).
|
|
34
|
+
extra_args : str, optional
|
|
35
|
+
Extra bowtie2 flags, e.g. ``"-p 4"``.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
name = "bowtie2"
|
|
39
|
+
|
|
40
|
+
def __init__(self, fasta_path, bin=None, build_bin=None, preset="--end-to-end", extra_args=""):
|
|
41
|
+
self.bin = bin or os.environ.get("BOWTIE2_BIN", "bowtie2")
|
|
42
|
+
self.build_bin = build_bin or self.bin + "-build"
|
|
43
|
+
self.preset = preset or "--end-to-end"
|
|
44
|
+
self.extra_args = extra_args or ""
|
|
45
|
+
self._idx_ready = False
|
|
46
|
+
super().__init__(fasta_path, command_template="", parse_conversion_tags=())
|
|
47
|
+
|
|
48
|
+
def _ensure_index(self):
|
|
49
|
+
"""Build the bowtie2 index from the reference FASTA if missing/stale."""
|
|
50
|
+
import subprocess
|
|
51
|
+
|
|
52
|
+
base = os.path.splitext(self.fasta_path)[0]
|
|
53
|
+
suffixes = (".1.bt2", ".2.bt2", ".rev.1.bt2", ".rev.2.bt2")
|
|
54
|
+
fa_mtime = os.path.getmtime(self.fasta_path)
|
|
55
|
+
fresh = all(
|
|
56
|
+
os.path.exists(base + s) and os.path.getmtime(base + s) >= fa_mtime
|
|
57
|
+
for s in suffixes
|
|
58
|
+
)
|
|
59
|
+
if not fresh:
|
|
60
|
+
build = subprocess.run(
|
|
61
|
+
[self.build_bin, "-f", self.fasta_path, base],
|
|
62
|
+
capture_output=True, text=True,
|
|
63
|
+
)
|
|
64
|
+
if build.returncode != 0:
|
|
65
|
+
raise RuntimeError(f"bowtie2-build failed: {build.stderr[:500]}")
|
|
66
|
+
self.command_template = (
|
|
67
|
+
f"{self.bin} -x {base} {self.preset} {self.extra_args} -U {{reads}} -S -"
|
|
68
|
+
)
|
|
69
|
+
self._idx_ready = True
|
|
70
|
+
|
|
71
|
+
def align(self, seq: str, min_mapq: int = 0) -> list:
|
|
72
|
+
self._ensure_index()
|
|
73
|
+
return super().align(seq, min_mapq=min_mapq)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""prismalign.adapters.bwa_mem2 — subprocess adapter for the bwa-mem2 binary.
|
|
3
|
+
|
|
4
|
+
bwa-mem2 is a ~3x faster drop-in replacement for BWA-MEM that emits identical
|
|
5
|
+
SAM. It is a *plain* aligner (no conversion chemistry), so prismalign does all
|
|
6
|
+
conversion itself — use it with any scheme (MK/BS/SLAM/...): prismalign builds
|
|
7
|
+
a converted reference, converts each read, and this adapter maps the converted
|
|
8
|
+
read to the converted index. Re-scoring against the original reference is
|
|
9
|
+
engine-side as usual.
|
|
10
|
+
|
|
11
|
+
Needs the ``bwa-mem2`` binary on PATH (or ``BWA_MEM2_BIN``). A bwa-mem2 index
|
|
12
|
+
is created on demand from the (converted) reference FASTA if missing/stale.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
|
|
17
|
+
from ..sam import SamAdapter
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BwaMem2Adapter(SamAdapter):
|
|
21
|
+
"""bwa-mem2 via subprocess (plain aligner; conversion is engine-side).
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
fasta_path : str
|
|
26
|
+
The (converted) reference FASTA the engine hands us.
|
|
27
|
+
bin : str, optional
|
|
28
|
+
Path to the ``bwa-mem2`` binary (default ``$BWA_MEM2_BIN`` or
|
|
29
|
+
``bwa-mem2`` on PATH).
|
|
30
|
+
extra_args : str, optional
|
|
31
|
+
Extra bwa-mem2 ``mem`` flags, e.g. ``"-t 4"``.
|
|
32
|
+
)
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
name = "bwa-mem2"
|
|
36
|
+
|
|
37
|
+
def __init__(self, fasta_path, bin=None, extra_args=""):
|
|
38
|
+
self.bin = bin or os.environ.get("BWA_MEM2_BIN", "bwa-mem2")
|
|
39
|
+
self.extra_args = extra_args or ""
|
|
40
|
+
self._idx_ready = False
|
|
41
|
+
super().__init__(fasta_path, command_template="", parse_conversion_tags=())
|
|
42
|
+
|
|
43
|
+
def _ensure_index(self):
|
|
44
|
+
"""Build the bwa-mem2 index from the reference FASTA if missing/stale."""
|
|
45
|
+
import subprocess
|
|
46
|
+
|
|
47
|
+
base = os.path.splitext(self.fasta_path)[0]
|
|
48
|
+
suffixes = (".amb", ".ann", ".bwt.2bit.64", ".pac", ".0123")
|
|
49
|
+
fa_mtime = os.path.getmtime(self.fasta_path)
|
|
50
|
+
fresh = all(
|
|
51
|
+
os.path.exists(base + s) and os.path.getmtime(base + s) >= fa_mtime
|
|
52
|
+
for s in suffixes
|
|
53
|
+
)
|
|
54
|
+
if not fresh:
|
|
55
|
+
proc = subprocess.run(
|
|
56
|
+
[self.bin, "index", self.fasta_path],
|
|
57
|
+
capture_output=True, text=True,
|
|
58
|
+
)
|
|
59
|
+
if proc.returncode != 0:
|
|
60
|
+
raise RuntimeError(
|
|
61
|
+
f"bwa-mem2 index failed: {proc.stderr[:500]}"
|
|
62
|
+
)
|
|
63
|
+
self.command_template = f"{self.bin} mem {self.extra_args} {{index}} -"
|
|
64
|
+
self._idx_ready = True
|
|
65
|
+
|
|
66
|
+
def align(self, seq: str, min_mapq: int = 0) -> list:
|
|
67
|
+
self._ensure_index()
|
|
68
|
+
return super().align(seq, min_mapq=min_mapq)
|
{prismalign-0.2.1/prismalign/backends → prismalign-0.2.2/prismalign/adapters}/sam/__init__.py
RENAMED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
2
|
+
"""prismalign.adapters.sam — generic subprocess adapter for SAM-emitting mappers.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Not a native backend: it wraps any external SAM-emitting aligner (via a command
|
|
5
|
+
template) and adapts its output to prismalign's Backend contract. Plus the
|
|
6
|
+
shared SAM-parsing helpers used by the other subprocess adapters.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from prismalign.backends.base import Backend, RawHit
|
|
5
10
|
|
|
6
11
|
|
|
7
12
|
def _cigar_refspan(cigar: str) -> int:
|
|
@@ -86,19 +91,26 @@ def _sam_to_rawhits(lines, parse_conversion_tags=(), default_name="SEQ"):
|
|
|
86
91
|
return hits
|
|
87
92
|
|
|
88
93
|
|
|
89
|
-
class
|
|
90
|
-
"""
|
|
94
|
+
class SamAdapter(Backend):
|
|
95
|
+
"""Adapter: drive any single-end SAM-emitting mapper as a subprocess.
|
|
96
|
+
|
|
97
|
+
This is NOT a native alignment backend — it shells out to an external
|
|
98
|
+
tool (via a command template) and adapts its SAM output to prismalign's
|
|
99
|
+
``Backend`` contract, so the engine can re-score against the original
|
|
100
|
+
reference as usual. Use it to wrap a mapper prismalign has no binding for
|
|
101
|
+
(e.g. ``bwa-mem2``, ``bowtie2``, ``hisat-3n``) without writing a new
|
|
102
|
+
backend.
|
|
91
103
|
|
|
92
104
|
``command_template`` is a format string; ``{index}`` is replaced by the
|
|
93
105
|
reference FASTA and ``{reads}`` by ``"-"`` (reads fed on stdin as one
|
|
94
106
|
FASTA record per align() call). Examples::
|
|
95
107
|
|
|
96
|
-
bwa:
|
|
97
|
-
bwa-mem2:
|
|
98
|
-
hisat-3n:
|
|
99
|
-
|
|
108
|
+
bwa: SamAdapter(ref.fa, "bwa mem {index} -")
|
|
109
|
+
bwa-mem2: SamAdapter(ref.fa, "bwa-mem2 mem {index} -")
|
|
110
|
+
hisat-3n: SamAdapter(ref.fa, "hisat-3n -x {index} "
|
|
111
|
+
"--base-change {base_change} -U {reads} -S -")
|
|
100
112
|
|
|
101
|
-
``parse_conversion_tags`` (e.g. ``("Yf","Zf")``) makes the
|
|
113
|
+
``parse_conversion_tags`` (e.g. ``("Yf","Zf")``) makes the adapter carry
|
|
102
114
|
a mapper's own conversion counts into the RawHit so the engine can use
|
|
103
115
|
them instead of re-scoring.
|
|
104
116
|
"""
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""strobealign
|
|
2
|
+
"""prismalign.adapters.strobealign — subprocess adapter (strobemers, fast short reads).
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
``.sti`` strobemer index on demand (unless present and fresh).
|
|
4
|
+
Wraps the ``strobealign`` binary (a subprocess adapter built on ``.sam``);
|
|
5
|
+
builds a ``.sti`` strobemer index on demand (unless present and fresh).
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
9
|
|
|
10
|
-
from ..sam import
|
|
10
|
+
from ..sam import SamAdapter
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
14
|
-
"""ultra-fast short-read aligner (strobemers)
|
|
15
|
-
|
|
16
|
-
``cargo build --release``;
|
|
17
|
-
index is created on demand
|
|
13
|
+
class StrobealignAdapter(SamAdapter):
|
|
14
|
+
"""ultra-fast short-read aligner (strobemers) via subprocess.
|
|
15
|
+
|
|
16
|
+
Needs the ``strobealign`` binary (bioconda or ``cargo build --release``;
|
|
17
|
+
also ``STROBEALIGN_BIN``). A ``.sti`` strobemer index is created on demand
|
|
18
|
+
from the converted reference.
|
|
18
19
|
"""
|
|
19
20
|
|
|
20
21
|
name = "strobealign"
|
|
@@ -9,19 +9,21 @@ C-extension wrap:
|
|
|
9
9
|
backend (``name``) package / C core what it binds
|
|
10
10
|
=================== ======================== ================================
|
|
11
11
|
``bwamem`` (default) ``bwamem/`` BWA-MEM via the ``bwamem`` pkg
|
|
12
|
-
``
|
|
12
|
+
``minibwa`` ``minibwa/`` lh3/minibwa (bwa-mem successor, C)
|
|
13
|
+
via PyO3 ``minibwa``
|
|
14
|
+
``mappy`` ``mappy/`` minimap2 via ``mappy``
|
|
13
15
|
``wfa2`` ``wfa2/`` + ``wrap.c`` + vendored WFA2-lib (gapped, C)
|
|
14
16
|
``wfa2lib/``
|
|
15
|
-
``mappy`` ``mappy/`` minimap2 via ``mappy``
|
|
16
|
-
``minibwa`` ``minibwa/`` lh3/minibwa via PyO3 ``minibwa``
|
|
17
|
-
``sam`` ``sam/`` generic SAM-emitting subprocess
|
|
18
|
-
``strobealign`` ``strobealign/`` strobealign subprocess
|
|
19
17
|
=================== ======================== ================================
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
These are the **native in-process** alignment backends. ``wfa2`` is the one we
|
|
20
|
+
compile ourselves (``wrap.c`` + vendored WFA2-lib) because no upstream Python
|
|
21
|
+
wrapper exists for that core; the rest wrap upstream bindings (``bwamem``,
|
|
22
|
+
``minibwa``, ``mappy``).
|
|
23
|
+
|
|
24
|
+
External-tool wrappers (subprocess adapters for mappers prismalign has no
|
|
25
|
+
binding for — ``bwa-mem2``, ``bowtie2``, ``hisat-3n``, ``strobealign``) live in
|
|
26
|
+
:mod:`prismalign.adapters`, NOT here, and are not selectable via ``--backend``.
|
|
25
27
|
|
|
26
28
|
The engine only needs a backend to provide ``align(seq) -> [RawHit]``
|
|
27
29
|
(optionally ``align_pe``), construction from a FASTA path (it builds/loads
|
|
@@ -33,10 +35,7 @@ from .base import Backend, RawHit, read_fasta
|
|
|
33
35
|
from .bwamem import BwaMemBackend
|
|
34
36
|
from .mappy import MappyBackend
|
|
35
37
|
from .minibwa import MinibwaBackend
|
|
36
|
-
from .python import PythonBackend
|
|
37
38
|
from .registry import _BACKENDS, get_backend
|
|
38
|
-
from .sam import SamBinaryBackend, _sam_to_rawhits
|
|
39
|
-
from .strobealign import StrobealignBackend
|
|
40
39
|
from .wfa2 import Wfa2Backend
|
|
41
40
|
|
|
42
41
|
__all__ = [
|
|
@@ -44,13 +43,9 @@ __all__ = [
|
|
|
44
43
|
"Backend",
|
|
45
44
|
"read_fasta",
|
|
46
45
|
"BwaMemBackend",
|
|
47
|
-
"PythonBackend",
|
|
48
46
|
"Wfa2Backend",
|
|
49
47
|
"MappyBackend",
|
|
50
48
|
"MinibwaBackend",
|
|
51
|
-
"SamBinaryBackend",
|
|
52
|
-
"StrobealignBackend",
|
|
53
49
|
"get_backend",
|
|
54
50
|
"_BACKENDS",
|
|
55
|
-
"_sam_to_rawhits",
|
|
56
51
|
]
|
|
@@ -64,8 +64,8 @@ class Backend(ABC):
|
|
|
64
64
|
def read_fasta(fasta_path: str):
|
|
65
65
|
"""Yield ``(name, sequence)`` for every contig of a plain FASTA file.
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
Used by the in-process ``wfa2`` backend, which parses the converted
|
|
68
|
+
reference itself. Sequence lines are uppercased.
|
|
69
69
|
"""
|
|
70
70
|
seq = []
|
|
71
71
|
name = None
|