Update BIN values in 'samtools depad' & check in 'samtools index' #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By its nature, 'samtools depad' edits mapped reads, altering both the mapping position and CIGAR string. This means the mapped start and end can change, and therefore the BIN can change.
Prior to this fix the pre-editing BIN (from the padded reference) was being written to the BAM output, leading to subtle problems downstream when trying to use the depadded BAM file via the BAI index. For example, in Picard v1.89 this could trigger an java.lang.ArrayIndexOutOfBoundsException where an old BIN was outside the length of the unpadded reference sequence.
A workaround is to use 'samtools depad' with SAM output, and pipe this via 'samtools view' to convert from SAM to BAM (and thus force the recalculation of the BIN values).