Commit 8ca365cb authored by Peter van 't Hof's avatar Peter van 't Hof

Change outputDir to File

parent 11cb5d29
......@@ -60,28 +60,34 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
}
def addMultiSampleJobs(): Unit = {
val refVariants = addGenerateFasta(null, outputDir + "reference/", outputName = "reference")
val refVariantSnps = addGenerateFasta(null, outputDir + "reference/", outputName = "reference", snpsOnly = true)
val refVariants = addGenerateFasta(null, new File(outputDir, "reference"), outputName = "reference")
val refVariantSnps = addGenerateFasta(null, new File(outputDir, "reference"), outputName = "reference", snpsOnly = true)
val catVariants = Cat(this, refVariants.variants :: samples.map(_._2.output.variants).toList, outputDir + "fastas/variant.fasta")
val catVariants = Cat(this, refVariants.variants :: samples.map(_._2.output.variants).toList,
new File(outputDir, "fastas" + File.separator + "variant.fasta"))
add(catVariants)
val catVariantsSnps = Cat(this, refVariantSnps.variants :: samples.map(_._2.outputSnps.variants).toList, outputDir + "fastas/variant.snps_only.fasta")
val catVariantsSnps = Cat(this, refVariantSnps.variants :: samples.map(_._2.outputSnps.variants).toList,
new File(outputDir, "fastas" + File.separator + "variant.snps_only.fasta"))
add(catVariantsSnps)
val catConsensus = Cat(this, refVariants.consensus :: samples.map(_._2.output.consensus).toList, outputDir + "fastas/consensus.fasta")
val catConsensus = Cat(this, refVariants.consensus :: samples.map(_._2.output.consensus).toList,
new File(outputDir, "fastas" + File.separator + "consensus.fasta"))
add(catConsensus)
val catConsensusSnps = Cat(this, refVariantSnps.consensus :: samples.map(_._2.outputSnps.consensus).toList, outputDir + "fastas/consensus.snps_only.fasta")
val catConsensusSnps = Cat(this, refVariantSnps.consensus :: samples.map(_._2.outputSnps.consensus).toList,
new File(outputDir, "fastas" + File.separator + "consensus.snps_only.fasta"))
add(catConsensusSnps)
val catConsensusVariants = Cat(this, refVariants.consensusVariants :: samples.map(_._2.output.consensusVariants).toList, outputDir + "fastas/consensus.variant.fasta")
val catConsensusVariants = Cat(this, refVariants.consensusVariants :: samples.map(_._2.output.consensusVariants).toList,
new File(outputDir, "fastas" + File.separator + "consensus.variant.fasta"))
add(catConsensusVariants)
val catConsensusVariantsSnps = Cat(this, refVariantSnps.consensusVariants :: samples.map(_._2.outputSnps.consensusVariants).toList, outputDir + "fastas/consensus.variant.snps_only.fasta")
val catConsensusVariantsSnps = Cat(this, refVariantSnps.consensusVariants :: samples.map(_._2.outputSnps.consensusVariants).toList,
new File(outputDir, "fastas" + File.separator + "consensus.variant.snps_only.fasta"))
add(catConsensusVariantsSnps)
val seed: Int = config("seed", default = 12345)
def addTreeJobs(variants: File, concensusVariants: File, outputDir: String, outputName: String) {
val dirSufixRaxml = if (outputDir.endsWith(File.separator)) "raxml" else File.separator + "raxml"
val dirSufixGubbins = if (outputDir.endsWith(File.separator)) "gubbins" else File.separator + "gubbins"
def addTreeJobs(variants: File, concensusVariants: File, outputDir: File, outputName: String) {
val dirSufixRaxml = new File(outputDir, "raxml")
val dirSufixGubbins = new File(outputDir, "gubbins")
val raxmlMl = new Raxml(this)
raxmlMl.input = variants
......@@ -101,7 +107,7 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
raxmlBoot.m = config("raxml_ml_model", default = "GTRGAMMAX")
raxmlBoot.p = seed
raxmlBoot.b = math.abs(r.nextInt)
raxmlBoot.w = outputDir + dirSufixRaxml
raxmlBoot.w = dirSufixRaxml
raxmlBoot.N = 1
raxmlBoot.n = outputName + "_boot_" + t
add(raxmlBoot)
......@@ -125,16 +131,18 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
val gubbins = new RunGubbins(this)
gubbins.fastafile = concensusVariants
gubbins.startingTree = Some(raxmlBi.getBipartitionsFile)
gubbins.outputDirectory = outputDir + dirSufixGubbins
gubbins.outputDirectory = dirSufixGubbins
add(gubbins)
}
addTreeJobs(catVariantsSnps.output, catConsensusVariantsSnps.output, outputDir + "trees" + File.separator + "snps_only", "snps_only")
addTreeJobs(catVariants.output, catConsensusVariants.output, outputDir + "trees" + File.separator + "snps_indels", "snps_indels")
addTreeJobs(catVariantsSnps.output, catConsensusVariantsSnps.output,
new File(outputDir, "trees" + File.separator + "snps_only"), "snps_only")
addTreeJobs(catVariants.output, catConsensusVariants.output,
new File(outputDir, "trees" + File.separator + "snps_indels"), "snps_indels")
}
def addGenerateFasta(sampleName: String, outputDir: String, outputName: String = null,
def addGenerateFasta(sampleName: String, outputDir: File, outputName: String = null,
snpsOnly: Boolean = false): FastaOutput = {
val bastyGenerateFasta = new BastyGenerateFasta(this)
bastyGenerateFasta.outputName = if (outputName != null) outputName else sampleName
......
......@@ -13,7 +13,7 @@ class IndelRealigner(val root: Configurable) extends org.broadinstitute.gatk.que
}
object IndelRealigner {
def apply(root: Configurable, input: File, targetIntervals: File, outputDir: String): IndelRealigner = {
def apply(root: Configurable, input: File, targetIntervals: File, outputDir: File): IndelRealigner = {
val ir = new IndelRealigner(root)
ir.input_file :+= input
ir.targetIntervals = targetIntervals
......
......@@ -18,7 +18,7 @@ class RealignerTargetCreator(val root: Configurable) extends org.broadinstitute.
}
object RealignerTargetCreator {
def apply(root: Configurable, input: File, outputDir: String): RealignerTargetCreator = {
def apply(root: Configurable, input: File, outputDir: File): RealignerTargetCreator = {
val re = new RealignerTargetCreator(root)
re.input_file :+= input
re.out = new File(outputDir, input.getName.stripSuffix(".bam") + ".realign.intervals")
......
......@@ -29,11 +29,8 @@ class GatkBenchmarkGenotyping(val root: Configurable) extends QScript with Biope
var dbsnp: File = config("dbsnp")
def init() {
if (config.contains("gvcffiles")) for (file <- config("gvcffiles").asList) {
if (config.contains("gvcffiles")) for (file <- config("gvcffiles").asList)
gvcfFiles ::= file.toString
}
if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module")
else if (!outputDir.endsWith("/")) outputDir += "/"
}
def biopetScript() {
......@@ -53,7 +50,7 @@ class GatkBenchmarkGenotyping(val root: Configurable) extends QScript with Biope
val gatkGenotyping = new GatkGenotyping(this)
gatkGenotyping.inputGvcfs = sampleGvcf :: gvcfPool
gatkGenotyping.samples :+= sampleName
gatkGenotyping.outputDir = outputDir + "samples_" + gvcfPool.size + "/"
gatkGenotyping.outputDir = new File(outputDir, "samples_" + gvcfPool.size + "/")
gatkGenotyping.init
gatkGenotyping.biopetScript
addAll(gatkGenotyping.functions)
......
......@@ -33,16 +33,15 @@ class GatkGenotyping(val root: Configurable) extends QScript with BiopetQScript
var samples: List[String] = Nil
def init() {
if (outputFile == null) outputFile = outputDir + outputName + ".vcf.gz"
if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module")
else if (!outputDir.endsWith("/")) outputDir += "/"
require(outputName != null, "Outputname is null")
if (outputFile == null) outputFile = new File(outputDir, outputName + ".vcf.gz")
}
def biopetScript() {
addGenotypeGVCFs(inputGvcfs, outputFile)
if (!samples.isEmpty) {
if (samples.size > 1) addSelectVariants(outputFile, samples, outputDir + "samples/", "all")
for (sample <- samples) addSelectVariants(outputFile, List(sample), outputDir + "samples/", sample)
if (samples.size > 1) addSelectVariants(outputFile, samples, new File(outputDir, "samples/"), "all")
for (sample <- samples) addSelectVariants(outputFile, List(sample), new File(outputDir, "samples/"), sample)
}
}
......@@ -52,8 +51,8 @@ class GatkGenotyping(val root: Configurable) extends QScript with BiopetQScript
return genotypeGVCFs.out
}
def addSelectVariants(inputFile: File, samples: List[String], outputDir: String, name: String) {
val selectVariants = SelectVariants(this, inputFile, outputDir + name + ".vcf.gz")
def addSelectVariants(inputFile: File, samples: List[String], outputDir: File, name: String) {
val selectVariants = SelectVariants(this, inputFile, new File(outputDir, name + ".vcf.gz"))
selectVariants.excludeNonVariants = true
for (sample <- samples) selectVariants.sample_name :+= sample
add(selectVariants)
......
......@@ -46,7 +46,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
val mapping = new Mapping(qscript)
mapping.sampleId = sampleId
mapping.libId = libId
mapping.outputDir = libDir + "/variantcalling/"
mapping.outputDir = new File(libDir, "variantcalling/")
/** Library variantcalling */
val gatkVariantcalling = new GatkVariantcalling(qscript)
......@@ -123,7 +123,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
/** sample variantcalling */
val gatkVariantcalling = new GatkVariantcalling(qscript)
gatkVariantcalling.sampleID = sampleId
gatkVariantcalling.outputDir = sampleDir + "/variantcalling/"
gatkVariantcalling.outputDir = new File(sampleDir, "variantcalling/")
protected def addJobs(): Unit = {
addPerLibJobs()
......@@ -140,8 +140,6 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
}
def init() {
if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module")
else if (!outputDir.endsWith("/")) outputDir += "/"
}
val multisampleVariantcalling = new GatkVariantcalling(this) {
......@@ -155,7 +153,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
def addMultiSampleJobs(): Unit = {
val gvcfFiles: List[File] = if (mergeGvcfs && externalGvcfs.size + samples.size > 1) {
val newFile = outputDir + "merged.gvcf.vcf.gz"
val newFile = new File(outputDir, "merged.gvcf.vcf.gz")
add(CombineGVCFs(this, externalGvcfs ++ samples.map(_._2.gatkVariantcalling.scriptOutput.gvcfFile), newFile))
List(newFile)
} else externalGvcfs ++ samples.map(_._2.gatkVariantcalling.scriptOutput.gvcfFile)
......@@ -164,7 +162,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
if (jointGenotyping) {
val gatkGenotyping = new GatkGenotyping(this)
gatkGenotyping.inputGvcfs = gvcfFiles
gatkGenotyping.outputDir = outputDir + "genotyping/"
gatkGenotyping.outputDir = new File(outputDir, "genotyping")
gatkGenotyping.init
gatkGenotyping.biopetScript
addAll(gatkGenotyping.functions)
......@@ -182,7 +180,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
}
if (gatkVariantcalling.useMpileup) {
val cvRaw = CombineVariants(this, allRawVcfFiles.toList, outputDir + "variantcalling/multisample.raw.vcf.gz")
val cvRaw = CombineVariants(this, allRawVcfFiles.toList, new File(outputDir, "variantcalling/multisample.raw.vcf.gz"))
add(cvRaw)
gatkVariantcalling.rawVcfInput = cvRaw.out
}
......@@ -190,7 +188,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
multisampleVariantcalling.preProcesBams = false
multisampleVariantcalling.doublePreProces = false
multisampleVariantcalling.inputBams = allBamfiles.toList
multisampleVariantcalling.outputDir = outputDir + "variantcalling"
multisampleVariantcalling.outputDir = new File(outputDir, "variantcalling")
multisampleVariantcalling.outputName = "multisample"
multisampleVariantcalling.init
multisampleVariantcalling.biopetScript
......@@ -200,7 +198,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
val recalibration = new GatkVariantRecalibration(this)
recalibration.inputVcf = multisampleVariantcalling.scriptOutput.finalVcfFile
recalibration.bamFiles = allBamfiles
recalibration.outputDir = outputDir + "recalibration/"
recalibration.outputDir = new File(outputDir, "recalibration")
recalibration.init
recalibration.biopetScript
}
......
......@@ -26,9 +26,7 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
var outputVcf: File = _
def init() {
if (inputVcf == null) throw new IllegalStateException("Missing Output directory on gatk module")
if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module")
else if (!outputDir.endsWith("/")) outputDir += "/"
require(inputVcf != null, "Missing Output directory on gatk module")
}
def biopetScript() {
......@@ -37,7 +35,7 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
vcfFile = addIndelVariantRecalibrator(vcfFile, outputDir)
}
def addSnpVariantRecalibrator(inputVcf: File, dir: String): File = {
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) {
......@@ -54,7 +52,7 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
}
}
def addIndelVariantRecalibrator(inputVcf: File, dir: String): File = {
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) {
......@@ -71,7 +69,7 @@ class GatkVariantRecalibration(val root: Configurable) extends QScript with Biop
}
}
def addVariantAnnotator(inputvcf: File, bamfiles: List[File], dir: String): File = {
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
......
......@@ -51,8 +51,6 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
def init() {
if (outputName == null && sampleID != null) outputName = sampleID
else if (outputName == null) outputName = config("output_name", default = "noname")
if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module")
else if (!outputDir.endsWith("/")) outputDir += "/"
val baseRecalibrator = new BaseRecalibrator(this)
if (preProcesBams && useBaseRecalibration && baseRecalibrator.knownSites.isEmpty) {
......@@ -65,7 +63,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
if (files.size == 1) return files
if (files.isEmpty) throw new IllegalStateException("Files can't be empty")
if (!doublePreProces.get) return files
val markDup = MarkDuplicates(this, files, new File(outputDir + outputName + ".dedup.bam"))
val markDup = MarkDuplicates(this, files, new File(outputDir, outputName + ".dedup.bam"))
markDup.isIntermediate = useIndelRealigner
add(markDup)
if (useIndelRealigner) {
......@@ -101,20 +99,20 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
val hcGvcf = new HaplotypeCaller(this)
hcGvcf.useGvcf
hcGvcf.input_file = scriptOutput.bamFiles
hcGvcf.out = outputDir + outputName + ".hc.discovery.gvcf.vcf.gz"
hcGvcf.out = new File(outputDir, outputName + ".hc.discovery.gvcf.vcf.gz")
add(hcGvcf)
scriptOutput.gvcfFile = hcGvcf.out
}
if (useHaplotypecaller.get) {
if (sampleID != null) {
val genotypeGVCFs = GenotypeGVCFs(this, List(scriptOutput.gvcfFile), outputDir + outputName + ".hc.discovery.vcf.gz")
val genotypeGVCFs = GenotypeGVCFs(this, List(scriptOutput.gvcfFile), new File(outputDir, outputName + ".hc.discovery.vcf.gz"))
add(genotypeGVCFs)
scriptOutput.hcVcfFile = genotypeGVCFs.out
} else {
val hcGvcf = new HaplotypeCaller(this)
hcGvcf.input_file = scriptOutput.bamFiles
hcGvcf.out = outputDir + outputName + ".hc.discovery.vcf.gz"
hcGvcf.out = new File(outputDir, outputName + ".hc.discovery.vcf.gz")
add(hcGvcf)
scriptOutput.hcVcfFile = hcGvcf.out
}
......@@ -124,7 +122,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
if (useUnifiedGenotyper.get) {
val ugVcf = new UnifiedGenotyper(this)
ugVcf.input_file = scriptOutput.bamFiles
ugVcf.out = outputDir + outputName + ".ug.discovery.vcf.gz"
ugVcf.out = new File(outputDir, outputName + ".ug.discovery.vcf.gz")
add(ugVcf)
scriptOutput.ugVcfFile = ugVcf.out
mergBuffer += ("2.UG-Discovery" -> scriptOutput.ugVcfFile)
......@@ -136,7 +134,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
val m2v = new MpileupToVcf(this)
m2v.inputBam = scriptOutput.bamFiles.head
m2v.sample = sampleID
m2v.output = outputDir + outputName + ".raw.vcf"
m2v.output = new File(outputDir, outputName + ".raw.vcf")
add(m2v)
scriptOutput.rawVcfFile = m2v.output
......@@ -148,7 +146,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
), super.defaults)
}
vcfFilter.inputVcf = m2v.output
vcfFilter.outputVcf = this.swapExt(outputDir, m2v.output, ".vcf", ".filter.vcf.gz")
vcfFilter.outputVcf = swapExt(outputDir, m2v.output, ".vcf", ".filter.vcf.gz")
add(vcfFilter)
scriptOutput.rawFilterVcfFile = vcfFilter.outputVcf
} else if (rawVcfInput != null) scriptOutput.rawFilterVcfFile = rawVcfInput
......@@ -164,7 +162,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
if (useHaplotypecaller.get) {
val hcAlleles = new HaplotypeCaller(this)
hcAlleles.input_file = scriptOutput.bamFiles
hcAlleles.out = outputDir + outputName + ".hc.allele.vcf.gz"
hcAlleles.out = new File(outputDir, outputName + ".hc.allele.vcf.gz")
hcAlleles.alleles = mergeAlleles.output
hcAlleles.genotyping_mode = org.broadinstitute.gatk.tools.walkers.genotyper.GenotypingOutputMode.GENOTYPE_GIVEN_ALLELES
add(hcAlleles)
......@@ -175,7 +173,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
if (useUnifiedGenotyper.get) {
val ugAlleles = new UnifiedGenotyper(this)
ugAlleles.input_file = scriptOutput.bamFiles
ugAlleles.out = outputDir + outputName + ".ug.allele.vcf.gz"
ugAlleles.out = new File(outputDir, outputName + ".ug.allele.vcf.gz")
ugAlleles.alleles = mergeAlleles.output
ugAlleles.genotyping_mode = org.broadinstitute.gatk.tools.walkers.genotyper.GenotypingOutputMode.GENOTYPE_GIVEN_ALLELES
add(ugAlleles)
......@@ -194,32 +192,32 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
sv.out
}
val cvFinal = CombineVariants(this, mergeList.toList, outputDir + outputName + ".final.vcf.gz")
val cvFinal = CombineVariants(this, mergeList.toList, new File(outputDir, outputName + ".final.vcf.gz"))
cvFinal.genotypemergeoption = org.broadinstitute.gatk.utils.variant.GATKVariantContextUtils.GenotypeMergeType.UNSORTED
add(cvFinal)
val vcfStats = new VcfStats(this)
vcfStats.input = cvFinal.out
vcfStats.setOutputDir(outputDir + File.separator + "vcfstats")
vcfStats.setOutputDir(new File(outputDir, "vcfstats"))
add(vcfStats)
scriptOutput.finalVcfFile = cvFinal.out
}
}
def addIndelRealign(inputBam: File, dir: String, isIntermediate: Boolean = true): File = {
def addIndelRealign(inputBam: File, dir: File, isIntermediate: Boolean = true): File = {
val realignerTargetCreator = RealignerTargetCreator(this, inputBam, dir)
realignerTargetCreator.isIntermediate = true
add(realignerTargetCreator)
val indelRealigner = IndelRealigner.apply(this, inputBam, realignerTargetCreator.out, dir)
val indelRealigner = IndelRealigner(this, inputBam, realignerTargetCreator.out, dir)
indelRealigner.isIntermediate = isIntermediate
add(indelRealigner)
return indelRealigner.o
}
def addBaseRecalibrator(inputBam: File, dir: String, isIntermediate: Boolean = false): File = {
def addBaseRecalibrator(inputBam: File, dir: File, isIntermediate: Boolean = false): File = {
val baseRecalibrator = BaseRecalibrator(this, inputBam, swapExt(dir, inputBam, ".bam", ".baserecal"))
if (baseRecalibrator.knownSites.isEmpty) {
......
......@@ -41,8 +41,6 @@ class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
var wholeGenome = false
def init() {
if (outputDir == null) throw new IllegalStateException("Missing Output directory on BamMetrics module")
else if (!outputDir.endsWith("/")) outputDir += "/"
if (config.contains("target_bed")) {
for (file <- config("target_bed").asList) {
bedFiles +:= new File(file.toString)
......@@ -63,7 +61,7 @@ class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
add(BedToInterval(this, baitBedFile, inputBam, outputDir), true)
for (bedFile <- bedFiles) {
val targetDir = outputDir + bedFile.getName.stripSuffix(".bed") + "/"
val targetDir = new File(outputDir, bedFile.getName.stripSuffix(".bed"))
val targetInterval = BedToInterval(this, bedFile, inputBam, targetDir)
add(targetInterval, true)
add(CalculateHsMetrics(this, inputBam, if (baitIntervalFile != null) baitIntervalFile
......@@ -87,7 +85,7 @@ class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
}
object BamMetrics extends PipelineCommand {
def apply(root: Configurable, bamFile: File, outputDir: String): BamMetrics = {
def apply(root: Configurable, bamFile: File, outputDir: File): BamMetrics = {
val bamMetrics = new BamMetrics(root)
bamMetrics.inputBam = bamFile
bamMetrics.outputDir = outputDir
......
......@@ -33,12 +33,10 @@ trait BiopetQScript extends Configurable with GatkLogging {
@Argument(doc = "JSON config file(s)", fullName = "config_file", shortName = "config", required = false)
val configfiles: List[File] = Nil
var outputDir: String = {
val temp = Config.getValueFromMap(globalConfig.map, ConfigValueIndex(this.configName, configPath, "output_dir"))
if (temp.isEmpty) ""
else {
val t = temp.get.value.toString
if (!t.endsWith("/")) t + "/" else t
var outputDir: File = {
Config.getValueFromMap(globalConfig.map, ConfigValueIndex(this.configName, configPath, "output_dir")) match {
case Some(value) => new File(value.asString)
case _ => new File(".")
}
}
......@@ -64,8 +62,6 @@ trait BiopetQScript extends Configurable with GatkLogging {
*/
final def script() {
outputDir = config("output_dir")
if (outputDir.isEmpty) outputDir = new File(".").getAbsolutePath()
else if (!outputDir.endsWith("/")) outputDir += "/"
init
biopetScript
......@@ -81,7 +77,7 @@ trait BiopetQScript extends Configurable with GatkLogging {
case _ =>
}
if (new File(outputDir).canWrite) globalConfig.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName)
if (outputDir.canWrite) globalConfig.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName)
else BiopetQScript.addError("Output dir: '" + outputDir + "' is not writeable")
BiopetQScript.checkErrors
......
......@@ -59,7 +59,7 @@ trait MultiSampleQScript extends BiopetQScript {
def createFile(suffix: String): File = new File(libDir, sampleId + "-" + libId + suffix)
/** Returns library directory */
def libDir = sampleDir + "lib_" + libId + File.separator
def libDir = new File(sampleDir, "lib_" + libId)
/** Function that add library jobs */
protected def addJobs()
......@@ -108,7 +108,7 @@ trait MultiSampleQScript extends BiopetQScript {
def createFile(suffix: String) = new File(sampleDir, sampleId + suffix)
/** Returns sample directory */
def sampleDir = outputDir + "samples" + File.separator + sampleId + File.separator
def sampleDir = new File(outputDir, "samples" + File.separator + sampleId)
}
/** Sample type, need implementation in pipeline */
......
......@@ -20,7 +20,7 @@ package nl.lumc.sasc.biopet.core
*/
trait ToolCommand extends MainCommand with Logging {
/** Placeholder for args */
protected abstract class AbstractArgs { }
protected abstract class AbstractArgs {}
/**
* Abstract opt parser to add efault args to each biopet tool
......
......@@ -48,7 +48,7 @@ package nl.lumc.sasc.biopet.core.workaround
import java.io.File
import org.broadinstitute.gatk.utils.commandline._
import org.broadinstitute.gatk.queue.util._
import org.broadinstitute.gatk.queue.{ QCommandPlugin, QScript, QScriptManager}
import org.broadinstitute.gatk.queue.{ QCommandPlugin, QScript, QScriptManager }
import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging }
import org.broadinstitute.gatk.queue.engine.{ QStatusMessenger, QGraphSettings, QGraph }
import collection.JavaConversions._
......
......@@ -43,10 +43,10 @@ class Md5sum(val root: Configurable) extends BiopetCommandLineFunction {
}
object Md5sum {
def apply(root: Configurable, fastqfile: File, outDir: String): Md5sum = {
def apply(root: Configurable, fastqfile: File, outDir: File): Md5sum = {
val md5sum = new Md5sum(root)
md5sum.input = fastqfile
md5sum.output = new File(outDir + fastqfile.getName + ".md5")
md5sum.output = new File(outDir, fastqfile.getName + ".md5")
return md5sum
}
}
......@@ -51,13 +51,6 @@ class Seqstat(val root: Configurable) extends BiopetCommandLineFunction {
}
object Seqstat {
def apply(root: Configurable, input: File, output: File): Seqstat = {
val seqstat = new Seqstat(root)
seqstat.input = input
seqstat.output = output
return seqstat
}
def apply(root: Configurable, fastqfile: File, outDir: String): Seqstat = {
val seqstat = new Seqstat(root)
val ext = fastqfile.getName.substring(fastqfile.getName.lastIndexOf("."))
......
......@@ -52,9 +52,9 @@ class Star(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", "STAR")
@Argument(doc = "Output Directory")
var outputDir: String = _
var outputDir: File = _
var genomeDir: String = config("genomeDir", reference.getParent + "/star/")
var genomeDir: File = config("genomeDir", new File(reference.getParent, "/star"))
var runmode: String = _
var sjdbOverhang: Int = _
var outFileNamePrefix: String = _
......@@ -64,7 +64,6 @@ class Star(val root: Configurable) extends BiopetCommandLineFunction {
override def afterGraph() {
if (outFileNamePrefix != null && !outFileNamePrefix.endsWith(".")) outFileNamePrefix += "."
if (!outputDir.endsWith("/")) outputDir += "/"
val