Commit 7c308613 authored by Sander Bollen's avatar Sander Bollen

varda in Toucan

parent e9ed4674
package nl.lumc.sasc.biopet.extensions.tools
import java.io.File
import nl.lumc.sasc.biopet.core.ToolCommandFuntion
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Argument, Output, Input}
/**
* Created by ahbbollen on 13-10-15.
*/
class GvcfToBed (val root: Configurable) extends ToolCommandFuntion {
def toolObject = nl.lumc.sasc.biopet.tools.GvcfToBed
@Input(doc = "input vcf")
var inputVcf: File = _
@Output(doc = "output bed")
var outputBed: File = _
@Argument(doc = "sample")
var sample: Option[String] = None
@Argument(doc = "minquality")
var minQuality: Int = 0
@Argument(doc = "inverse")
var inverse: Boolean = false
override def defaultCoreMemory = 4.0
override def cmdLine = {
super.cmdLine +
required("-I", inputVcf) +
required("-O", outputBed) +
optional("-S", sample) +
optional("--minGenomeQuality", minQuality) +
conditional(inverse, "--inverted")
}
}
......@@ -34,6 +34,7 @@ class VcfFilter(val root: Configurable) extends ToolCommandFuntion {
var minTotalDepth: Option[Int] = config("min_total_depth")
var minAlternateDepth: Option[Int] = config("min_alternate_depth")
var minSamplesPass: Option[Int] = config("min_samples_pass")
var minGenomeQuality: Option[Int] = config("min_genome_quality")
var filterRefCalls: Boolean = config("filter_ref_calls", default = false)
override def defaultCoreMemory = 3.0
......@@ -45,5 +46,6 @@ class VcfFilter(val root: Configurable) extends ToolCommandFuntion {
optional("--minTotalDepth", minTotalDepth) +
optional("--minAlternateDepth", minAlternateDepth) +
optional("--minSamplesPass", minSamplesPass) +
optional("--minGenomeQuality", minGenomeQuality) +
conditional(filterRefCalls, "--filterRefCalls")
}
......@@ -15,11 +15,13 @@
*/
package nl.lumc.sasc.biopet.pipelines.toucan
import nl.lumc.sasc.biopet.extensions.bcftools.BcftoolsView
import nl.lumc.sasc.biopet.extensions.manwe.{ManweSamplesImport, ManweAnnotateVcf, ManweDataSourcesAnnotate}
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand, Reference }
import nl.lumc.sasc.biopet.extensions.VariantEffectPredictor
import nl.lumc.sasc.biopet.extensions.tools.{ VcfWithVcf, VepNormalizer }
import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.extensions.{Ln, Gzip, VariantEffectPredictor}
import nl.lumc.sasc.biopet.extensions.tools.{GvcfToBed, VcfFilter, VcfWithVcf, VepNormalizer}
import nl.lumc.sasc.biopet.utils.ConfigUtils
import org.broadinstitute.gatk.queue.QScript
......@@ -28,20 +30,26 @@ import org.broadinstitute.gatk.queue.QScript
*
* Created by ahbbollen on 15-1-15.
*/
class Toucan(val root: Configurable) extends QScript with BiopetQScript with SummaryQScript with Reference {
class Toucan(val root: Configurable) extends QScript with BiopetQScript with SummaryQScript with Reference{
def this() = this(null)
@Input(doc = "Input VCF file", shortName = "Input", required = true)
var inputVCF: File = _
var sampleIds: List[String] = Nil
def init(): Unit = {
inputFiles :+= new InputFile(inputVCF)
sampleIds = root match {
case m: MultiSampleQScript => m.samples.keys.toList
case null => Nil //TODO: get names from vcf header
case s: SampleLibraryTag => s.sampleId.toList
case _ => throw new IllegalArgumentException("You don't have any samples")
}
}
override def defaults = Map(
"varianteffectpredictor" -> Map("everything" -> true)
)
//defaults ++= Map("varianteffectpredictor" -> Map("everything" -> true))
def biopetScript(): Unit = {
......@@ -87,6 +95,93 @@ class Toucan(val root: Configurable) extends QScript with BiopetQScript with Sum
}
}
/**
* Perform varda analysis
* @param vcf input vcf
* @return return vcf
*/
def varda(vcf: File): File = {
val splits = sampleIds.map(x => {
val view = new BcftoolsView(this)
view.input = vcf
view.output = swapExt(vcf, ".vcf.gz", s"$x.vcf.gz")
view.samples = List(x)
view.minAC = Some(1)
add(view)
view
})
val minGQ = config("minimumGenomeQuality", default = 20)
val vardaConfig: Option[File] = config("vardaConfig") // TODO: create on the fly
val annotationQueries: List[String] = config("annotationQueries")
val isPublic: Boolean = config("vardaIsPublic")
val filteredVcfs = splits.map(x => {
val filter = new VcfFilter(this)
filter.inputVcf = x.output
filter.outputVcf = swapExt(x.output, ".vcf.gz", ".filtered.vcf.gz")
filter.minGenomeQuality = minGQ
add(filter)
filter
})
val bedTracks = filteredVcfs.map(x => {
val bed = new GvcfToBed(this)
bed.inputVcf = x.outputVcf
bed.outputBed = swapExt(x.outputVcf, ".vcf.gz", ".bed")
add(bed)
bed
})
val zippedBedTracks = bedTracks.map(x => {
val gzip = new Gzip(this)
gzip.input = List(x.outputBed)
gzip.output = swapExt(x.outputBed, ".bed", ".bed.gz")
add(gzip)
gzip
})
val annotate = new ManweAnnotateVcf(this)
annotate.vcf = vcf
annotate.manweConfig = vardaConfig
annotate.queries = annotationQueries
annotate.waitToComplete = true
annotate.output = swapExt(vcf, ".vcf.gz", ".tmp.annot")
add(annotate)
val annotatedVcf = new ManweDownloadAfterAnnotate(this, annotate)
annotatedVcf.output = swapExt(annotate.output, ".tmp.annot", "tmp.annot.vcf.gz")
val imports = for (
(sample: String, bed, vcf) <- (sampleIds, bedTracks, filteredVcfs).zipped
) yield {
val importing = new ManweSamplesImport(this)
importing.beds = List(bed.outputBed)
importing.vcfs = List(vcf.outputVcf)
importing.name = Some(sample)
importing.waitToComplete = true
importing.output = swapExt(vcf.outputVcf, ".vcf.gz", ".tmp.import")
importing.public = isPublic
importing.manweConfig = vardaConfig
importing
}
val activates = imports.map(x => {
val active = new ManweActivateAfterAnnotImport(this, annotate, x)
active.manweConfig = vardaConfig
active.output = swapExt(x.output, ".tmp.import", ".tmp.activated")
active
})
val finalLn = new Ln(this)
activates.foreach(x => finalLn.deps :+= x)
finalLn.input = annotatedVcf.output
finalLn.output = swapExt(annotatedVcf.output, "tmp.annot.vcf.gz", ".varda_annotated.vcf.gz")
finalLn.relative = true
finalLn.output
}
def summaryFile = new File(outputDir, "Toucan.summary.json")
def summaryFiles = Map()
......
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