Repository navigation
pmdshodh 0.2.0
Reference-based scoring (-r) and CRAM input: pmdshodh filter -r ref.fa in.bam replaces samtools calmd | pmdtools | samtools view.
Added
-r, --reference FILE: take reference bases from an indexed FASTA (samtools faidx; bgzip with.gzitoo) instead of MD tags, so reads need no MD tag. MD tags that are present are compared with the reference; disagreeing (usually stale) tags are reported on stderr and counted in the summary, and those reads are scored from the reference. Every header sequence must be in the index with the same length; this is checked before any record is read. With--pmdtools-compat, the reference bases go through an MD tag written the waysamtools calmdwrites it (reference bases in uppercase, soft-masked ones included), so scores match PMDtools run on calmd output.- CRAM input for
filter,scoreanddamage, detected from the file contents and decoded with-r(required). Each reference sequence is checked against the header'sM5checksum when it is loaded (and single-reference slices against their own MD5), so a different reference is an input error. Containers are decoded on the thread pool; output is identical for any thread count.filterstill writes SAM or BAM.- Kept records are written as stored in the CRAM: MD and NM tags that htslib left out (it regenerates them on decoding) are not added back.
- CRAM decoding loads whole reference sequences: with
score -@ 8 -r, peak RSS was 1,181 MB on BER11_L_NOuser.cram and 1,247 MB on Motala3.cram, against 110 MB and 105 MB for the same BAMs (median of 3 runs; MB = 1024 KiB, as in docs/benchmarks.md). TheM5check added about 19% to CRAM wall time (median of 3: 35.6 → 42.3 s and 54.5 → 64.7 s at-@ 8).
- PyPI packaging: wheels that carry the
pmdshodhbinary (Linux x86_64 and aarch64 with glibc 2.17 or newer, macOS arm64 and x86_64, Windows x86_64), built and published by a workflow with PyPI trusted publishing. 0.1.0 was published to PyPI on 2026-11-15 from thev0.1.0tag. - Real-data checks of
-r: samtools calmd and PMDtools 0.60 under WSL Ubuntu 24.04, every read compared.- BER11_L_NOuser (14,006,183 reads, soft-masked equCab2) and Motala3 (23,622,338 reads, human_g1k_v37):
-ron the original BAM against the MD path on calmd output gives 0 reads differing in score or site count in default mode on both. In--pmdtools-compat, Motala3 also has 0 differing reads. - PMDtools on calmd output against
--pmdtools-compat -r: Motala3 has 0 reads above 1e-6 (largest difference 4.97e-14). BER11 has 339 above 1e-6. All 339 have an MD tag in the input BAM with lowercase reference bases; calmd left those tags as they were, and PMDtools never counts a lowercase base as C or G. With MD removed from those reads (483 have lowercase MD) and recomputed by calmd, PMDtools and--pmdtools-compat -ragree on all 483 (largest difference 2.29e-14). - Motala3 has 107 reads whose MD tag disagrees with the reference.
- BER11_L_NOuser (14,006,183 reads, soft-masked equCab2) and Motala3 (23,622,338 reads, human_g1k_v37):
- Real-data check of CRAM: samtools 1.25 CRAMs of BER11_L_NOuser and Motala3 give byte-identical
score -routput to their BAMs (14,006,183 and 23,622,338 reads; default and--pmdtools-compatat-@ 8, default at-@ 1).filter -r -t 3keeps 1,029,380 and 301,706 reads, identical in every field and tag tosamtools view --input-fmt-option decode_md=0of the same CRAMs. Unit tests decode CRAM 3.0 and 3.1 files written by samtools, including one with a multi-reference slice, a proper pair and an unmapped read, and an empty CRAM.
Changed
- JSON run summary
format_version2 (was 1). New fields:input_format(sam,bamorcram), and areferencesection with the-rpath, whether reference bases came from MD tags or the FASTA, and (with-r) how many scored reads had MD tags that agree, disagree or are absent. For CRAM, the MD tag counts cover only MD tags stored in the file. Fields from version 1 are unchanged. - The error for a mapped read without an MD tag now suggests
-ras well assamtools calmd.
What's Changed
- Add PyPI packaging for the pmdshodh binary by @dpatel511 in #20
- Document pip install now that 0.1.0 is on PyPI by @dpatel511 in #21
- Agree the -r/CRAM design and narrow the positioning by @dpatel511 in #22
- Score from a reference FASTA with -r by @dpatel511 in #23
- Read CRAM input with -r by @dpatel511 in #24
- Check CRAM reference sequences against the header's M5 by @dpatel511 in #25
- Prepare v0.2.0 by @dpatel511 in #26
Full Changelog: v0.1.0...v0.2.0