Commit bfdd3e42 authored by bow's avatar bow
Browse files

Merge branch 'feature-fix_only_sample' into 'develop'

Feature fix only sample

Fix for #109

Also added addMultiSampleJobs method.

Not sure but maybe method addPerSampleJobs need a new name but just don't know what.

See merge request !79
parents d46ad182 29f9b30f
......@@ -41,7 +41,7 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
var outputSnps: FastaOutput = _
protected def addJobs(): Unit = {
addLibsJobs()
addPerLibJobs()
output = addGenerateFasta(sampleId, sampleDir)
outputSnps = addGenerateFasta(sampleId, sampleDir, snpsOnly = true)
}
......@@ -56,11 +56,13 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
gatkPipeline.biopetScript
addAll(gatkPipeline.functions)
addSamplesJobs()
}
def addMultiSampleJobs(): Unit = {
val refVariants = addGenerateFasta(null, outputDir + "reference/", outputName = "reference")
val refVariantSnps = addGenerateFasta(null, outputDir + "reference/", outputName = "reference", snpsOnly = true)
addSamplesJobs()
val catVariants = Cat(this, refVariants.variants :: samples.map(_._2.output.variants).toList, outputDir + "fastas/variant.fasta")
add(catVariants)
val catVariantsSnps = Cat(this, refVariantSnps.variants :: samples.map(_._2.outputSnps.variants).toList, outputDir + "fastas/variant.snps_only.fasta")
......@@ -129,6 +131,7 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
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")
}
def addGenerateFasta(sampleName: String, outputDir: String, outputName: String = null,
......
......@@ -127,7 +127,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
gatkVariantcalling.outputDir = sampleDir + "/variantcalling/"
protected def addJobs(): Unit = {
addLibsJobs()
addPerLibJobs()
gatkVariantcalling.inputBams = libraries.map(_._2.mapping.finalBamFile).toList
gatkVariantcalling.preProcesBams = false
if (!singleSampleCalling) {
......@@ -150,10 +150,11 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
override def configPath: List[String] = super.configPath ::: "multisample" :: Nil
}
def biopetScript() {
addSamplesJobs
def biopetScript(): Unit = {
addSamplesJobs()
}
//SampleWide jobs
def addMultiSampleJobs(): Unit = {
val gvcfFiles: List[File] = if (mergeGvcfs && externalGvcfs.size + samples.size > 1) {
val newFile = outputDir + "merged.gvcf.vcf.gz"
add(CombineGVCFs(this, externalGvcfs ++ samples.map(_._2.gatkVariantcalling.scriptOutput.gvcfFile), newFile))
......
......@@ -26,7 +26,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Argument }
*/
trait MultiSampleQScript extends BiopetQScript {
@Argument(doc = "Only Sample", shortName = "sample", required = false)
val onlySample: List[String] = Nil
private val onlySamples: List[String] = Nil
require(Config.global.map.contains("samples"), "No Samples found in config")
......@@ -94,7 +94,7 @@ trait MultiSampleQScript extends BiopetQScript {
protected def addJobs()
/** function add all libraries in one call */
protected final def addLibsJobs(): Unit = {
protected final def addPerLibJobs(): Unit = {
for ((libraryId, library) <- libraries) {
library.addAndTrackJobs()
}
......@@ -125,17 +125,24 @@ trait MultiSampleQScript extends BiopetQScript {
val samples: Map[String, Sample] = sampleIds.map(id => id -> makeSample(id)).toMap
/** Returns a list of all sampleIDs */
protected def sampleIds: Set[String] = if (onlySample != Nil) onlySample.toSet else {
ConfigUtils.any2map(Config.global.map("samples")).keySet
}
protected def sampleIds: Set[String] = ConfigUtils.any2map(Config.global.map("samples")).keySet
/** Runs addAndTrackJobs method for each sample */
final def addSamplesJobs() {
for ((sampleId, sample) <- samples) {
sample.addAndTrackJobs()
}
if (onlySamples.isEmpty) {
samples.foreach { case (sampleId, sample) => sample.addAndTrackJobs() }
addMultiSampleJobs()
} else onlySamples.foreach(sampleId => samples.get(sampleId) match {
case Some(sample) => sample.addAndTrackJobs()
case None => logger.warn("sampleId '" + sampleId + "' not found")
})
}
/**
* Method where the multisample jobs should be added, this will be executed only when running the -sample argument is not given
*/
def addMultiSampleJobs()
/** Stores sample state */
private var currentSample: Option[String] = None
......
......@@ -37,6 +37,9 @@ class MultisamplePipelineTemplate(val root: Configurable) extends QScript with M
}
}
def addMultiSampleJobs(): Unit = {
}
def init(): Unit = {
}
......
......@@ -67,7 +67,7 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript {
val controls: List[String] = config("control", default = Nil)
def addJobs(): Unit = {
addLibsJobs()
addPerLibJobs()
val bamFiles = libraries.map(_._2.mapping.finalBamFile).toList
if (bamFiles.length == 1) {
add(Ln(qscript, bamFiles.head, bamFile))
......@@ -102,8 +102,10 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript {
// Third step is calling peaks on the bam files produced with the mapping pipeline, this will be done with MACS2
logger.info("Starting CArP pipeline")
addSamplesJobs
addSamplesJobs()
}
def addMultiSampleJobs(): Unit = {
for ((sampleId, sample) <- samples) {
for (controlId <- sample.controls) {
if (!samples.contains(controlId))
......
......@@ -25,31 +25,29 @@ class Kopisu(val root: Configurable) extends QScript with MultiSampleQScript {
@Input(doc = "Input bamfile", required = true)
var bamFile: File = config("bam")
class LibraryOutput extends AbstractLibraryOutput {
}
class SampleOutput extends AbstractSampleOutput {
}
def init() {
if (!outputDir.endsWith("/")) outputDir += "/"
}
def biopetScript() {
runSamplesJobs
addSamplesJobs()
}
// Called for each sample
def runSingleSampleJobs(sampleConfig: Map[String, Any]): SampleOutput = {
val sampleOutput = new SampleOutput
def makeSample(id: String) = new Sample(id)
class Sample(sampleId: String) extends AbstractSample(sampleId) {
def makeLibrary(id: String) = new Library(id)
class Library(libraryId: String) extends AbstractLibrary(libraryId) {
def addJobs(): Unit = {
}
}
def addJobs(): Unit = {
return sampleOutput
}
}
// Called for each run from a sample
def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): LibraryOutput = {
val libraryOutput = new LibraryOutput
return libraryOutput
def addMultiSampleJobs(): Unit = {
}
}
......
......@@ -103,7 +103,7 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
}
protected def addJobs(): Unit = {
addLibsJobs()
addPerLibJobs()
val libraryBamfiles = libraries.map(_._2.mapping.finalBamFile).toList
val libraryFastqFiles = libraries.map(_._2.prefixFastq).toList
......@@ -151,7 +151,10 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
tagsLibrary = cdl.output
}
addSamplesJobs
addSamplesJobs()
}
def addMultiSampleJobs(): Unit = {
}
def addBedtoolsCounts(bamFile: File, outputPrefix: String, outputDir: String) {
......
Supports Markdown
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