Skip to content

Commit

Permalink
closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Sep 20, 2018
1 parent f2a4231 commit e408a73
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.0.5
======
+ fix bug that occurred with SVs near either end of chromosome (brentp/duphold#2). thanks Brad for reporting and providing a test-case.

v0.0.4
======
+ small bug-fixes
Expand Down
2 changes: 1 addition & 1 deletion duphold.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.0.5-dev"
version = "0.0.5"
author = "Brent Pedersen"
description = "find depth support for DUP/DEL/CNV calls that use PE/SR"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions src/duphold.nim
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ proc get_or_empty[T](variant:Variant, field:string, input:var seq[T]) =
else:
quit "unknown type in get_or_empty"

proc check_rapid_depth_change[T](start:int, stop:int, values: var seq[T], w:int=7): int32 =
proc check_rapid_depth_change*[T](start:int, stop:int, values: var seq[T], w:int=7): int32 =
## if start and end indicate the bounds of a deletion, we can often expect to see a rapid change in
## depth at or near the break-point.
var
Expand All @@ -115,7 +115,7 @@ proc check_rapid_depth_change[T](start:int, stop:int, values: var seq[T], w:int=
for bi, bp in @[start, stop]:
var
close_changes = 0
cs = bp - dist
cs = max(w, bp - dist - w)
left = Stats()
right = Stats()

Expand All @@ -124,7 +124,7 @@ proc check_rapid_depth_change[T](start:int, stop:int, values: var seq[T], w:int=
for i in cs..<(cs + w):
right.addm(values[i])

for k in cs..(bp + dist + w):
for k in cs..min(bp + dist + w, values.len - w - 1):
if (k - last_change) > w:
var
lm = left.mean
Expand Down
1 change: 1 addition & 0 deletions tests/all.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import ./duphold_tests
18 changes: 18 additions & 0 deletions tests/duphold_tests.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import unittest
import duphold

suite "test duphold":
test "test start near 0":
var values = newSeq[int32](2000)
for i, v in values:
values[i] = i.int32
var r = check_rapid_depth_change[int32](0, 2, values, w=7)
check r >= 0

test "test end near chrom length":
var values = newSeq[int32](2000)
for i, v in values:
values[i] = i.int32
for w in 1..70:
var r = check_rapid_depth_change[int32](values.len - 3, values.len - 1, values, w=w)
check r >= 0
1 change: 1 addition & 0 deletions tests/nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
path = "$projectPath/../src"

0 comments on commit e408a73

Please sign in to comment.