Skip to content
Snippets Groups Projects
Commit 2ecea204 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added validation

parent 0e3d6e9f
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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 = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment