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

Added a method to validate contigs

parent 9f7e5ddb
No related branches found
No related tags found
No related merge requests found
......@@ -305,7 +305,7 @@ object VcfStats extends ToolCommand {
val bedRecords = (commandArgs.intervals match {
case Some(intervals) => BedRecordList.fromFile(intervals)
case Some(intervals) => BedRecordList.fromFile(intervals).validateContigs(commandArgs.referenceFile)
case _ => BedRecordList.fromReference(commandArgs.referenceFile)
}).combineOverlap.scatter(commandArgs.binSize)
......
......@@ -83,6 +83,14 @@ case class BedRecordList(val chrRecords: Map[String, List[BedRecord]], val heade
chrRecords.map(x => x._1 -> x._2.flatMap(_.scatter(binSize)))
)
def validateContigs(reference: File) = {
val referenceFile = new FastaSequenceFile(reference, true)
val dict = referenceFile.getSequenceDictionary
val notExisting = chrRecords.keys.filter(dict.getSequence(_) == null).toList
require(notExisting.isEmpty, s"Contigs found in bed records but are not existing in reference: ${notExisting.mkString(",")}")
this
}
def writeToFile(file: File): Unit = {
val writer = new PrintWriter(file)
header.foreach(writer.println)
......
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