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

fixed error in RealignmentEngine due to inclusive vs exclusive ends #6404

Merged
merged 1 commit into from Jan 21, 2020

Conversation

davidbenjamin
Copy link
Contributor

Closes #6344, I think. @takutosato can you review this?

private static SimpleInterval convertToInterval(final BwaMemAlignment alignment) {
return new SimpleInterval(Integer.toString(alignment.getRefId()), alignment.getRefStart(), alignment.getRefEnd());
return new SimpleInterval(Integer.toString(alignment.getRefId()), alignment.getRefStart(), alignment.getRefEnd() - 1);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to go the other way don't we? Increase the start and leave the end alone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose the last included position is 5.

  1. Account for exclusive --> inclusive stop.
    BWA mem alignment is exclusive, hence its end is 6. SimpleInterval is inclusive, so its end should be 5, which is BWA's end - 1.

  2. account for 0-based --> 1-based contig
    Add 1 to everything, so that adding 1 to the end cancels subtracting 1, while the start is incremented by 1.

@lbergelson You're right. Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me!

private static SimpleInterval convertToInterval(final BwaMemAlignment alignment) {
return new SimpleInterval(Integer.toString(alignment.getRefId()), alignment.getRefStart(), alignment.getRefEnd());
return new SimpleInterval(Integer.toString(alignment.getRefId()), alignment.getRefStart() + 1, alignment.getRefEnd());
Copy link
Member

Choose a reason for hiding this comment

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

@davidbenjamin Are we sure that the contig is correct? I think alignment.getRefId() is likely to be 0 indexed, which means that you'll start with contig 0 when you want contig 1. And obviously it doesn't work for non-numbered contigs. I think what you need to be doing here is looking it up from bwaMemIndex.getReferenceContigNames().

Copy link
Member

Choose a reason for hiding this comment

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

Oh. I see, it's using the same method to generate the overlap detectors, so that's ok.

@davidbenjamin davidbenjamin merged commit 6810c5e into master Jan 21, 2020
@davidbenjamin davidbenjamin deleted the db_realignment_bug branch January 21, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FilterAlignmentArtifacts Invalid Intervals and Segmentation Faults
3 participants