Skip to content

Commit

Permalink
Fix out of bounds error. (#29)
Browse files Browse the repository at this point in the history
This truncates the possible start position to be 1 if it would
be < 1.

Closes #28.
  • Loading branch information
roryk authored and brentp committed Oct 24, 2019
1 parent 84f7073 commit 67f0458
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/duphold.nim
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,15 @@ proc get_bnd_mate_pos*(a:string, vchrom:string): int {.inline.} =

proc count(discordants:var seq[Discordant], s:int, e:int, i99:int, slop:int=25): int =
## count the number of discordants that span s..e but are within d of both.
var ilow = lowerBound(discordants, Discordant(left:uint32(s - i99), right: uint32(s - i99)), proc(a, b: Discordant):int =
var ilow: int
if s <= i99:
ilow = 1
else:
ilow = lowerBound(discordants, Discordant(left:uint32(s - i99), right: uint32(s - i99)), proc(a, b: Discordant):int =
if a.left == b.left:
return a.right.int - b.right.int
return a.left.int - b.left.int
)
)
for i in ilow..discordants.high:
var disc = discordants[i]
if disc.left.int > s + i99: break
Expand Down

0 comments on commit 67f0458

Please sign in to comment.