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

Added a precheck when using bedfiles with wrong contig in there

parent 43253296
...@@ -17,15 +17,16 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics ...@@ -17,15 +17,16 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.annotations.{ RibosomalRefFlat, AnnotationRefFlat } import nl.lumc.sasc.biopet.core.annotations.{AnnotationRefFlat, RibosomalRefFlat}
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.summary.SummaryQScript import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ Reference, BiopetFifoPipe, PipelineCommand, SampleLibraryTag } import nl.lumc.sasc.biopet.core.{BiopetFifoPipe, PipelineCommand, Reference, SampleLibraryTag}
import nl.lumc.sasc.biopet.extensions.bedtools.{ BedtoolsCoverage, BedtoolsIntersect } import nl.lumc.sasc.biopet.extensions.bedtools.{BedtoolsCoverage, BedtoolsIntersect}
import nl.lumc.sasc.biopet.extensions.picard._ import nl.lumc.sasc.biopet.extensions.picard._
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsFlagstat import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsFlagstat
import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
import nl.lumc.sasc.biopet.extensions.tools.BiopetFlagstat import nl.lumc.sasc.biopet.extensions.tools.BiopetFlagstat
import nl.lumc.sasc.biopet.utils.intervals.BedCheck
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
class BamMetrics(val root: Configurable) extends QScript class BamMetrics(val root: Configurable) extends QScript
...@@ -72,6 +73,8 @@ class BamMetrics(val root: Configurable) extends QScript ...@@ -72,6 +73,8 @@ class BamMetrics(val root: Configurable) extends QScript
/** executed before script */ /** executed before script */
def init(): Unit = { def init(): Unit = {
inputFiles :+= new InputFile(inputBam) inputFiles :+= new InputFile(inputBam)
ampliconBedFile.foreach(BedCheck.checkBedFileToReference(_, referenceFasta()))
roiBedFiles.foreach(BedCheck.checkBedFileToReference(_, referenceFasta()))
} }
/** Script to add jobs */ /** Script to add jobs */
......
package nl.lumc.sasc.biopet.utils.intervals
import java.io.File
import scala.collection.mutable.Set
import nl.lumc.sasc.biopet.utils.Logging
/**
* Created by pjvanthof on 14/05/16.
*/
object BedCheck {
private val cache: Set[(File, File)] = Set()
def checkBedFileToReference(bedFile: File, reference: File, biopetError: Boolean = false, ignoreCache: Boolean = false): Unit = {
if (ignoreCache || !cache.contains((bedFile, reference))) {
cache.add((bedFile, reference))
val bedrecords = BedRecordList.fromFile(bedFile)
if (biopetError) {
try {
bedrecords.validateContigs(reference)
} catch {
case e: IllegalArgumentException => Logging.addError(e.getMessage)
}
} else bedrecords.validateContigs(reference)
}
}
}
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