diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala index 4c50cc857dccff7eadd0d974e2afe68cbd40d93b..c395d0bc58dbddeef092d6b185cd22925b3b9959 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala @@ -60,6 +60,22 @@ case class BedRecord(chr: String, .flatten .mkString("\t") } + + def validate = { + require(start <= end, "Start is greater then end") + (thickStart, thickEnd) match { + case (Some(s), Some(e)) => require(s <= e, "Thick start is greater then end") + case _ => + } + blockCount match { + case Some(count) => { + require(count == blockSizes.length, "Number of sizes is not the same as blockCount") + require(count == blockStarts.length, "Number of starts is not the same as blockCount") + } + case _ => + } + this + } } object BedRecord { diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala index 906f90df18e1c0aa6f66410ebe7ef5013c506722..783f324816ea64689124f251c1a69d67d4f45089 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala @@ -70,7 +70,17 @@ object BedRecordList { } def fromFile(bedFile: File) = { - fromList(Source.fromFile(bedFile).getLines().map(BedRecord.fromLine(_))) + var lineCount = 0L + fromList(Source.fromFile(bedFile).getLines().map(line => { + lineCount += 1 + try { + BedRecord.fromLine(line).validate + } catch { + case e: Exception => + Logging.logger.error(s"Parsing line number $lineCount failed on file: ${bedFile.getAbsolutePath}") + throw e + } + })) } def combineOverlap(list: BedRecordList): BedRecordList = {