Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index bam before calling samtools idxstats; warn user if input lacks reads #102

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

tomkinsc
Copy link
Member

In read_utils.py::minimap2_idxstats(), warn the user if the input bam file lacks reads, and index the post-alignment post-filtering bam before calling samtools idxstats so minimap2_idxstats() succeeds if the input bam lacks reads. The minimap2 wrapper, tools/minimap2.py::Minimap2::align_bam(), tolerates empty input and indexes bam/cram output, but the post-filtering final bam in minimap2_idxstats was not being indexed, which led to a problematic exit-on-failure condition in a WDL command invoking the function. Also fix import of the InvalidBamHeaderError class used in several tool modules (add it to errors.py, and import the error subclasses where needed). This also runs minimap2 alignment when a read group lacks reads, since the newer version of minimap2 seems to better tolerate empty RGs. This allows samtools idxstats to yield zeros across the board for all input sequences when no reads are present, rather than only emitting the catchall "*" (which can cause issues downstream where metrics are expected)

…reads

in `read_utils.py::minimap2_idxstats()`, warn the user if the input bam file lacks reads, and index the post-alignment post-filtering bam before calling `samtools idxstats` so `minimap2_idxstats()` succeeds if the input bam lacks reads. The minimap2 wrapper, `tools/minimap2.py::Minimap2::align_bam()`, tolerates empty input and indexes bam/cram output, but the post-filtering final bam in minimap2_idxstats was not being indexed, which led to a problematic exit-on-failure condition in a WDL command invoking the function. Also fix import of the InvalidBamHeaderError class used in several tool modules (add it to errors.py, and import the error subclasses where needed).
This also runs minimap2 alignment when a read group lacks reads, since the newer version of minimap2 seems to better tolerate empty RGs. This allows samtools idxstats to yield zeros across the board for all input sequences when no reads are present, rather than only emitting the catchall "*" (which can cause issues downstream where metrics are expected)
@tomkinsc tomkinsc merged commit d176365 into master Jun 10, 2024
10 checks passed
@tomkinsc tomkinsc deleted the ct-bugfix-minimap2_idxstats branch June 10, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant