Repository navigation
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