Commit 7336a86d authored by Peter van 't Hof's avatar Peter van 't Hof

Merge remote-tracking branch 'remotes/origin/develop' into fix-BIOPET-425

parents 051ca556 39070750
......@@ -33,10 +33,15 @@ class SortVcf(val root: Configurable) extends Picard with Reference {
@Input(doc = "Sequence dictionary to use", required = true)
var sequenceDictionary: File = _
@Output
private var outputIndex: File = _
override val dictRequired = true
override def beforeGraph(): Unit = {
super.beforeGraph()
if (output.getName.endsWith(".vcf.gz")) outputIndex = new File(output.getAbsolutePath + ".tbi")
if (output.getName.endsWith(".vcf")) outputIndex = new File(output.getAbsolutePath + ".idx")
if (sequenceDictionary == null) sequenceDictionary = referenceDictFile
}
......
......@@ -141,12 +141,20 @@ class Gears(val root: Configurable) extends QScript with MultiSampleQScript { qs
class Library(libId: String) extends AbstractLibrary(libId) {
lazy val flexiprep = new Flexiprep(qscript)
flexiprep.sampleId = Some(sampleId)
flexiprep.libId = Some(libId)
flexiprep.inputR1 = config("R1")
flexiprep.inputR2 = config("R2")
flexiprep.outputDir = new File(libDir, "flexiprep")
lazy val inputR1: File = config("R1")
lazy val inputR2: Option[File] = config("R2")
lazy val skipFlexiprep: Boolean = config("skip_flexiprep", default = false)
lazy val flexiprep = if (skipFlexiprep) None else Some(new Flexiprep(qscript))
flexiprep.foreach(_.sampleId = Some(sampleId))
flexiprep.foreach(_.libId = Some(libId))
flexiprep.foreach(_.inputR1 = inputR1)
flexiprep.foreach(_.inputR2 = inputR2)
flexiprep.foreach(_.outputDir = new File(libDir, "flexiprep"))
lazy val qcR1: File = flexiprep.map(_.fastqR1Qc).getOrElse(inputR1)
lazy val qcR2: Option[File] = flexiprep.map(_.fastqR2Qc).getOrElse(inputR2)
val libraryGears: Boolean = config("library_gears", default = false)
......@@ -154,17 +162,17 @@ class Gears(val root: Configurable) extends QScript with MultiSampleQScript { qs
/** Function that add library jobs */
protected def addJobs(): Unit = {
inputFiles :+= InputFile(flexiprep.inputR1, config("R1_md5"))
flexiprep.inputR2.foreach(inputFiles :+= InputFile(_, config("R2_md5")))
add(flexiprep)
inputFiles :+= InputFile(inputR1, config("R1_md5"))
inputR2.foreach(inputFiles :+= InputFile(_, config("R2_md5")))
flexiprep.foreach(add(_))
gearsSingle.foreach { gs =>
gs.sampleId = Some(sampleId)
gs.libId = Some(libId)
gs.outputDir = libDir
gs.fastqR1 = List(addDownsample(flexiprep.fastqR1Qc, gs.outputDir))
gs.fastqR2 = flexiprep.fastqR2Qc.map(addDownsample(_, gs.outputDir)).toList
gs.fastqR1 = List(addDownsample(qcR1, gs.outputDir))
gs.fastqR2 = qcR2.map(addDownsample(_, gs.outputDir)).toList
add(gs)
}
}
......@@ -187,11 +195,11 @@ class Gears(val root: Configurable) extends QScript with MultiSampleQScript { qs
val flexipreps = libraries.values.map(_.flexiprep).toList
val mergeR1: File = new File(sampleDir, s"$sampleId.R1.fq.gz")
add(Zcat(qscript, flexipreps.map(_.fastqR1Qc)) | new Gzip(qscript) > mergeR1)
add(Zcat(qscript, libraries.values.map(_.qcR1).toList) | new Gzip(qscript) > mergeR1)
val mergeR2 = if (flexipreps.exists(_.paired)) Some(new File(sampleDir, s"$sampleId.R2.fq.gz")) else None
val mergeR2 = if (libraries.values.exists(_.inputR2.isDefined)) Some(new File(sampleDir, s"$sampleId.R2.fq.gz")) else None
mergeR2.foreach { file =>
add(Zcat(qscript, flexipreps.flatMap(_.fastqR2Qc)) | new Gzip(qscript) > file)
add(Zcat(qscript, libraries.values.flatMap(_.qcR2).toList) | new Gzip(qscript) > file)
}
gearsSingle.fastqR1 = List(addDownsample(mergeR1, gearsSingle.outputDir))
......
......@@ -46,6 +46,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
def indexPage = {
val krakenExecuted = summary.getSampleValues("gearskraken", "stats", "krakenreport").values.forall(_.isDefined)
val centrifugeExecuted = summary.getSampleValues("gearscentrifuge", "stats", "centrifuge_report").values.forall(_.isDefined)
val wgsExecuted = summary.getSampleValues("bammetrics", "stats", "wgs").values.exists(_.isDefined)
val rnaExecuted = summary.getSampleValues("bammetrics", "stats", "rna").values.exists(_.isDefined)
val insertsizeExecuted = summary.getSampleValues("bammetrics", "stats", "CollectInsertSizeMetrics", "metrics").values.exists(_ != Some(None))
......@@ -56,9 +57,15 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
ReportPage(
List("Samples" -> generateSamplesPage(pageArgs)) ++
(if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
(if (krakenExecuted) List("Dustbin analysis - Kraken" -> ReportPage(List(), List(
"Krona plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
else Nil) ++ (if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map())), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge")))
else Nil) ++
List("Reference" -> ReportPage(List(), List(
"Reference" -> ReportSection("/nl/lumc/sasc/biopet/core/report/reference.ssp", Map("pipeline" -> pipelineName))
......@@ -109,13 +116,20 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Single sample page */
def samplePage(sampleId: String, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), None, "gearskraken", "stats", "krakenreport").isDefined
val centrifugeExecuted = summary.getValue(Some(sampleId), None, "gearscentrifuge", "stats", "centrifuge_report").isDefined
val flexiprepExecuted = summary.getLibraryValues("flexiprep")
.exists { case ((sample, lib), value) => sample == sampleId && value.isDefined }
ReportPage(List(
"Libraries" -> generateLibraryPage(args),
"Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), None)) ++
(if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
(if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map())), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge")))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
"Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
else Nil) ++
......@@ -133,12 +147,19 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
/** Library page */
def libraryPage(sampleId: String, libId: String, args: Map[String, Any]): ReportPage = {
val krakenExecuted = summary.getValue(Some(sampleId), Some(libId), "gearskraken", "stats", "krakenreport").isDefined
val centrifugeExecuted = summary.getValue(Some(sampleId), Some(libId), "gearscentrifuge", "stats", "centrifuge_report").isDefined
val flexiprepExecuted = summary.getValue(Some(sampleId), Some(libId), "flexiprep").isDefined
ReportPage(
("Alignment" -> BammetricsReport.bamMetricsPage(summary, Some(sampleId), Some(libId))) ::
(if (flexiprepExecuted) List("QC" -> FlexiprepReport.flexiprepPage) else Nil) :::
(if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
(if (centrifugeExecuted) List("Centriguge analysis" -> ReportPage(List("Non-unique" -> ReportPage(List(), List("All mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_report")
)), Map())), List(
"Unique mappings" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp",
Map("summaryStatsTag" -> "centrifuge_unique_report")
)), Map("summaryModuleTag" -> "gearscentrifuge")))
else Nil) ::: (if (krakenExecuted) List("Dustbin analysis" -> ReportPage(List(), List(
"Krona Plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
)), Map()))
else Nil),
......
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