Commit 78ff9834 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added scala docs to multisampleMapping

parent 1e87ae80
......@@ -24,6 +24,7 @@ import scala.collection.JavaConversions._
trait MultisampleMappingTrait extends MultiSampleQScript
with Reference { qscript: QScript =>
/** With this method the merge strategy for libraries to samples is defined. This can be overriden to fix the merge strategy. */
def mergeStrategy: MergeStrategy.Value = {
val value: String = config("merge_strategy", default = "preprocessmarkduplicates")
MergeStrategy.values.find(_.toString.toLowerCase == value) match {
......@@ -35,11 +36,13 @@ trait MultisampleMappingTrait extends MultiSampleQScript
def init(): Unit = {
}
/** Is there are jobs that needs to be added before the rest of the jobs this methods can be overriden, to let the sample jobs this work the super call should be done also */
def biopetScript(): Unit = {
addSamplesJobs()
addSummaryJobs()
}
/** This is de default multisample mapping report, this can be extended by other pipelines */
override def reportClass: Option[ReportBuilderExtension] = {
val report = new MultisampleMappingReport(this)
report.outputDir = new File(outputDir, "report")
......@@ -47,12 +50,15 @@ trait MultisampleMappingTrait extends MultiSampleQScript
Some(report)
}
/** In a default multisample mapping run there are no multsample jobs. This method can be overriden by other pipelines */
def addMultiSampleJobs(): Unit = {
// this code will be executed after all code of all samples is executed
}
/** By default only the reference is put in the summary, when extending pippeline specific files can be added */
def summaryFiles: Map[String, File] = Map("referenceFasta" -> referenceFasta())
/** By default only the reference is put in the summary, when extending pippeline specific settings can be added */
def summarySettings: Map[String, Any] = Map(
"reference" -> referenceSummary,
"merge_strategy" -> mergeStrategy.toString)
......@@ -62,6 +68,8 @@ trait MultisampleMappingTrait extends MultiSampleQScript
def makeLibrary(id: String) = new Library(id)
class Library(libId: String) extends AbstractLibrary(libId) {
/** By default the bams files are put in the summary, more files can be added here */
def summaryFiles: Map[String, File] = (inputR1.map("input_R1" -> _) :: inputR2.map("input_R2" -> _) ::
inputBam.map("input_bam" -> _) :: bamFile.map("output_bam" -> _) ::
preProcessBam.map("output_bam_preprocess" -> _) :: Nil).flatten.toMap
......@@ -88,8 +96,10 @@ trait MultisampleMappingTrait extends MultiSampleQScript
case _ => None
}
/** By default the preProcessBam is the same as the normal bamFile. A pipeline can extend this is there are preprocess steps */
def preProcessBam = bamFile
/** This method can be extended to add jobs to the pipeline, to do this the super call of this function must be called by the pipelines */
def addJobs(): Unit = {
inputR1.foreach(inputFiles :+= new InputFile(_, config("R1_md5")))
inputR2.foreach(inputFiles :+= new InputFile(_, config("R2_md5")))
......@@ -162,20 +172,25 @@ trait MultisampleMappingTrait extends MultiSampleQScript
}
}
/** By default the bams files are put in the summary, more files can be added here */
def summaryFiles: Map[String, File] = (bamFile.map("output_bam" -> _) ::
preProcessBam.map("output_bam_preprocess" -> _) :: Nil).flatten.toMap
def summaryStats: Map[String, Any] = Map()
/** This is the merged bam file, None if the merged bam file is NA */
def bamFile = if (libraries.flatMap(_._2.bamFile).nonEmpty &&
mergeStrategy != MultisampleMapping.MergeStrategy.None)
Some(new File(sampleDir, s"$sampleId.bam"))
else None
/** By default the preProcessBam is the same as the normal bamFile. A pipeline can extend this is there are preprocess steps */
def preProcessBam = bamFile
/** Default is set to keep the merged files, user can set this in the config. To change the default this method can be overriden */
def keepMergedFiles: Boolean = config("keep_merged_files", default = true)
/** This method can be extended to add jobs to the pipeline, to do this the super call of this function must be called by the pipelines */
def addJobs(): Unit = {
addPerLibJobs() // This add jobs for each library
......@@ -217,6 +232,7 @@ trait MultisampleMappingTrait extends MultiSampleQScript
}
}
/** This class is the default implementation that can be used on the command line */
class MultisampleMapping(val root: Configurable) extends QScript with MultisampleMappingTrait {
def this() = this(null)
......@@ -229,6 +245,7 @@ object MultisampleMapping extends PipelineCommand {
val None, MergeSam, MarkDuplicates, PreProcessMergeSam, PreProcessMarkDuplicates = Value
}
/** When file is not absolute an error is raise att the end of the script of a pipeline */
def fileMustBeAbsolute(file: Option[File]): Option[File] = {
if (file.forall(_.isAbsolute)) file
else {
......
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