Commit a99720fa authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Correct 1-based to 0 based

parent dc8933b8
......@@ -85,7 +85,7 @@ object WipeReads extends ToolCommand {
logger.info("Parsing interval file ...")
/** Function to create iterator from BED file */
def makeIntervalFromBed(inFile: File) = BedRecordList.fromFile(inFile).sorted.intervals.toIterator
def makeIntervalFromBed(inFile: File) = BedRecordList.fromFile(inFile).sorted.samIntervals.toIterator
/**
* Parses a refFlat file to yield Interval objects
......
......@@ -25,11 +25,11 @@ case class BedRecord(chr: String,
def overlapWith(record: BedRecord): Boolean = {
if (chr != record.chr) false
else if (start <= record.end && record.start <= end) true
else if (start < record.end && record.start < end) true
else false
}
def length = end - start + 1
def length = end - start
lazy val exons = if (blockCount.isDefined && blockSizes.length > 0 && blockStarts.length > 0) {
Some(for (i <- 0 until blockCount.get) yield {
......@@ -55,9 +55,9 @@ case class BedRecord(chr: String,
lazy val utr5 = (strand, thickStart, thickEnd) match {
case (Some(true), Some(tStart), Some(tEnd)) if (tStart > start && tEnd < end) =>
Some(BedRecord(chr, start, tStart - 1, name.map(_ + "_utr5")))
Some(BedRecord(chr, start, tStart, name.map(_ + "_utr5")))
case (Some(false), Some(tStart), Some(tEnd)) if (tStart > start && tEnd < end) =>
Some(BedRecord(chr, tEnd + 1, end, name.map(_ + "_utr5")))
Some(BedRecord(chr, tEnd, end, name.map(_ + "_utr5")))
case _ => None
}
......
......@@ -15,10 +15,10 @@ import nl.lumc.sasc.biopet.core.Logging
class BedRecordList(val chrRecords: Map[String, List[BedRecord]], header: List[String] = Nil) {
def allRecords = for (chr <- chrRecords; record <- chr._2) yield record
def intervals = allRecords.map({ x =>
def samIntervals = allRecords.map({ x =>
(x.name, x.strand) match {
case (Some(name), Some(strand)) => new Interval(x.chr, x.start, x.end, !strand, name)
case _ => new Interval(x.chr, x.start, x.end)
case (Some(name), Some(strand)) => new Interval(x.chr, x.start + 1, x.end, !strand, name)
case _ => new Interval(x.chr, x.start + 1, x.end)
}
})
......@@ -31,8 +31,8 @@ class BedRecordList(val chrRecords: Map[String, List[BedRecord]], header: List[S
def overlapWith(record: BedRecord) = sorted.chrRecords
.getOrElse(record.chr, Nil)
.dropWhile(_.end < record.start)
.takeWhile(_.start <= record.end)
.dropWhile(_.end <= record.start)
.takeWhile(_.start < record.end)
def length = allRecords.foldLeft(0L)((a, b) => a + b.length)
......@@ -49,9 +49,9 @@ class BedRecordList(val chrRecords: Map[String, List[BedRecord]], header: List[S
(for (r <- result) yield {
(overlap.start < r.start, overlap.end > r.end) match {
case (true, true) => Nil
case (true, false) => List(r.copy(start = overlap.end + 1))
case (false, true) => List(r.copy(end = overlap.start - 1))
case (false, false) => List(r.copy(end = overlap.start - 1), r.copy(start = overlap.end + 1))
case (true, false) => List(r.copy(start = overlap.end))
case (false, true) => List(r.copy(end = overlap.start))
case (false, false) => List(r.copy(end = overlap.start), r.copy(start = overlap.end))
}
}).flatten
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment