genome / pindel

Pindel can detect breakpoints of large deletions, medium sized insertions, inversions, tandem duplications and other structural variants at single-based resolution from next-gen sequence data. It uses a pattern growth approach to identify the breakpoints of these variants from paired-end short reads.
GNU General Public License v3.0
162 stars 90 forks source link

Use new diff() function for absolute difference between two unsigned coords #64

Open jmarshall opened 7 years ago

jmarshall commented 7 years ago

Fixes the ambiguous abs() compilation errors described in #62. Casting to int is not really the best way to fix this, as the cause of the problem is that the arguments are unsigned int rather than int and what's really needed is some sort of abs_difference function that works on unsigneds natively.

There are several other source files that would also produce these compiler errors, but those source files happen to also #include <math.h> which gives them float abs(float)/etc functions that resolve the ambiguous function choice while probably making things worse.

This PR adds a new unsigned diff(unsigned, unsigned) function and uses it instead of raw abs() in all these source files. It also adds in pindel.h an implementation of this function that computes the difference by cases rather than by using abs(), so as to avoid overflow — which would occur for abs()-based methods when comparing a coordinate near 0 with one near the end of a 232-base chromosome. (If this is overkill, the implementation could be replaced with an abs()-based one, but I doubt there is any difference in efficiency.)

jdemeul commented 6 years ago

Ran into the ambiguous abs() compilation errors described in #62 as well. Fixed by building this PR, thanks @jmarshall!