From abab23350f18ce2b2ece84cd7c94d0c5aaf3a619 Mon Sep 17 00:00:00 2001 From: chartl Date: Mon, 28 Feb 2011 19:56:33 +0000 Subject: [PATCH] Fix for expanded intervals in the case where the input file has overlapping intervals in it (seriously?) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5337 348d0f76-0448-11de-a6fe-93d51630548a --- .../ipf/intervals/ExpandIntervals.scala | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scala/src/org/broadinstitute/sting/queue/library/ipf/intervals/ExpandIntervals.scala b/scala/src/org/broadinstitute/sting/queue/library/ipf/intervals/ExpandIntervals.scala index 5c5928aec..8ae8b7192 100755 --- a/scala/src/org/broadinstitute/sting/queue/library/ipf/intervals/ExpandIntervals.scala +++ b/scala/src/org/broadinstitute/sting/queue/library/ipf/intervals/ExpandIntervals.scala @@ -56,8 +56,14 @@ class ExpandIntervals(in : File, start: Int, size: Int, out: File, ref: File, ip curLoc = nextLoc nextLoc = if ( xrl.hasNext ) parseGenomeInterval(xrl.next) else null if ( curLoc != null ) { - intervalCache += refine(expandLeft(curLoc),prevLoc) - intervalCache += refine(expandRight(curLoc),nextLoc) + val left: GenomeLoc = refine(expandLeft(curLoc),prevLoc) + val right: GenomeLoc = refine(expandRight(curLoc),nextLoc) + if ( left != null ) { + intervalCache += left + } + if ( right != null ) { + intervalCache += right + } } linesProcessed += 1 if ( linesProcessed % LINES_TO_CACHE == 0 ) { @@ -83,14 +89,20 @@ class ExpandIntervals(in : File, start: Int, size: Int, out: File, ref: File, ip def refine(newG: GenomeLoc, borderG: GenomeLoc) : GenomeLoc = { if ( borderG == null || ! newG.overlapsP(borderG) ) { - newG + return newG } else { if ( newG.getStart < borderG.getStart ) { - parser.createGenomeLoc(newG.getContig,newG.getStart,borderG.getStart-startInt) + if ( borderG.getStart - startInt > newG.getStart ) { + return parser.createGenomeLoc(newG.getContig,newG.getStart,borderG.getStart-startInt) + } } else { - parser.createGenomeLoc(newG.getContig,borderG.getStop+startInt,newG.getStop) + if ( borderG.getStop + startInt < newG.getStop ){ + return parser.createGenomeLoc(newG.getContig,borderG.getStop+startInt,newG.getStop) + } } } + + null } def repr(loc : GenomeLoc) : String = {