From 958e6ba4ff1dcd1d21ab77943a119e0c0e0a0444 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Wed, 20 Jan 2016 14:06:13 +0100 Subject: [PATCH] Move script and init to main trait --- .../biopet/core/annotations/Annotations.scala | 20 +++++------ .../gentrap/measures/BasesPerExon.scala | 19 ++-------- .../gentrap/measures/BasesPerGene.scala | 20 +++-------- .../gentrap/measures/CufflinksBlind.scala | 19 ++-------- .../gentrap/measures/CufflinksGuided.scala | 19 ++-------- .../gentrap/measures/CufflinksStrict.scala | 19 ++-------- .../gentrap/measures/FragmentsPerExon.scala | 19 ++-------- .../gentrap/measures/FragmentsPerGene.scala | 19 ++-------- .../gentrap/measures/Measurement.scala | 35 ++++++++++++++++--- 9 files changed, 63 insertions(+), 126 deletions(-) diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/annotations/Annotations.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/annotations/Annotations.scala index 82d772fcd..d1300f020 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/annotations/Annotations.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/annotations/Annotations.scala @@ -5,13 +5,13 @@ import nl.lumc.sasc.biopet.core.BiopetQScript.InputFile import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ trait AnnotationGtf extends BiopetQScript { qscript: QScript => /** GTF reference file */ lazy val annotationGtf: File = { - val file: File = config("annotation_gtf") - inputFiles :+ InputFile(file, config("annotation_gtf_md5")) + val file: File = config("annotation_gtf", freeVar = true) + inputFiles :+ InputFile(file, config("annotation_gtf_md5", freeVar = true)) file } } @@ -19,8 +19,8 @@ trait AnnotationGtf extends BiopetQScript { qscript: QScript => trait AnnotationBed extends BiopetQScript { qscript: QScript => /** GTF reference file */ lazy val annotationBed: File = { - val file: File = config("annotation_bed") - inputFiles :+ InputFile(file, config("annotation_bed_md5")) + val file: File = config("annotation_bed", freeVar = true) + inputFiles :+ InputFile(file, config("annotation_bed_md5", freeVar = true)) file } } @@ -28,8 +28,8 @@ trait AnnotationBed extends BiopetQScript { qscript: QScript => trait AnnotationRefFlat extends BiopetQScript { qscript: QScript => /** GTF reference file */ lazy val annotationRefFlat: File = { - val file: File = config("annotation_refflat") - inputFiles :+ InputFile(file, config("annotation_refflat_md5")) + val file: File = config("annotation_refflat", freeVar = true) + inputFiles :+ InputFile(file, config("annotation_refflat_md5", freeVar = true)) file } } @@ -37,8 +37,8 @@ trait AnnotationRefFlat extends BiopetQScript { qscript: QScript => trait RibosomalRefFlat extends BiopetQScript { qscript: QScript => /** GTF reference file */ lazy val ribosomalRefFlat: File = { - val file: File = config("ribosome_refflat") - inputFiles :+ InputFile(file, config("ribosome_refflat_md5")) + val file: File = config("ribosome_refflat", freeVar = true) + inputFiles :+ InputFile(file, config("ribosome_refflat_md5", freeVar = true)) file } } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerExon.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerExon.scala index 3803b5dce..43f2a4806 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerExon.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerExon.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class BasesPerExon(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("BasesPerExon.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerGene.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerGene.scala index a550a02c1..599fb670c 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerGene.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/BasesPerGene.scala @@ -4,21 +4,9 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class BasesPerGene(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("BasesPerGene.summary.json") + //TODO: splitting on strand if strandspecific + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksBlind.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksBlind.scala index 3615540f2..f24e0ed80 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksBlind.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksBlind.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class CufflinksBlind(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("CufflinksBlind.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksGuided.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksGuided.scala index 900c707f6..a8b3e845a 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksGuided.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksGuided.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class CufflinksGuided(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("CufflinksGuided.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksStrict.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksStrict.scala index 0055d46bc..5fa3ce96f 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksStrict.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/CufflinksStrict.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class CufflinksStrict(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("CufflinksStrict.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerExon.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerExon.scala index 623dd039b..1d1fbb56e 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerExon.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerExon.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class FragmentsPerExon(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("FragmentsPerExon.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerGene.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerGene.scala index c3c24e268..904fcde16 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerGene.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/FragmentsPerGene.scala @@ -4,21 +4,8 @@ import nl.lumc.sasc.biopet.utils.config.Configurable import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ + * Created by pjvan_thof on 1/12/16. + */ class FragmentsPerGene(val root: Configurable) extends QScript with Measurement { - /** Init for pipeline */ - def init(): Unit = ??? - - /** Pipeline itself */ - def biopetScript(): Unit = ??? - - /** Must return a map with used settings for this pipeline */ - def summarySettings: Map[String, Any] = Map() - - /** File to put in the summary for thie pipeline */ - def summaryFiles: Map[String, File] = Map() - - /** Name of summary output file */ - def summaryFile: File = new File("FragmentsPerGene.summary.json") + def bamToCountFile(id: String, bamFile: File): (String, File) = ??? } diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/Measurement.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/Measurement.scala index eb39c09c9..37249c593 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/Measurement.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/measures/Measurement.scala @@ -5,13 +5,40 @@ import nl.lumc.sasc.biopet.core.summary.SummaryQScript import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvan_thof on 1/12/16. - */ -trait Measurement extends SummaryQScript with Reference { qscript : QScript => - private var bamFiles: Map[String, File] = Map() + * Created by pjvan_thof on 1/12/16. + */ +trait Measurement extends SummaryQScript with Reference { qscript: QScript => + protected var bamFiles: Map[String, File] = Map() def addBamfile(id: String, file: File): Unit = { require(!bamFiles.contains(id), s"'$id' already exist") bamFiles += id -> file } + + def name: String = this.getClass.getSimpleName.toLowerCase + + lazy val countFiles: Map[String, File] = bamFiles.map { case (id, bamFile) => bamToCountFile(id, bamFile) } + + /** Init for pipeline */ + def init(): Unit = { + require(bamFiles.nonEmpty) + } + + /** Pipeline itself */ + def biopetScript(): Unit = { + //TODO: Merging + + //TODO: Heatmap + } + + def bamToCountFile(id: String, bamFile: File): (String, File) + + /** Must return a map with used settings for this pipeline */ + def summarySettings: Map[String, Any] = Map() + + /** File to put in the summary for thie pipeline */ + def summaryFiles: Map[String, File] = Map() + + /** Name of summary output file */ + def summaryFile: File = new File(s"$name.summary.json") } -- GitLab