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

Add piped input tests for RevertSam, MergeBamAlignment #1974

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

takutosato
Copy link
Contributor

@takutosato takutosato commented Aug 6, 2024

Description

When we cloudify a Picard tool, we change the input and output file types from FILE to PicardHtsPath. This could trigger a "java.io.IOException: Illegal seek" if the input SAM is piped (/dev/stdin). I believe this is related to a known issue (see samtools/htsjdk#1084, samtools/htsjdk#1077). The workaround is to wrap a Path object in SamInputResource.of(), which was put in place in samtools/htsjdk#1124. The tests in PR should safeguard us from inadvertently removing the workaround until a more robust fix can be implemented.

The targeted tools are RevertSam and MergeBamAlignment, both of which are used with piped input in warp pipelines. For example, see
https://github.com/broadinstitute/warp/blob/develop/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl
https://github.com/broadinstitute/warp/blob/develop/tasks/broad/Alignment.wdl

To reproduce the bug, change Line 272 of RevertSam from:

final SamReader in = SamReaderFactory.makeDefault().referenceSequence(referenceSequence.getReferencePath()).validationStringency(VALIDATION_STRINGENCY).open(SamInputResource.of(INPUT.toPath())); ;

to

final SamReader in = SamReaderFactory.makeDefault().referenceSequence(referenceSequence.getReferencePath()).validationStringency(VALIDATION_STRINGENCY).open(INPUT.toPath());

That is, remove the wrapper SamInputResource.of().

Checklist (never delete this)

Never delete this, it is our record that procedure was followed. If you find that for whatever reason one of the checklist points doesn't apply to your PR, you can leave it unchecked but please add an explanation below.

Content

  • Added or modified tests to cover changes and any new functionality
  • Edited the README / documentation (if applicable)
  • All tests passing on github actions

Review

  • Final thumbs-up from reviewer
  • Rebase, squash and reword as applicable

For more detailed guidelines, see https://github.com/broadinstitute/picard/wiki/Guidelines-for-pull-requests

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you tested that the tests fail when you don't have that work around in place One request for additional comment and then good to merge. Thank you!

@@ -269,7 +269,7 @@ protected int doWork() {
}

final boolean sanitizing = SANITIZE;
final SamReader in = SamReaderFactory.makeDefault().referenceSequence(referenceSequence.getReferencePath()).validationStringency(VALIDATION_STRINGENCY).open(SamInputResource.of(INPUT.toPath())); // tsato: confirm this won't break piped input
final SamReader in = SamReaderFactory.makeDefault().referenceSequence(referenceSequence.getReferencePath()).validationStringency(VALIDATION_STRINGENCY).open(SamInputResource.of(INPUT.toPath()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takutosato Could you put a comment here referencing this PR or the related issue? Just too save us some time when we forget and someone tries to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@takutosato
Copy link
Contributor Author

@lbergelson yes the test fails when the workaround is removed.

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@takutosato takutosato merged commit 142282a into master Aug 6, 2024
9 checks passed
@takutosato takutosato deleted the ts_cloud_pipe branch August 6, 2024 17:07
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.

2 participants