Commit 2c323f38 authored by Peter van 't Hof's avatar Peter van 't Hof

Fix code style warnings

parent 7778c07d
......@@ -18,6 +18,6 @@ object AnalyzeCovariates {
ac.before = before
ac.after = after
ac.plots = plots
return ac
ac
}
}
\ No newline at end of file
......@@ -12,8 +12,8 @@ import nl.lumc.sasc.biopet.core.config.Configurable
class ApplyRecalibration(val root: Configurable) extends org.broadinstitute.gatk.queue.extensions.gatk.ApplyRecalibration with GatkGeneral {
scatterCount = config("scattercount", default = 0)
override def beforeGraph {
super.beforeGraph
override def beforeGraph() {
super.beforeGraph()
nt = Option(getThreads(3))
memoryLimit = Option(nt.getOrElse(1) * 2)
......@@ -37,6 +37,6 @@ object ApplyRecalibration {
ar.recal_file = recal_file
ar.tranches_file = tranches_file
ar.out = output
return ar
ar
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ object BaseRecalibrator {
val br = new BaseRecalibrator(root)
br.input_file :+= input
br.out = output
br.beforeGraph
return br
br.beforeGraph()
br
}
}
\ No newline at end of file
......@@ -18,6 +18,6 @@ object CombineGVCFs {
val cg = new CombineGVCFs(root)
cg.variant = input
cg.o = output
return cg
cg
}
}
\ No newline at end of file
......@@ -18,6 +18,6 @@ object CombineVariants {
val cv = new CombineVariants(root)
cv.variant = input
cv.out = output
return cv
cv
}
}
\ No newline at end of file
......@@ -26,10 +26,10 @@ trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction wit
override val versionExitcode = List(0, 1)
override def versionCommand = executable + " -jar " + jarFile + " -version"
override def getVersion = super.getVersion.collect { case version => "Gatk " + version }
override def getVersion = super.getVersion.collect { case v => "Gatk " + v }
override def beforeGraph: Unit = {
super.beforeGraph
override def beforeGraph(): Unit = {
super.beforeGraph()
if (reference_sequence == null) reference_sequence = referenceFasta()
}
}
......@@ -29,6 +29,6 @@ object GenotypeGVCFs {
val gg = new GenotypeGVCFs(root)
gg.variant = gvcfFiles
gg.out = output
return gg
gg
}
}
\ No newline at end of file
......@@ -35,8 +35,8 @@ class HaplotypeCaller(val root: Configurable) extends org.broadinstitute.gatk.qu
stand_emit_conf = config("stand_emit_conf", default = 0)
}
override def beforeGraph {
super.beforeGraph
override def beforeGraph() {
super.beforeGraph()
if (bamOutput != null && nct.getOrElse(1) > 1) {
threads = 1
logger.warn("BamOutput is on, nct/threads is forced to set on 1, this option is only for debug")
......
......@@ -19,6 +19,6 @@ object IndelRealigner {
ir.input_file :+= input
ir.targetIntervals = targetIntervals
ir.out = new File(outputDir, input.getName.stripSuffix(".bam") + ".realign.bam")
return ir
ir
}
}
\ No newline at end of file
......@@ -18,6 +18,6 @@ object PrintReads {
val br = new PrintReads(root)
br.input_file :+= input
br.out = output
return br
br
}
}
\ No newline at end of file
......@@ -20,6 +20,6 @@ object RealignerTargetCreator {
val re = new RealignerTargetCreator(root)
re.input_file :+= input
re.out = new File(outputDir, input.getName.stripSuffix(".bam") + ".realign.intervals")
return re
re
}
}
\ No newline at end of file
......@@ -18,6 +18,6 @@ object SelectVariants {
val sv = new SelectVariants(root)
sv.variant = input
sv.out = output
return sv
sv
}
}
\ No newline at end of file
......@@ -26,8 +26,8 @@ class UnifiedGenotyper(val root: Configurable) extends org.broadinstitute.gatk.q
}
}
override def beforeGraph {
super.beforeGraph
override def beforeGraph() {
super.beforeGraph()
genotype_likelihoods_model = org.broadinstitute.gatk.tools.walkers.genotyper.GenotypeLikelihoodsCalculationModel.Model.BOTH
nct = Some(getThreads(1))
......
......@@ -20,6 +20,6 @@ object VariantAnnotator {
va.variant = input
va.input_file = bamFiles
va.out = output
return va
va
}
}
\ No newline at end of file
......@@ -10,8 +10,8 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
class VariantEval(val root: Configurable) extends org.broadinstitute.gatk.queue.extensions.gatk.VariantEval with GatkGeneral {
override def beforeGraph {
super.beforeGraph
override def beforeGraph() {
super.beforeGraph()
}
}
......@@ -22,8 +22,8 @@ object VariantEval {
vareval.eval = Seq(sample)
vareval.comp = Seq(compareWith)
vareval.out = output
vareval.beforeGraph
return vareval
vareval.beforeGraph()
vareval
}
def apply(root: Configurable, sample: File, compareWith: File,
......@@ -36,8 +36,8 @@ object VariantEval {
vareval.ST = ST
vareval.noEV = true
vareval.EV = EV
vareval.beforeGraph
return vareval
vareval.beforeGraph()
vareval
}
}
\ No newline at end of file
......@@ -39,6 +39,6 @@ object VariantRecalibrator {
vr.input :+= input
vr.recal_file = recal_file
vr.tranches_file = tranches_file
return vr
vr
}
}
\ No newline at end of file
......@@ -11,6 +11,8 @@ import nl.lumc.sasc.biopet.pipelines.basty.BastyTrait
import org.broadinstitute.gatk.queue.QScript
/**
* Basty pipeline including GATK steps
*
* Created by pjvan_thof on 3/4/15.
*/
class Basty(val root: Configurable) extends QScript with BastyTrait {
......
......@@ -38,7 +38,7 @@ class GatkBenchmarkGenotyping(val root: Configurable) extends QScript with Biope
var gvcfPool: List[File] = Nil
addGenotypingPipeline(gvcfPool)
while (todoGvcfs.size > 0) {
while (todoGvcfs.nonEmpty) {
val index = Random.nextInt(todoGvcfs.size)
gvcfPool ::= todoGvcfs(index)
addGenotypingPipeline(gvcfPool)
......@@ -51,8 +51,8 @@ class GatkBenchmarkGenotyping(val root: Configurable) extends QScript with Biope
gatkGenotyping.inputGvcfs = sampleGvcf :: gvcfPool
gatkGenotyping.samples :+= sampleName
gatkGenotyping.outputDir = new File(outputDir, "samples_" + gvcfPool.size)
gatkGenotyping.init
gatkGenotyping.biopetScript
gatkGenotyping.init()
gatkGenotyping.biopetScript()
addAll(gatkGenotyping.functions)
}
}
......
......@@ -38,7 +38,7 @@ class GatkGenotyping(val root: Configurable) extends QScript with BiopetQScript
def biopetScript() {
addGenotypeGVCFs(inputGvcfs, outputFile)
if (!samples.isEmpty) {
if (samples.nonEmpty) {
if (samples.size > 1) addSelectVariants(outputFile, samples, new File(outputDir, "samples/"), "all")
for (sample <- samples) addSelectVariants(outputFile, List(sample), new File(outputDir, "samples/"), sample)
}
......@@ -47,7 +47,7 @@ class GatkGenotyping(val root: Configurable) extends QScript with BiopetQScript
def addGenotypeGVCFs(gvcfFiles: List[File], outputFile: File): File = {
val genotypeGVCFs = GenotypeGVCFs(this, gvcfFiles, outputFile)
add(genotypeGVCFs)
return genotypeGVCFs.out
genotypeGVCFs.out
}
def addSelectVariants(inputFile: File, samples: List[String], outputDir: File, name: String) {
......
......@@ -78,8 +78,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
val bamFile: Option[File] = if (config.contains("R1")) {
mapping.input_R1 = config("R1")
mapping.input_R2 = config("R2")
mapping.init
mapping.biopetScript
mapping.init()
mapping.biopetScript()
addAll(mapping.functions) // Add functions of mapping to curent function pool
Some(mapping.finalBamFile)
} else if (config.contains("bam")) {
......@@ -93,8 +93,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
qscript.add(samToFastq)
mapping.input_R1 = samToFastq.fastqR1
mapping.input_R2 = Some(samToFastq.fastqR2)
mapping.init
mapping.biopetScript
mapping.init()
mapping.biopetScript()
addAll(mapping.functions) // Add functions of mapping to curent function pool
Some(mapping.finalBamFile)
} else {
......@@ -106,7 +106,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
if (readGroup.getLibrary != libId) logger.warn("Library ID readgroup in bam file is not the same")
if (readGroup.getSample != sampleId || readGroup.getLibrary != libId) readGroupOke = false
}
inputSam.close
inputSam.close()
if (!readGroupOke) {
if (config("correct_readgroups", default = false)) {
......@@ -133,8 +133,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
if (bamFile.isDefined) {
gatkVariantcalling.inputBams = List(bamFile.get)
gatkVariantcalling.variantcalling = config("library_variantcalling", default = false)
gatkVariantcalling.init
gatkVariantcalling.biopetScript
gatkVariantcalling.init()
gatkVariantcalling.biopetScript()
addAll(gatkVariantcalling.functions)
}
......@@ -155,8 +155,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
gatkVariantcalling.useHaplotypecaller = false
gatkVariantcalling.useUnifiedGenotyper = false
}
gatkVariantcalling.init
gatkVariantcalling.biopetScript
gatkVariantcalling.init()
gatkVariantcalling.biopetScript()
addAll(gatkVariantcalling.functions)
gatkVariantcalling.inputBams.foreach(x => addAll(Bam2Wig(qscript, x).functions))
......@@ -174,7 +174,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
def biopetScript(): Unit = {
addSamplesJobs()
addSummaryJobs
addSummaryJobs()
}
def addMultiSampleJobs(): Unit = {
......@@ -184,13 +184,13 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
List(newFile)
} else externalGvcfs ++ samples.map(_._2.gatkVariantcalling.scriptOutput.gvcfFile)
if (!skipGenotyping && gvcfFiles.size > 0) {
if (!skipGenotyping && gvcfFiles.nonEmpty) {
if (jointGenotyping) {
val gatkGenotyping = new GatkGenotyping(this)
gatkGenotyping.inputGvcfs = gvcfFiles
gatkGenotyping.outputDir = new File(outputDir, "genotyping")
gatkGenotyping.init
gatkGenotyping.biopetScript
gatkGenotyping.init()
gatkGenotyping.biopetScript()
addAll(gatkGenotyping.functions)
var vcfFile = gatkGenotyping.outputFile
}
......@@ -216,8 +216,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
multisampleVariantcalling.inputBams = allBamfiles.toList
multisampleVariantcalling.outputDir = new File(outputDir, "variantcalling")
multisampleVariantcalling.outputName = "multisample"
multisampleVariantcalling.init
multisampleVariantcalling.biopetScript
multisampleVariantcalling.init()
multisampleVariantcalling.biopetScript()
addAll(multisampleVariantcalling.functions)
if (config("inputtype", default = "dna").asString != "rna" && config("recalibration", default = false).asBoolean) {
......@@ -225,8 +225,8 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
recalibration.inputVcf = multisampleVariantcalling.scriptOutput.finalVcfFile
recalibration.bamFiles = allBamfiles
recalibration.outputDir = new File(outputDir, "recalibration")
recalibration.init
recalibration.biopetScript
recalibration.init()
recalibration.biopetScript()
}
}
}
......
......@@ -27,7 +27,7 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
}
def biopetScript() {
var vcfFile: File = if (!bamFiles.isEmpty) addVariantAnnotator(inputVcf, bamFiles, outputDir) else inputVcf
var vcfFile: File = if (bamFiles.nonEmpty) addVariantAnnotator(inputVcf, bamFiles, outputDir) else inputVcf
vcfFile = addSnpVariantRecalibrator(vcfFile, outputDir)
vcfFile = addIndelVariantRecalibrator(vcfFile, outputDir)
}
......@@ -35,41 +35,41 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
def addSnpVariantRecalibrator(inputVcf: File, dir: File): File = {
val snpRecal = VariantRecalibrator(this, inputVcf, swapExt(dir, inputVcf, ".vcf", ".indel.recal"),
swapExt(dir, inputVcf, ".vcf", ".indel.tranches"), indel = false)
if (!snpRecal.resource.isEmpty) {
if (snpRecal.resource.nonEmpty) {
add(snpRecal)
val snpApply = ApplyRecalibration(this, inputVcf, swapExt(dir, inputVcf, ".vcf", ".indel.recal.vcf"),
snpRecal.recal_file, snpRecal.tranches_file, indel = false)
add(snpApply)
return snpApply.out
snpApply.out
} else {
logger.warn("Skipped snp Recalibration, resource is missing")
return inputVcf
inputVcf
}
}
def addIndelVariantRecalibrator(inputVcf: File, dir: File): File = {
val indelRecal = VariantRecalibrator(this, inputVcf, swapExt(dir, inputVcf, ".vcf", ".indel.recal"),
swapExt(dir, inputVcf, ".vcf", ".indel.tranches"), indel = true)
if (!indelRecal.resource.isEmpty) {
if (indelRecal.resource.nonEmpty) {
add(indelRecal)
val indelApply = ApplyRecalibration(this, inputVcf, swapExt(dir, inputVcf, ".vcf", ".indel.recal.vcf"),
indelRecal.recal_file, indelRecal.tranches_file, indel = true)
add(indelApply)
return indelApply.out
indelApply.out
} else {
logger.warn("Skipped indel Recalibration, resource is missing")
return inputVcf
inputVcf
}
}
def addVariantAnnotator(inputvcf: File, bamfiles: List[File], dir: File): File = {
val variantAnnotator = VariantAnnotator(this, inputvcf, bamfiles, swapExt(dir, inputvcf, ".vcf", ".anotated.vcf"))
add(variantAnnotator)
return variantAnnotator.out
variantAnnotator.out
}
}
......
......@@ -111,7 +111,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
if (sampleID != null && (useHaplotypecaller || config("joint_genotyping", default = false).asBoolean)) {
val hcGvcf = new HaplotypeCaller(this)
hcGvcf.useGvcf
hcGvcf.useGvcf()
hcGvcf.input_file = scriptOutput.bamFiles
hcGvcf.out = new File(outputDir, outputName + ".hc.discovery.gvcf.vcf.gz")
add(hcGvcf)
......@@ -228,7 +228,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
indelRealigner.isIntermediate = isIntermediate
add(indelRealigner)
return indelRealigner.o
indelRealigner.o
}
def addBaseRecalibrator(inputBam: File, dir: File, isIntermediate: Boolean = false): File = {
......@@ -253,7 +253,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
printReads.isIntermediate = isIntermediate
add(printReads)
return printReads.o
printReads.o
}
}
......
......@@ -12,6 +12,8 @@ import nl.lumc.sasc.biopet.pipelines.shiva.{ ShivaTrait, ShivaVariantcallingTrai
import org.broadinstitute.gatk.queue.QScript
/**
* Shiva inplementation with GATK steps
*
* Created by pjvan_thof on 2/26/15.
*/
class Shiva(val root: Configurable) extends QScript with ShivaTrait {
......@@ -47,7 +49,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
/** Return true when baserecalibration is executed */
protected def doneBaseRecalibrator: Boolean = {
val br = new BaseRecalibrator(qscript)
useBaseRecalibration && !br.knownSites.isEmpty
useBaseRecalibration && br.knownSites.nonEmpty
}
/** This will adds preprocess steps, gatk indel realignment and base recalibration is included here */
......@@ -70,13 +72,12 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
/** This methods will add double preprocess steps, with GATK indel realignment */
override protected def addDoublePreProcess(input: List[File], isIntermediate: Boolean = false): Option[File] = {
if (input.size <= 1) super.addDoublePreProcess(input)
else super.addDoublePreProcess(input, true).collect {
case file => {
else super.addDoublePreProcess(input, isIntermediate = true).collect {
case file =>
config("use_indel_realigner", default = true).asBoolean match {
case true => addIndelRealign(file, sampleDir, false)
case true => addIndelRealign(file, sampleDir, isIntermediate = false)
case false => file
}
}
}
}
}
......@@ -91,7 +92,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
indelRealigner.isIntermediate = isIntermediate
add(indelRealigner)
return indelRealigner.o
indelRealigner.o
}
/** Adds base recalibration jobs */
......@@ -117,7 +118,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
printReads.isIntermediate = isIntermediate
add(printReads)
return printReads.o
printReads.o
}
}
......
......@@ -12,6 +12,8 @@ import nl.lumc.sasc.biopet.pipelines.shiva.ShivaVariantcallingTrait
import org.broadinstitute.gatk.queue.QScript
/**
* ShivaVariantcalling with GATK variantcallers
*
* Created by pjvan_thof on 2/26/15.
*/
class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVariantcallingTrait {
......
......@@ -20,6 +20,8 @@ import org.scalatest.testng.TestNGSuite
import org.testng.annotations.{ DataProvider, Test }
/**
* Class for testing shiva
*
* Created by pjvan_thof on 3/2/15.
*/
class ShivaTest extends TestNGSuite with Matchers {
......@@ -48,16 +50,16 @@ class ShivaTest extends TestNGSuite with Matchers {
covariates: Boolean, realign: Boolean, baseRecalibration: Boolean): Unit = {
val map = {
var m: Map[String, Any] = ShivaTest.config
if (sample1) m = ConfigUtils.mergeMaps(ShivaTest.sample1, m.toMap)
if (sample2) m = ConfigUtils.mergeMaps(ShivaTest.sample2, m.toMap)
if (sample3) m = ConfigUtils.mergeMaps(ShivaTest.sample3, m.toMap)
if (dbsnp) m = ConfigUtils.mergeMaps(Map("dbsnp" -> "test"), m.toMap)
if (sample1) m = ConfigUtils.mergeMaps(ShivaTest.sample1, m)
if (sample2) m = ConfigUtils.mergeMaps(ShivaTest.sample2, m)
if (sample3) m = ConfigUtils.mergeMaps(ShivaTest.sample3, m)
if (dbsnp) m = ConfigUtils.mergeMaps(Map("dbsnp" -> "test"), m)
ConfigUtils.mergeMaps(Map("multisample_sample_variantcalling" -> multi,
"single_sample_variantcalling" -> single,
"library_variantcalling" -> library,
"use_analyze_covariates" -> covariates,
"use_indel_realigner" -> realign,
"use_base_recalibration" -> baseRecalibration), m.toMap)
"use_base_recalibration" -> baseRecalibration), m)
}
......
......@@ -22,6 +22,8 @@ import org.testng.annotations.{ AfterClass, DataProvider, Test }
import scala.collection.mutable.ListBuffer
/**
* Class for testing ShivaVariantcalling
*
* Created by pjvan_thof on 3/2/15.
*/
class ShivaVariantcallingTest extends TestNGSuite with Matchers {
......