isovic / graphmap

GraphMap - A highly sensitive and accurate mapper for long, error-prone reads http://www.nature.com/ncomms/2016/160415/ncomms11307/full/ncomms11307.html Note: This was the original repository which will no longer be officially maintained. Please use the new official repository here:
https://github.com/lbcb-sci/graphmap2
MIT License
178 stars 44 forks source link

Fix seg fault #64

Closed robegan21 closed 7 years ago

robegan21 commented 7 years ago

For some of my datasets with many smaller scaffolds, I found that the latest version of graphmap was segfaulting again on certain reads. When I dove deep into the debugger, I found that the start alignment positions were negative so there was a buffer underrun on the reference sequence.

Additionally even when an alignment is classified as insane and is_aligned is false, the MD and metrics were still being called. I fixed that so that there would not be a buffer under run there too.

This patch adds assertions in cigargen.cc: CountAlignmentOperations() and AlignmentToMD() And performs additional checks for insane alignments and avoids alignment calculations when is_aligned is false

I did not investigate why certain alignments were being calculated outside the bounds of the reference sequence, which would be a better fix, but at least this stops the segfaults on my datasets.

I have also not verified, but this could also fix issue #60 and #43

isovic commented 7 years ago

Hi Rob,

Thank you for creating this pull request! I really appreciate all your input, it helped a lot!!

I merged your pull request, though not directly into master because I wanted to perform some tests. It got merged into the bugfix branch, which after testing was merged to master. I managed to find the cause of faulty coordinates, but these tests definitely don't hurt.

I referenced you in the README.md btw. :-)

Ivan