Repository navigation
v2.8.2: numba CIGAR walker for fiberhmm-extract
⚠️ Reverse-strand MM/ML parsing bug — UPGRADE TO v2.9.0
Versions 2.6 – 2.8.2 had a parser bug that shifted m6A/m5C modification positions on reverse-aligned reads (~24 bp median), causing ns/nl/as/al/MA/AQ tags to be wrong on reverse reads. Forward reads unaffected. DAF with IUPAC (R/Y) encoding unaffected.
Upgrade: pip install --upgrade fiberhmm (v2.9.0+). See v2.9.0 release notes for details.
fiberhmm-extract 2-3× faster via numba CIGAR walker
`read.get_aligned_pairs()` allocates O(read_length) Python tuples per read — for PacBio 20 kb reads, that's ~20,000 tuple objects just to build the query→ref mapping needed for every extractor. Replaced with a numba-JIT'd CIGAR walker that returns a numpy int64 array indexed by query position.
Benchmarks on Mac /tmp (`fiberhmm-extract --all -c 4 --bed-only`)
| Test BAM | v2.8.1 | v2.8.2 | Speedup |
|---|---|---|---|
| DddB (22,913 reads) | 6.1s | 1.9s | 3.2× |
| Hia5 (1,225 reads) | 3.0s | 1.8s | 1.7× |
Correctness
- `cigar_to_query_ref` vs `pysam.get_aligned_pairs` on 100-read subsets of both test BAMs: 2,206,382 / 2,206,382 positions match exactly.
- All 8 extract BED outputs (footprint/msp/tf per enzyme + m6a/m5c for hia5) are byte-identical to v2.8.1 sorted output.
Also added: `parse_mm_ml_per_mod_type` (experimental)
A vectorized numpy alternative to `pysam.modified_bases` lives in `fiberhmm/core/bam_reader.py` but is not used by extract. Flagged experimental because it doesn't replicate pysam's reverse-strand position flip exactly — query positions differ from pysam's for reverse-strand reads. Fine for apply/recall's HMM semantics (where A+a and T-a are treated equivalently) but not position-exact for downstream BED extraction. Available for future use if the HMM paths want to drop the pysam dependency entirely.
Install
```bash
pip install --upgrade fiberhmm
```
🤖 Generated with Claude Code