Commit 038c3e4a authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added BastyGenerateFasta

parent 1f08d7d5
......@@ -3,7 +3,9 @@ package nl.lumc.sasc.biopet.pipelines.basty
import nl.lumc.sasc.biopet.core.MultiSampleQScript
import nl.lumc.sasc.biopet.core.PipelineCommand
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.Cat
import nl.lumc.sasc.biopet.pipelines.gatk.GatkPipeline
import nl.lumc.sasc.biopet.tools.BastyGenerateFasta
import org.broadinstitute.gatk.queue.QScript
class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
......@@ -13,6 +15,8 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
}
class SampleOutput extends AbstractSampleOutput {
var outputVariants: File = _
var outputVariantsSnps: File = _
}
defaults ++= Map("ploidy" -> 1, "use_haplotypecaller" -> false, "use_unifiedgenotyper" -> true)
......@@ -29,17 +33,26 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
gatkPipeline.biopetScript
addAll(gatkPipeline.functions)
val refVariants = addGenerateFasta("Reference", outputDir + "reference/")
val refVariantSnps = addGenerateFasta("Reference", outputDir + "reference/", snpsOnly = true)
runSamplesJobs()
add(Cat(this, refVariants :: samplesOutput.map(_._2.outputVariants).toList, outputDir + "fastas/variant.fasta"))
add(Cat(this, refVariantSnps :: samplesOutput.map(_._2.outputVariantsSnps).toList, outputDir + "fastas/variant.snps_only.fasta"))
}
// Called for each sample
def runSingleSampleJobs(sampleConfig: Map[String, Any]): SampleOutput = {
val sampleOutput = new SampleOutput
val sampleID: String = sampleConfig("ID").toString
val sampleDir = globalSampleDir + sampleID
val sampleDir = globalSampleDir + sampleID + "/"
sampleOutput.libraries = runLibraryJobs(sampleConfig)
sampleOutput.outputVariants = addGenerateFasta(sampleID, sampleDir)
sampleOutput.outputVariantsSnps = addGenerateFasta(sampleID, sampleDir, snpsOnly = true)
return sampleOutput
}
......@@ -53,6 +66,16 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
return libraryOutput
}
def addGenerateFasta(sampleName: String, outputDir: String, snpsOnly: Boolean = false): File = {
val bastyGenerateFasta = new BastyGenerateFasta(this)
bastyGenerateFasta.inputVcf = gatkPipeline.multisampleVariantcalling.scriptOutput.finalVcfFile
bastyGenerateFasta.outputVariants = outputDir + sampleName + ".variants" + (if (snpsOnly) ".snps_only" else "") + ".fasta"
bastyGenerateFasta.sampleName = sampleName
bastyGenerateFasta.snpsOnly = snpsOnly
add(bastyGenerateFasta)
return bastyGenerateFasta.outputVariants
}
}
object Basty extends PipelineCommand
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