Skip to content

pmdshodh 0.3.1

Choose a tag to compare

@github-actions github-actions released this 22 Nov 16:42
· 25 commits to main since this release
c495119

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

  • -r with a FASTA whose .fai no 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 -r could use gigabytes of memory or abort the run. It is now an input error at once (B3).
  • --pmdtools-compat now matches PMDtools 0.60 in five more cases. These are N over N with -r (B2), reads flagged unmapped that still have an alignment (B4), reads without reference bases (B5), hard-clipped reads (B6), and filter thresholds outside PMDtools' range, such as -t -1000000 (B7).

Install

pip install pmdshodh==0.3.1

Or 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_version 3 (was 2): reads.skipped has a new reason, no_reference_bases, counted only with --pmdtools-compat (see Fixed, B5). Other fields are unchanged. report reads versions 1 to 3.

Fixed

  • With -r, a FASTA that no longer matched its .fai index (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 faidx returns 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 -r treated an N read base over an N reference base as a match when it built the MD tag, but samtools calmd writes 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 from samtools calmd | pmdtools 0.60, by up to 0.085. They now match, with a largest difference of 2e-14. Default mode is unchanged, because N is 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-compat skipped 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-compat scored 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 to N (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 as skipped.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-compat scored reads with a hard clip (H) in their CIGAR, but PMDtools drops every such read, whatever its flags, with the message it prints for N and P CIGARs (rule found by black-box probes, docs/blackbox.md 1.6f). bwa mem writes hard clips on supplementary alignments: on the aligner sweep's bwa_mem_pe.bam, compat scored 197,064 reads against PMDtools' 197,046, and on bwa_mem_se.bam 95,177 against 95,168. Compat now drops them, counted as skipped.unsupported_cigar (or skipped.clips with --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-compat applied any --threshold or --upper-threshold, but PMDtools filters only when --threshold is above −10000 or --upperthreshold is 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 3 writes 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