From 96d9963268aa37399f86b3283e0bfb962060d845 Mon Sep 17 00:00:00 2001
From: bow <bow@bow.web.id>
Date: Fri, 31 Oct 2014 16:41:37 +0100
Subject: [PATCH] Update refFlat parser to account for 0-based coordinate

---
 .../main/scala/nl/lumc/sasc/biopet/tools/WipeReads.scala    | 4 ++--
 .../scala/nl/lumc/sasc/biopet/tools/WipeReadsUnitTest.scala | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/WipeReads.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/WipeReads.scala
index 3b921db8f..9bfb15686 100644
--- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/WipeReads.scala
+++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/WipeReads.scala
@@ -106,8 +106,8 @@ object WipeReads extends ToolCommand {
         .map(x => (x._1, x._2.map(y => y.split(","))))
         // zip exonStarts and exonEnds, note the index was reversed because we did .reverse above
         .map(x => (x._1, x._2(1).zip(x._2(0))))
-        // make Intervals
-        .map(x => x._2.map(y => new Interval(x._1, y._1.toInt, y._2.toInt)))
+        // make Intervals, accounting for the fact that refFlat coordinates are 0-based
+        .map(x => x._2.map(y => new Interval(x._1, y._1.toInt + 1, y._2.toInt)))
         // flatten sublist
         .flatten
 
diff --git a/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/WipeReadsUnitTest.scala b/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/WipeReadsUnitTest.scala
index 8c8af38f5..16cfabe81 100644
--- a/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/WipeReadsUnitTest.scala
+++ b/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/WipeReadsUnitTest.scala
@@ -148,13 +148,13 @@ class WipeReadsUnitTest extends TestNGSuite with MockitoSugar with Matchers {
     val intervals: List[Interval] = makeIntervalFromFile(RefFlatFile1)
     intervals.length shouldBe 5
     intervals.head.getSequence should ===("chrS")
-    intervals.head.getStart shouldBe 100
+    intervals.head.getStart shouldBe 101
     intervals.head.getEnd shouldBe 500
     intervals(2).getSequence should ===("chrQ")
-    intervals(2).getStart shouldBe 800
+    intervals(2).getStart shouldBe 801
     intervals(2).getEnd shouldBe 1000
     intervals.last.getSequence should ===("chrQ")
-    intervals.last.getStart shouldBe 100
+    intervals.last.getStart shouldBe 101
     intervals.last.getEnd shouldBe 200
   }
 
-- 
GitLab