Skip to content

v2.9.7: fix fiberhmm-extract crash on malformed MD tags

Choose a tag to compare

@mtcicero26 mtcicero26 released this 22 Apr 16:50
· 483 commits to main since this release

Bug fix

fiberhmm-extract now swallows pysam AssertionError when a read carries a malformed MD tag, skipping that read's deamination extraction instead of aborting the entire region worker.

Symptom (user-reported field crash):

Traceback (most recent call last):
  File ".../fiberhmm/cli/extract_tags.py", line 214, in _extract_region_worker
    n_features['deam'] += _extract_deam(...)
  File ".../fiberhmm/cli/extract_tags.py", line 688, in _extract_deam
    pairs = read.get_aligned_pairs(with_seq=True)
  ...
AssertionError: Invalid MD tag: MD length 37729 mismatch with CIGAR length 43799 and 9742 insertions

Root cause: the path-3 MD walker in _extract_deam (added in v2.9.6 for DAF-seq BAMs that only carry MD mismatches, no MM/ML and no R/Y) caught ValueError/AttributeError but not AssertionError, which is what pysam throws when MD/CIGAR lengths disagree internally.

Fix: broaden the exception handler to Exception. Affected reads now skip the deam track silently; all other tracks (footprint, msp, tf, m6a, m5c) still extract for those reads.

Regression test pinned: tests/test_extract_block_scores.py::test_deam_priority3_skips_read_on_pysam_assertion_error.

Install

pip install --upgrade fiberhmm

Affects only v2.9.6 (which introduced path-3). Earlier versions never touched MD tags, so they weren't exposed to this bug.