From 76f77af36fabab8709493d2db3dffac33fca31e9 Mon Sep 17 00:00:00 2001 From: Brent Pedersen <bpederse@gmail.com> Date: Tue, 10 Sep 2019 12:40:40 -0600 Subject: [PATCH] support for more ALT types (e.g DUP:TANDEM, DEL:ME, etc) closes #26 --- CHANGES.md | 5 +++++ duphold.nimble | 2 +- src/duphold.nim | 33 ++++++++++++++++++--------------- src/dupholdpkg/version.nim | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a656a03..a9d111a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +v0.1.5 +====== ++ support for more ALT types (e.g DUP:TANDEM, DEL:ME, etc) ++ flush stdout properly (#25) + v0.1.4 ====== + output DHSP for BND elements on same chrom diff --git a/duphold.nimble b/duphold.nimble index b4dd5c6..f997528 100644 --- a/duphold.nimble +++ b/duphold.nimble @@ -18,7 +18,7 @@ license = "MIT" # Dependencies -requires "hts >= 0.2.7", "genoiser >= 0.2.2", "docopt >= 0.6.8" +requires "hts >= 0.2.21", "genoiser >= 0.2.2", "docopt >= 0.6.8" srcDir = "src" installExt = @["nim"] diff --git a/src/duphold.nim b/src/duphold.nim index e8b0893..c95895a 100644 --- a/src/duphold.nim +++ b/src/duphold.nim @@ -204,21 +204,24 @@ proc duphold*[T](variant:Variant, values:var seq[T], sample_i: int, stats:var Me var s = variant.start e = variant.stop + isBnd = false - var bnd = get_bnd_mate_pos(variant) - var isBnd = false - if bnd != -1: - if bnd < s and s - bnd < 20000000: - e = s - s = bnd - elif bnd > e and bnd - e < 20000000: - s = e - e = bnd - 1 - isBnd = true - - if bnd == -1: - # skip distant BND's as this is not informative - if ':' in variant.ALT[0]: return -1 + + if variant.ALT[0][0] != '<': + var bnd = get_bnd_mate_pos(variant) + var isBnd = false + if bnd != -1: + if bnd < s and s - bnd < 20000000: + e = s + s = bnd + elif bnd > e and bnd - e < 20000000: + s = e + e = bnd - 1 + isBnd = true + + if bnd == -1: + # skip distant BND's as this is not informative + if ':' in variant.ALT[0]: return -1 if e - s < 10: s = max(0, s - 50) @@ -276,7 +279,7 @@ proc duphold*[T](variant:Variant, values:var seq[T], sample_i: int, stats:var Me if discordants.len == 0: return - if isBnd or variant.ALT[0] == "<DEL>" or (variant.ALT[0] != "<" and len(variant.REF) > len(variant.ALT[0])): + if isBnd or variant.ALT[0].startswith("<DEL") or (variant.ALT[0] != "<" and len(variant.REF) > len(variant.ALT[0])): var ints = newSeq[int32](variant.vcf.n_samples) get_or_empty(variant, "DHSP", ints) ints[sample_i] = discordants.count(s, e, i99).int32 diff --git a/src/dupholdpkg/version.nim b/src/dupholdpkg/version.nim index 3c5c552..6c4e9d4 100644 --- a/src/dupholdpkg/version.nim +++ b/src/dupholdpkg/version.nim @@ -1 +1 @@ -const dupholdVersion* = "0.1.4" +const dupholdVersion* = "0.1.5"