Commit b9963f60 authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub

Merge pull request #52 from biopet/xhmm-wisecondor-countfile

Single-sample jobs for count file generation
parents 43756e68 85e5d3c1
......@@ -4,14 +4,23 @@ import java.io.File
import nl.lumc.sasc.biopet.core.{ PedigreeQscript, PipelineCommand, Reference }
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.extensions.gatk.DepthOfCoverage
import nl.lumc.sasc.biopet.extensions.wisecondor.WisecondorCount
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.function.QFunction
import scalaz.{ -\/, \/, \/- }
/**
* Created by Sander Bollen on 23-3-17.
*/
class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with SummaryQScript with Reference {
qscript =>
private val targets: File = config("targets")
def this() = this(null)
def init() = {
......@@ -29,13 +38,96 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with
class Sample(name: String) extends AbstractSample(name) {
val inputCountFile: Option[File] = config("count_file")
val inputXhmmCountFile: Option[File] = config("xhmm_count_file")
val inputWisecondorCountFile: Option[File] = config("wisecondor_count_file")
val bamFile: Option[File] = config("bam")
/**
* Create XHMM count file or create link to input count file
* Precedence is given to existing count files.
* Returns a disjunction where right is the file, and left is
* a potential error message
*/
protected lazy val outputXhmmCountJob: String \/ QFunction = {
val outFile = new File(sampleDir + File.separator + s"$name.dcov")
(inputXhmmCountFile, bamFile) match {
case (Some(f), _) => {
if (bamFile.isDefined) {
logger.warn(s"Both BAM and Xhmm count files are given for sample $name. The BAM file will be ignored")
}
val ln = new Ln(root)
ln.input = f
ln.output = outFile
\/-(ln)
}
case (None, Some(bam)) => {
val dcov = DepthOfCoverage(root, List(bam), outFile, List(targets))
\/-(dcov)
}
case _ => -\/(s"Cannot find bam file or xhmm count file for sample" +
s" $name in config. At least one must be given.")
}
}
/* Get count file for Xhmm method */
lazy val outputXhmmCountFile: String \/ File = {
outputXhmmCountJob match {
case \/-(ln: Ln) => \/-(ln.output)
case \/-(doc: DepthOfCoverage) => \/-(doc.out)
case -\/(error) => -\/(error)
}
}
/**
* Create wisecondor count file or create link to input count file.
* Precedence is given to existing count files.
* Returns a disjunction where right is the file, and left is
* a potential error message
*/
protected lazy val outputWisecondorCountJob: String \/ QFunction = {
val outFile = new File(sampleDir + File.separator + s"$name.wisecondor.bed")
(inputWisecondorCountFile, bamFile) match {
case (Some(f), _) => {
if (bamFile.isDefined) {
logger.warn(s"Both BAM and Wisecondor count files are given for sample $name. The BAM file will be ignored")
}
val ln = new Ln(root)
ln.input = f
ln.output = outFile
\/-(ln)
}
case (None, Some(bam)) => {
val counter = new WisecondorCount(root)
counter.inputBam = bam
counter.output = outFile
counter.binFile = Some(targets)
\/-(counter)
}
case _ => -\/(s"Cannot find bam file or wisecondor count for sample" +
s" $name. At least one must be given.")
}
}
/* Get count file for wisecondor method */
lazy val outputWisecondorCountFile: String \/ File = {
outputWisecondorCountJob match {
case \/-(ln: Ln) => \/-(ln.output)
case \/-(count: WisecondorCount) => \/-(count.output)
case -\/(error) => -\/(error)
}
}
/** Function to add sample jobs */
def addJobs(): Unit = {}
def addJobs(): Unit = {
(outputWisecondorCountJob :: outputXhmmCountJob :: Nil).foreach {
case -\/(error) => Logging.addError(error)
case \/-(function) => add(function)
}
}
/* This is necesary for compile reasons, but library does not in fact exist for this pipeline */
/* This is necessary for compile reasons, but library does not in fact exist for this pipeline */
def makeLibrary(id: String) = new Library(id)
class Library(id: String) extends AbstractLibrary(id) {
......
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