Repository navigation
Releases
pmdshodh 0.3.3
pmdshodh 0.3.3 has one fix, found by a new CRAM fuzz target written after the 0.3 audit (docs/audit-0.3.md, finding B10). Scores, kept reads and the JSON run summary (format_version 4) are unchanged from 0.3.2.
Fixed
- A corrupt or truncated CRAM is now an input error at once, instead of first allocating up to 2 GB. Before, a container claiming a body longer than the input made pmdshodh allocate the claimed length, up to 2 GB, before stopping with an input error. A corrupt 7.7 KB CRAM used 1.6 GB with
-@ 2(B10).
Install
pip install pmdshodh==0.3.3Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Fixed
- A CRAM container claiming a body longer than the input made pmdshodh allocate the claimed length, up to 2 GB, before stopping with an input error. A corrupt 7.7 KB CRAM used 1.6 GB with
-@ 2. The body is now read only as far as the input goes, so such a file is an input error (exit 2) at once, "container of N bytes is cut short", using memory only for the bytes it has. Output for valid CRAMs is unchanged. Found by fuzzing CRAM input in the 0.3 audit (docs/audit-0.3.md, B10).
What's Changed
- Read CRAM container bodies only as far as the input goes (audit B10) by @dpatel511 in #70
- Add a CRAM fuzz target (audit O4) by @dpatel511 in #71
- Prepare 0.3.3 by @dpatel511 in #72
Full Changelog: v0.3.2...v0.3.3
pmdshodh 0.3.2
pmdshodh 0.3.2 has the last two fixes from the 0.3 audit (docs/audit-0.3.md, findings B8 and B9), which is now complete. For valid input, default-mode scores and kept reads are unchanged from 0.3.1. The JSON run summary is now format_version 4.
Fixed
- A CRAM with a mapped read past the end of its reference sequence made pmdshodh crash (exit 101) while decoding it. It is now an input error (exit 2) that names the read, as with SAM and BAM (B9).
--pmdtools-compatnow drops reads whose SEQ is 1 base, as PMDtools 0.60 does, counted as the new skip reasontoo_short(B8).
Install
pip install pmdshodh==0.3.2Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Changed
- JSON run summary
format_version4 (was 3):reads.skippedhas a new reason,too_short, counted only with--pmdtools-compat(see Fixed, B8). Other fields are unchanged.reportreads versions 1 to 4.
Fixed
--pmdtools-compatscored reads whose SEQ is 1 base, but PMDtools 0.60 drops them silently, whatever their CIGAR operation, strand or flags. A 2-base SEQ with a single aligned base (1S1M,1M1I) is still scored (rule found by black-box probes, docs/blackbox.md 1.6g). Compat now drops them, counted asskipped.too_short, and leaves them out offilteroutput and the damage table, as PMDtools does. Default mode still scores them. Found by the 0.3 audit's edge-case map (docs/audit-0.3.md, B8).- A CRAM whose mapped read runs past the end of its reference sequence made pmdshodh panic while decoding it (exit 101), with
-@ 1and more threads. samtools writes such files and reads them back. Such a read is now an input error (exit 2) that names it, andfilterleaves no output, as with SAM and BAM input and-r. Output for valid CRAMs is unchanged. Found on a synthetic record by the 0.3 audit, while writing the reason for an untested check (docs/audit-0.3.md, B9).
What's Changed
- Map the audit edge-case matrix to tests by @dpatel511 in #63
- Drop 1-base reads in compat mode (audit B8) by @dpatel511 in #64
- Classify every default-vs-compat difference on real data by @dpatel511 in #65
- Run each audit property on 10,000 small cases by @dpatel511 in #66
- Reject CRAM reads past their reference end instead of panicking (audit B9) by @dpatel511 in #67
- Prepare 0.3.2 by @dpatel511 in #68
Full Changelog: v0.3.1...v0.3.2
pmdshodh 0.3.1
pmdshodh 0.3.1 has the fixes from the 0.3 audit (docs/audit-0.3.md, findings B1–B7). For valid input, default-mode scores and kept reads are unchanged from 0.3.0. The JSON run summary is now format_version 3.
Fixed
-rwith a FASTA whose.faino longer matches it (for example, rewrapped after indexing) gave wrong reference bases with no error. It is now an input error asking to index the FASTA again (B1).- An absurd CIGAR with
-rcould use gigabytes of memory or abort the run. It is now an input error at once (B3). --pmdtools-compatnow matches PMDtools 0.60 in five more cases. These areNoverNwith-r(B2), reads flagged unmapped that still have an alignment (B4), reads without reference bases (B5), hard-clipped reads (B6), andfilterthresholds outside PMDtools' range, such as-t -1000000(B7).
Install
pip install pmdshodh==0.3.1Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Changed
- JSON run summary
format_version3 (was 2):reads.skippedhas a new reason,no_reference_bases, counted only with--pmdtools-compat(see Fixed, B5). Other fields are unchanged.reportreads versions 1 to 3.
Fixed
- With
-r, a FASTA that no longer matched its.faiindex (for example, rewrapped after indexing) was read with wrong reference bases, with no error, from its second 1 MiB block on. In a synthetic 2.5 Mb test, one read scored 6.55 from 8 sites instead of −1.17 from 22.samtools faidxreturns wrong bases in this case too. pmdshodh now checks that every line break is where the index puts it, and that each sequence starts after its header line. A mismatch stops the run with an input error (exit 2) asking to index the FASTA again. This was already the case for CRAM input from an uncompressed FASTA, and now also covers bgzip-compressed FASTA. Output for correctly indexed FASTAs is unchanged. Found by the 0.3 audit (docs/audit-0.3.md, B1). --pmdtools-compat -rtreated anNread base over anNreference base as a match when it built the MD tag, butsamtools calmdwrites it as a mismatch. Only reads that also have PMDtools' combined-CIGAR reconstruction (docs/blackbox.md 1.6c) were affected: an insertion or soft clip together with a deletion, which shifts MD letters along the read. On 583 generated reads, 15 differed fromsamtools calmd | pmdtools0.60, by up to 0.085. They now match, with a largest difference of 2e-14. Default mode is unchanged, becauseNis never a C or G site. Found by the 0.3 audit (docs/audit-0.3.md, B2).- With
-r, a record whose CIGAR covers far more read bases than its SEQ had a per-base vector built before its length was checked. A 4,000,000,000-base insertion used 7.3 GB for 39 s before the error, and a 2×10¹⁶-base one aborted the run (exit 134) instead of stopping with an input error. CIGAR lengths are now checked first, and summed without overflow, so they can no longer wrap round to SEQ's length. The reference window end is computed with an overflow check too. Such records are now an input error (exit 2) at once, with or without-r. Valid reads are unaffected. Found by fuzzing in the 0.3 audit (docs/audit-0.3.md, B3). --pmdtools-compatskipped reads flagged unmapped that still have a CIGAR and MD tag, but PMDtools ignores flags and scores them. bwa writes such reads when they overhang a reference end, which is common with many short references. On a BAM of Motala3's chr21 reads aligned to 3,511 contigs of 10 kb, compat scored 307,139 reads against PMDtools' 309,320. It now scores them from MD, also with-r, and matches PMDtools on all 309,320 reads (largest difference 4.1e-14). Unmapped reads without an alignment, or with one that cannot be scored, are still counted as unmapped. Default mode still skips all unmapped reads; this is now listed as a departure in docs/design.md §5. Found by the 0.3 audit (docs/audit-0.3.md, B4).--pmdtools-compatscored reads that PMDtools drops with "bad reference sequence reconstruction": reads whose rebuilt reference has no uppercase A, C, G or T, for example reads aligned only toN(20 of 755,825 reads of ENA ERR4589292), reads made only of=bases, or reads with only lowercase MD letters (rule found by black-box probes, docs/blackbox.md 1.6e). Compat now drops them, counted asskipped.no_reference_bases. They have no informative sites, so no score changes and kept reads are unaffected. Default mode still scores them (0 from 0 sites). Found by the 0.3 audit (docs/audit-0.3.md, B5).--pmdtools-compatscored reads with a hard clip (H) in their CIGAR, but PMDtools drops every such read, whatever its flags, with the message it prints forNandPCIGARs (rule found by black-box probes, docs/blackbox.md 1.6f). bwa mem writes hard clips on supplementary alignments: on the aligner sweep'sbwa_mem_pe.bam, compat scored 197,064 reads against PMDtools' 197,046, and onbwa_mem_se.bam95,177 against 95,168. Compat now drops them, counted asskipped.unsupported_cigar(orskipped.clipswith--no-clips), and matches PMDtools by read name and flag on both files (largest difference 4.2e-14). No other read changes. Default mode still scores hard-clipped reads (departure D3, docs/design.md §5). Found by the 0.3 audit (docs/audit-0.3.md, B6).filter --pmdtools-compatapplied any--thresholdor--upper-threshold, but PMDtools filters only when--thresholdis above −10000 or--upperthresholdis below 1,000,000. Otherwise it acts as if neither was given and writes no reads (rule found by black-box probes, docs/blackbox.md 1.7b). So-t -1000000, a common way to keep every read, kept all reads in compat and none in PMDtools. Compat now keeps no reads in that case, and prints a note on stderr explaining why. Thresholds inside the range are unaffected:filter -t 3writes identical records before and after on three real BAMs, in both modes. Default mode still applies any finite bound. Found by the 0.3 audit (docs/audit-0.3.md, B7).
What's Changed
- Add the 0.3 audit plan by @dpatel511 in #49
- Add edge-case tests from the audit coverage map by @dpatel511 in #50
- Check FASTA line layout against its index (audit B1) by @dpatel511 in #51
- Write N over N as a mismatch in compat -r MD (audit B2) by @dpatel511 in #52
- Add property tests from the audit plan by @dpatel511 in #53
- Record the audit real-data matrix by @dpatel511 in #54
- Check CIGAR read length before allocating (audit B3) by @dpatel511 in #55
- Add fuzz targets from the audit plan by @dpatel511 in #56
- Score placed unmapped reads in compat mode (audit B4) by @dpatel511 in #57
- Record the audit's new test data and findings B4 and B5 by @dpatel511 in #58
- Drop reads without reference bases in compat mode (audit B5) by @dpatel511 in #59
- Drop hard-clipped reads in compat mode (audit B6) by @dpatel511 in #60
- Keep no reads for out-of-range compat thresholds (audit B7) by @dpatel511 in #61
- Prepare 0.3.1 by @dpatel511 in #62
Full Changelog: v0.3.0...v0.3.1
pmdshodh 0.3.0
pmdshodh 0.3.0 adds an HTML damage report. Scores, filtering and the JSON run summary format are unchanged from 0.2.4.
Highlights
- New
reportsubcommand.pmdshodh report run.json [more.json ...] -o report.htmlturns the JSON run summaries written bydamage -o,filter --summaryorscore --summaryinto one HTML page. It never re-reads the alignments. Per sample, the page shows:- the run settings;
- read counts, skipped reads by reason, flag counts and, with
-r, MD tag agreement; - damage by position in percent: 5′ C→T, and 3′ G→A for double-stranded or 3′ C→T for single-stranded libraries, with all other substitutions as a dashed baseline;
- the first-base C→T rate with its standard error;
- the PMD score histogram with the thresholds marked and, for
filter, the fraction of scored reads kept; - read lengths of scored reads and, for
filter, of kept reads in a chart of their own.
- Several samples in one report. An "All samples" section overlays the samples' damage curves and score histograms.
- Self-contained and reproducible. The page uses inline SVG, with no JavaScript, external files or network access, so it opens offline or as an e-mail attachment. The same summaries give a byte-identical page.
- Checkable. The JSON stays the source of truth: the report computes rates from its counts, and every plotted value is also in a
data-valuesattribute. - Older summaries work. Summaries from 0.1.x (
format_version1) are accepted, with the fields they lack shown as "not recorded". An invalid summary exits with status 2 and names the file and field.
Validation
The report was checked on:
- the nf-core/eager test BAMs: JK2782 (mammoth mtDNA) and JK2067 (human 1240k capture);
- a real single-stranded library: UKY001, MT.
A script recomputed every plotted number from the JSON counts: 117 checks, 0 failures. On the single-stranded library, the 3′ C→T curve shows the damage (19.5% at the last base) where 3′ G→A shows none (0.6%). Details are in docs/report-proposal.md §9.
Install
pip install pmdshodh==0.3.0Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Added
pmdshodh report run.json [more.json ...] -o report.html: an HTML damage report from one or more JSON run summaries (format_version1 or 2), without re-reading alignments.- Per sample: run settings, read counts, damage by position in percent (5′ C→T; 3′ G→A for ds, C→T for ss) against all other substitutions, the first-base C→T rate, the score histogram with thresholds and the kept fraction, and read lengths.
- Several summaries add overlay plots.
- One self-contained file with inline SVG and no JavaScript, byte-identical for the same summaries.
- Invalid summaries exit with status 2, naming the file and field.
- Outputs follow the same rules as the other subcommands: written by rename, removed on a signal, never written over an input.
- The JSON summary format is unchanged.
What's Changed
- Add HTML damage report (pmdshodh report) by @dpatel511 in #44
- Record the eager validation of the HTML report by @dpatel511 in #45
- Cap report figures at the chart width (B1) by @dpatel511 in #46
- Give kept read lengths their own chart (O1) by @dpatel511 in #47
- Prepare 0.3.0 by @dpatel511 in #48
Full Changelog: v0.2.4...v0.3.0
pmdshodh 0.2.4
pmdshodh 0.2.4 has two fixes. Scores are unchanged from 0.2.3.
Fixed
- Clean exit on Ctrl-C, SIGTERM or SIGHUP: an interrupted run, or one stopped by a scheduler's time limit, no longer leaves
<output>.pmdshodh-tmpfiles behind. The run still ends by that signal, so shells and schedulers see it as killed (status 130, 143 or 129). On Windows, Ctrl-C or Ctrl-Break removes the files and exits with status 130. - UDG-half damage tables in
--pmdtools-compatmode now match PMDtools 0.60. In UDG-half mode, PMDtools takes a C site's CpG context from the reference, not from the next read base. Before this fix, the table differed at positions 1–5 by up to 0.009. It now matches PMDtools to 5 decimals on the 1,500-read test set and on 200,000-read slices of two real libraries. Default-mode tables are unchanged.
Install
pip install pmdshodh==0.2.4Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Fixed
--pmdtools-compatdamage tables (damage,--summary) in UDG-half mode now match PMDtools 0.60--deamination --UDGhalf. PMDtools takes a C site's CpG context from the next reference base there, as in scoring, and only its--CpGtable uses the next read base. Compat had used the--CpGrule, so 57 of 1,500 fixture reads counted differently: the table differed at positions 1–5, by up to 0.009. The tables now agree to PMDtools' 5 decimals on the fixture and on the first 200,054 reads of BER11_L_NOuser and 200,012 of Motala3. Default-mode tables and all scores are unchanged.- A run ended by Ctrl-C, SIGTERM (a scheduler's time limit) or SIGHUP left its temporary files (
<output>.pmdshodh-tmp, and since 0.2.2 one for--summarytoo) behind. They are now removed, and the process still ends by the same signal, so the shell or scheduler sees it as killed (status 130, 143 or 129). On Windows, Ctrl-C or Ctrl-Break removes them and exits with status 130. New dependencies: signal-hook (Linux, macOS) and ctrlc (Windows).
What's Changed
- Remove temporary output files when a signal ends the run by @dpatel511 in #41
- Match PMDtools' UDG-half damage table in compat mode by @dpatel511 in #42
- Prepare 0.2.4 by @dpatel511 in #43
Full Changelog: v0.2.3...v0.2.4
pmdshodh 0.2.3
pmdshodh 0.2.3 is a small fix release. Scores are unchanged from 0.2.2.
Fixed
filterno longer adds a second CG tag to a read with more than 65,535 CIGAR operations when that read comes from BAM input (BAM stores such CIGARs in a CG tag). Before, the kept record grew by 4 bytes per operation, and samtools showed CG as an ordinary tag. Kept records are now written unchanged. This mostly affects long reads; SAM input and--tagwere not affected.
Also in this release
- Checks on real aligner output: reads aligned with bwa aln (eager's settings), bwa mem and bowtie2, then sorted, merged, marked for duplicates or converted to CRAM 3.0 and 3.1 with samtools. On 17 of the 18 files,
--pmdtools-compatmatches PMDtools 0.60 read by read (largest difference 4.2e-14, up to 199,865 reads per file) and keeps the same reads. Output is identical at 1 and 4 threads. - Clearer note when MD tags disagree with
-r. On bwa output this happens at referenceNbases, such as rCRS position 3107: bwa replaces them with a random base, so its MD tags give a base the reference doesn't have, and-ris right not to score that site. - Documented limitation:
--pmdtools-compatdoes not reproduce PMDtools on=read bases (samtools calmd -eoutput) for reverse-strand reads or for reads made only of=. Default mode with-rhandles=correctly.
Install
pip install pmdshodh==0.2.3Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Added
- Checks on the output of real aligners (WSL Ubuntu 24.04; bwa 0.7.19, bowtie2 2.5.5, samtools 1.25, PMDtools 0.60). 100,000 reads of ENA ERR3991018 (single-stranded, no UDG) were aligned to the rCRS (
MTof human_g1k_v37), single-end and as fully overlapping pairs.- The inputs were:
bwa aln(eager's-l 1024 -n 0.01),bwa mem(supplementary alignments with hard clips) andbowtie2(end-to-end,--local,-k 5);- then
samtoolssort, merge, markdup (single-end and paired), name-sort,calmd -e, and CRAM 3.0 and 3.1; - and 14 crafted reads: a 66,000 bp read with 66,000 CIGAR operations, 1,500 and 5,000 bp reads, IUPAC codes in reads and reference, an N run, a soft-masked region,
X/=and padding CIGARs, clips next to indels, a secondary read without SEQ, and a 1 bp read.
- For each input,
scoreandfiltergave the same output at-@ 1and-@ 4, with no NaN scores, and every output passedsamtools quickcheck. --pmdtools-compatagainst PMDtools, on the reads PMDtools scores: 0 reads above 1e-6 and identical kept reads on 17 of the 18 aligner outputs, all butcalmd -e(up to 199,865 reads each, largest difference 4.2e-14), and on the 7 crafted reads PMDtools can read. PMDtools crashed on the reads over 1,000 bp, a known PMDtools bug (docs/design.md §5).- The
calmd -eoutput differs in compat mode; this is documented instead of reproduced (docs/design.md §5). -ragainst MD: identical scores for bowtie2. For bwa output, about 1% of reads differ (968 of 99,935 single-end), all covering MT:3107. There the rCRS hasN, which bwa replaces with a random base when indexing, so its MD tags give that base;-rdoes not score the site.
- The inputs were:
Changed
- The stderr note on MD tags that disagree with
-rnames both usual causes: MD written before realignment, or against referenceNbases that the aligner replaced, as bwa does. It used to say "usually stale after realignment".
Fixed
filter: a read with more than 65,535 CIGAR operations, which BAM stores in a CG tag, gained a second CG tag when read from BAM and written as BAM or SAM (264,008 bytes more for 66,000 operations), so samtools showed CG as an ordinary tag. Kept records are now written unchanged. SAM input and--tagwere not affected.
What's Changed
- Keep one CG tag on long-CIGAR records; record the aligner sweep by @dpatel511 in #39
- Prepare 0.2.3 by @dpatel511 in #40
Full Changelog: v0.2.2...v0.2.3
pmdshodh 0.2.2
pmdshodh 0.2.2 fixes how the command line handles unusual output paths, bad options and bad input. Scores are unchanged from 0.2.1: on two real libraries (14.0 M and 23.6 M reads), scores and kept reads are byte-identical, and --pmdtools-compat still matches PMDtools 0.60.
Upgrade notes
- Data-loss fixes; update if you write to FIFOs, devices or symlinks, or might pass the input as the output:
- Output to an existing FIFO or device (
/dev/null,/dev/stdout,>(...),NULon Windows) is now written in place. Before, it could be replaced by a regular file: as root,-o /dev/fullreplaced the device node. - A symlink output now updates the file it points to.
- An output that is the input file is refused (exit 2). It used to overwrite the input.
- Output to an existing FIFO or device (
- Input with no data at all (0 bytes or empty stdin) is now an input error (exit 2), as in samtools. A file with only a header is still valid.
pmdshodh score in.bam | headnow stops quietly with exit 141, as samtools does. Before, it printed "Broken pipe" and exited 1. Underset -o pipefailthis still counts as a failure, as it does with samtools.- New limits:
--rangeis at most 1000 and-@at most 1024.--pmd-p+--pmd-cmust be at most 1. Larger values gave NaN scores, whichfiltersilently dropped.--thresholdand--upper-thresholdmust be finite.
Also in this release
- First check on a real single-stranded library (ENA PRJEB37007, no UDG): on 14.7 M reads,
--library ss --pmdtools-compatmatches PMDtools--ssread by read (largest difference 8.2e-14), and the kept reads are identical. filter -o /dev/null --summary run.jsonwrites only the summary..BAMand.SAMextensions work in any case.- Clearer errors:
- FASTQ, FASTA and binary input are named as such.
- A BAM cut mid-block says it is probably truncated.
- A kept read whose reference is not in the header is named.
- A bad
--summarypath fails before any read is processed.
Install
pip install pmdshodh==0.2.2Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Added
- Real-data check of single-stranded scoring, on library UKY001.B0102 (ENA PRJEB37007, single-stranded and not UDG-treated per its ENA record). Its damage pattern fits that: C→T at both ends (25.5% at the 5′ and 17.7% at the 3′ terminal base of the 1240K BAM), G→A at 1.3% or below. PMDtools 0.60
--sswas run under WSL Ubuntu 24.04, and every read was compared.score --library ss --pmdtools-compatagainst--printDS --ss: 0 reads above 1e-6 on the mtDNA BAM (ERR3991018, 281,906 reads, largest difference 6.2e-14) and on the 1240K-capture BAM (ERR3977849, 14,461,790 reads, 8.2e-14).filter --library ss --pmdtools-compat --threshold 3keeps the same reads as--threshold 3 --ss, identical including tags: 162,734 and 7,169,568.- In default mode, which scores each C site once,
--threshold 3keeps 117,380 and 5,327,200 reads. All but 2 of those are also kept by PMDtools, and 1,842,370 reads kept by PMDtools are not. Every read with an informative site scores differently from PMDtools; the reads that score the same have none. filter --library ssoutput is identical at-@ 1and-@ 8.
Changed
- Input with no data at all (0 bytes, or empty standard input) is an input error (exit 2), as in samtools; it usually means an upstream step failed. Input with only a header is still valid and gives empty output.
- When the reader of standard output closes it early (
pmdshodh score in.bam | head), pmdshodh stops without a message and exits 141, as samtools does when SIGPIPE ends it. Before, it printed "cannot write output: Broken pipe" and exited 1. - Options are checked before any input is read:
--pmd-p+--pmd-c, the damage rate at the read end, must be at most 1. Larger values gave NaN scores, whichfiltersilently dropped;--pmd-p 1with the default--pmd-c 0.01did this for 1,081 of 2,912 reads.--thresholdand--upper-thresholdmust be finite numbers:-t nanused to keep nothing.--rangeis at most 1000 (--range 100000000was killed for lack of memory), and-@at most 1024 (-@ 100000tried to start threads for 4 minutes, then failed).- A negative value given with a space (
--pmd-p -0.1) gets the range message instead of "unexpected argument '-0'".
filteroutput format:.BAMand.SAMextensions are accepted in any case. Devices have no extension, so--output-formatdecides there as for stdout, BAM by default:-o /dev/null --summary run.jsonkeeps only the summary.--output-formatthat contradicts the extension, and-o x.cram, are input errors instead of being ignored or reported as an unknown format.- Error messages name the path given, not the temporary file (
out.bam.pmdshodh-tmp). Input that is not SAM, BAM or CRAM is reported as such ("it looks like FASTQ", "it looks like FASTA", "it is binary data") instead of "invalid header: invalid record" or "record 1: unexpected EOL", and a BAM cut inside a BGZF block says that the file is probably truncated.
Fixed
- Output to an existing FIFO or device was renamed over it:
filter -o x.samreplaced a FIFO namedx.sam(its reader got nothing), and as rootscore -o /dev/full,--summaryordamage -oto a device replaced the device node with a regular file. A symlink output was replaced by a regular file instead of updating its target (forscoresince 0.2.1, which madescore -owrite by rename;filter,damageand--summaryalready did this), andscore -o >(...)failed (since 0.2.1).-o /dev/stdoutfailed for users other than root, and-o NULon Windows failed ("cannot move the file to a different disk drive"). Only regular files are now written under a temporary name and renamed; a symlink is followed, and anything else is written in place. - An output that is the input file (also through
./, and on Linux and macOS through a hard link) replaced the input with exit 0:filter -t 3 same.bam -o same.bamleft 34 of 2,912 reads. This, the reference as output, and one file given for two outputs (-o x.bam --summary x.bam) are now input errors. --summary(anddamage -o) are created before the first record is read. A summary in a missing directory used to fail only after the whole run, with the BAM already written and exit 1.filter: a kept read whose reference or mate's reference is not an@SQline of the header is an input error that names the read (exit 2). It used to fail with "cannot write output: invalid reference sequence name" (exit 1).scoreanddamagedo not write records and still read SAM without a header (samtools view in.bam | pmdshodh score -).- docs/benchmarks.md said 32 checks passed in the 0.2.1 round:
check.pyran 24 checks, all passed, and printed 8 informational lines. docs/benchmarks/check.pyfails on a NaN or infinite score; it used to count it as a small difference. No NaN or infinite score was found in any earlier benchmark or parity output.
What's Changed
- Record the --ss parity check on a real single-stranded library by @dpatel511 in #36
- Fix output paths, validation and messages found by a CLI audit by @dpatel511 in #37
- Prepare 0.2.2 by @dpatel511 in #38
Full Changelog: v0.2.1...v0.2.2
pmdshodh 0.2.1
pmdshodh 0.2.1 is a bug-fix and speed-up release. Scores of BAMs with MD tags are unchanged, and --pmdtools-compat still matches PMDtools 0.60: in the benchmark round on this release, per-read scores agreed on 37.6 M real reads (largest difference 6.0e-14), and the kept reads were identical.
Upgrade notes
Two inputs that used to be read silently now stop with an input error (exit 2):
- Truncated BAM or bgzipped SAM. A file that ends without the BGZF end-of-file marker was read up to the cut with exit 0; now it is an error, and
filterleaves no output file. Recreate or re-download the file. =read bases without-r. Reads stored with=for bases equal to the reference (assamtools calmd -ewrites them) need the reference: pass-r ref.fa. With-r, those reads are now scored from their reference bases, so their default scores change.--pmdtools-compatkeeps PMDtools' behaviour.
Highlights
- Faster, with identical output (medians of 5 alternating runs on 2 M reads, i5-13500H laptop, WSL):
- damage tables for
--summary: 9.16 → 8.33 s; --library ss: 6.98 → 5.53 s;- CRAM input with
-rat-@ 8(14 M reads): 45.9 → 38.8 s.
- damage tables for
- Less memory for CRAM against references with many small contigs: 1,010 → 392 MB on a synthetic 10,000-contig reference.
- New benchmark round (docs/benchmarks.md), on two real libraries of 14.0 M and 23.6 M reads, one laptop:
filterwas 32–39× faster than the PMDtools pipeline on one thread and 208–217× faster on 8;- on one thread,
scorewas faster than metaDMGpmdin all 10 alternating pairs (48.8 vs 61.7 s and 60.6 vs 71.9 s). - The PMDtools timings were measured on 2026-11-13 on the same laptop.
- Clearer errors:
score -ono longer leaves a partial table after a failed run, and plain gzip input is named as such.
Install
pip install pmdshodh==0.2.1Or download the binary for your platform below and check it against SHA256SUMS. A Bioconda package is still to come.
Changes
Added
- Benchmarks of
--library ss,-rand CRAM input, and a new benchmark round on this release: docs/benchmarks.md.
Changed
- Read bases written as
=(same as the reference, assamtools calmd -ewrites them) are scored in default mode. With-rthey take their reference base; without-ra read with=bases is an input error naming-r, because MD does not give their reference bases. PMDtools never counts=as C or G: a read with nine=at reference C scored 5.03 from 1 site instead of 4.22 from 10.--pmdtools-compatkeeps that. Kept records are written with their=bases. - Damage tables (
--summary,damage) count only positions within--rangeof the read ends instead of looking at every base. Output is identical.score -@ 1 --summaryon 2 M BER11_L_NOuser reads: median 9.16 → 8.33 s (5 alternating runs each; WSL Ubuntu 24.04, i5-13500H). - CRAM input: reference sequences are checked against the header
M5on the thread pool instead of the reading thread.score -@ 8 -ron BER11_L_NOuser.cram: median 45.9 → 38.8 s (5 alternating runs each; WSL Ubuntu 24.04, i5-13500H). A wrong reference is still an input error before any record of the batch is used. - Single-stranded scoring (
--library ss) is faster. The damage, error and null terms are computed once per run instead of at every site (bit-identical), and reads are no longer copied into molecule orientation.score -@ 1 --library sson 2 M BER11_L_NOuser reads: median 6.98 → 5.53 s (5 alternating runs each; WSL Ubuntu 24.04, i5-13500H).
Fixed
- BGZF input (BAM, bgzipped SAM) that ends without the end-of-file marker is now an input error (exit 2), and
filterleaves no output file. Before, a file cut at a block boundary was read silently: on a samtools-written BAM cut that way, 1,261 of 1,500 reads were scored with exit 0. samtools only warns in this case. CRAM input cut before its end-of-file container was already an error. score -o FILEwrites under a temporary name and renames on success, asfilterdoes, so a failed run no longer leaves a partial table.- gzip-compressed input that is not BGZF (as
gzipwrites it) is reported as such, with a hint to recompress with bgzip, instead of "invalid BGZF header". - CRAM input: the cache of whole reference sequences is also cleared past its limit (256 Mi bases) when a batch has only multi-reference containers, as samtools writes for many small contigs. Before, such input kept every sequence it had used, up to the whole reference. On a synthetic 1 Gb reference of 10,000 contigs (100 multi-reference containers, samtools 1.25), peak RSS of
score -@ 4 -rfell from 1,010 MB to 392 MB, with identical scores.
What's Changed
- Download only wheels and the sdist for PyPI on a tag push by @dpatel511 in #27
- Reject BGZF input without the end-of-file marker by @dpatel511 in #28
- Score '=' read bases from -r; reject them without it by @dpatel511 in #29
- Write score -o atomically; name plain gzip input by @dpatel511 in #30
- Count damage only within --range of the read ends by @dpatel511 in #31
- Clear the CRAM sequence cache for multi-reference batches too by @dpatel511 in #32
- Check CRAM M5 checksums on the thread pool by @dpatel511 in #33
- Speed up single-stranded scoring by @dpatel511 in #34
- Prepare 0.2.1: benchmark round and release notes by @dpatel511 in #35
Full Changelog: v0.2.0...v0.2.1
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
pmdshodh 0.1.0
Install
pip install pmdshodhOr download the archive for your platform below and check it against SHA256SUMS. Linux builds need glibc 2.17 or newer (CentOS/RHEL 7 and later).
First release.
Added
filtercommand: keep reads by PMD score and write SAM or BAM, with an@PGheader line and an optional score tag.scorecommand: per-read PMD scores as TSV.damagecommand: JSON run summary only.- PMD score following the likelihood model of Skoglund et al. (2014), with PMDtools-compatible options for double-stranded and single-stranded libraries and CpG/UDG-treated data.
--pmdtools-compatto reproduce PMDtools 0.60 exactly, including its known bugs, for comparisons.- Multi-threaded scoring and BGZF compression; output is identical for any thread count.
- JSON run summary (
format_version1) with read counts, skipped reads by reason, a score histogram and damage tables. - Parity tests against PMDtools on synthetic and real reads.
- Prebuilt binaries on GitHub Releases for Linux x86_64 and aarch64 (glibc 2.17 or newer), macOS arm64 and x86_64, and Windows x86_64, with SHA-256 checksums. Scores agree across these platforms to within 2e-15: Linux and macOS give byte-identical output on the test fixture, and Windows differs in the last digits.
- Minimum supported Rust version 1.91 (the minimum of noodles 0.119), declared in
Cargo.tomland tested in CI. The README used to say 1.85, which was never true. - README, design notes, benchmark plan and roadmap.
Changed
--ssscores each C site once, following the paper's single-stranded model (SI Eq. S1). PMDtools 0.60 adds the double-stranded term as well, which roughly doubles ss scores and makes them depend on which end the damage is at. Default ss scores are therefore lower than PMDtools';--pmdtools-compatkeeps PMDtools' scores.filter --upper-thresholdno longer keeps reads with no informative sites; they carry no evidence of being undamaged. They are still counted asno_informative_sites.--pmdtools-compatkeeps them, as PMDtools does.- Faster scoring, with byte-identical output: double-stranded site terms are precomputed once per run, damage counting no longer copies each read, and BAM records are read directly instead of through the generic record interface. On the first 2,000,000 reads of ENA ERR1892229 (i5-13500H laptop, WSL, medians of 7 interleaved runs),
score -@ 1went from 11.05 s to 8.19 s,filter -@ 1from 10.71 s to 7.29 s andfilter -@ 8from 3.00 s to 2.18 s. - With
-@above 1, reading, scoring and output now overlap (a reader thread and a scoring thread run alongside output), so multi-threaded runs scale further;-@ 1is unchanged. Output is byte-identical; peak memory rises from 12–22 MB to 21–33 MB (at most three batches of 10,000 records in flight). On the first 2,000,000 reads of ENA ERR1892229 (i5-13500H laptop, WSL, medians of 5 interleaved runs, monotonic clock),score -@ 8went from 3.08 s to 1.75 s andfilter -t 3 -@ 8from 2.03 s to 1.45 s. -@ Nnow means at most N threads doing work at once, so pipelines can pass their CPU allocation.- Before, scoring, BGZF decompression and BGZF compression each had their own pool of N threads, and
-@ 8used about 9 cores. - They now share one pool. The new
src/bgzf.rscompresses exactly as noodles-bgzf did, so output bytes are unchanged. - At the same
-@, runs are slower than before because they use fewer cores. For the same number of cores they are as fast or faster. - Measured on the first 2,000,000 reads of ENA ERR1892229 (i5-13500H laptop, WSL, medians of 5 interleaved runs, monotonic clock):
score -@ 8: 1.71 s on 6.3 cores (before: 1.65 s on 7.9);filter -t 3 -@ 8: 1.45 s on 7.1 cores (before: 1.38 s on 9.4);filter -t 3 -@ 12: 1.25 s on 9.6 cores (before: 1.33 s on 10.2);filter -t 3 -@ 1: 7.58 s → 8.43 s (it used to take 1.2 cores).
- Peak memory at
-@ 8is 33–38 MB, because up to four batches are in memory.
- Before, scoring, BGZF decompression and BGZF compression each had their own pool of N threads, and
- Errors for MD tags that disagree with the alignment now suggest recomputing MD with
samtools calmd. Such tags are usually stale after realignment. scoreandfiltercount damage tables only when--summaryis given; thedamagecommand always counts them. Output is byte-identical. On the first 2,000,000 reads of BER11_L_NOuser (i5-13500H laptop, WSL, medians of 5 interleaved runs, monotonic clock):score -@ 1: 8.77 s → 6.18 s (metaDMGpmd -@ 1: 8.23 s; before the shared thread pool: 8.68 s);filter -t 3 -@ 1: 8.77 s → 6.17 s (before the shared thread pool: 7.95 s);score -@ 8: 1.60 s → 1.26 s;filter -t 3 -@ 8: 1.42 s → 1.04 s;- with
--summary, unchanged (1.43 s forfilter -t 3 -@ 8).
- Each command's
--helpgroups its options under headings (Output, Filtering, Summary, Scoring model, Read filters, Performance) and ends with examples. A test runs every example. Usage lines saypmdshodhon every platform. --range 0is rejected as invalid input (exit 2) before any input is read; it used to give empty damage tables.
Fixed
--pmdtools-compatwith several threads no longer slows down 2–5× from contention on glibc's allocator lock. The shared thread pool above made this worse, and the fix sizes compat's per-read buffers up front instead of growing them. On BER11_L_NOuser (14.0 M reads, 5 alternating runs),filter --pmdtools-compat -@ 8took 10.8–11.8 s instead of 23.9–66.6 s. Scores are unchanged.score -o -writes to stdout; it used to create a file named-.--pmdtools-compatnow also reproduces PMDtools 0.60 for lowercase reference bases in MD (never counted as C or G) and for reverse-strand reads whose MD contains characters PMDtools drops when reverse-complementing (e.g. lowercasen). Default scoring is unchanged; both are listed as departures in docs/design.md.