Commit 7e7bf6a4 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Convert gears to subscripts

parent cd500560
...@@ -22,6 +22,7 @@ import nl.lumc.sasc.biopet.extensions.kraken.{ Kraken, KrakenReport } ...@@ -22,6 +22,7 @@ import nl.lumc.sasc.biopet.extensions.kraken.{ Kraken, KrakenReport }
import nl.lumc.sasc.biopet.extensions.picard.SamToFastq import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsView import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsView
import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
...@@ -74,69 +75,27 @@ class GearsSingle(val root: Configurable) extends QScript with SummaryQScript wi ...@@ -74,69 +75,27 @@ class GearsSingle(val root: Configurable) extends QScript with SummaryQScript wi
Some(gears) Some(gears)
} }
override def defaults = Map(
"samtofastq" -> Map(
"validationstringency" -> "LENIENT"
)
)
/** Method to add jobs */ /** Method to add jobs */
def biopetScript(): Unit = { def biopetScript(): Unit = {
val fastqFiles: List[File] = bamFile.map { bamfile => val (r1: File, r2: Option[File]) = (fastqR1, fastqR2, bamFile) match {
case (Some(r1), r2, _) => (r1, r2)
val samtoolsViewSelectUnmapped = new SamtoolsView(this) case (_, _, Some(bam)) =>
samtoolsViewSelectUnmapped.input = bamfile val extract = new ExtractUnmappedReads(this)
samtoolsViewSelectUnmapped.b = true extract.bamFile = bam
samtoolsViewSelectUnmapped.output = new File(outputDir, s"$outputName.unmapped.bam") extract.init()
samtoolsViewSelectUnmapped.f = List("12") extract.biopetScript()
samtoolsViewSelectUnmapped.isIntermediate = true addAll(extract.functions)
add(samtoolsViewSelectUnmapped) (extract.fastqUnmappedR1, Some(extract.fastqUnmappedR2))
case _ => Logging.addError("Missing input files")
// start bam to fastq (only on unaligned reads) also extract the matesam }
val samToFastq = new SamToFastq(this)
samToFastq.input = samtoolsViewSelectUnmapped.output val kraken = new GearsKraken(this)
samToFastq.fastqR1 = new File(outputDir, s"$outputName.unmapped.R1.fq.gz") kraken.fastqR1 = r1
samToFastq.fastqR2 = new File(outputDir, s"$outputName.unmapped.R2.fq.gz") kraken.fastqR2 = r2
samToFastq.fastqUnpaired = new File(outputDir, s"$outputName.unmapped.singleton.fq.gz") kraken.init()
samToFastq.isIntermediate = true kraken.biopetScript()
add(samToFastq) addAll(kraken.functions)
addSummaryQScript(kraken)
List(samToFastq.fastqR1, samToFastq.fastqR2)
}.getOrElse(List(fastqR1, fastqR2).flatten)
// start kraken
val krakenAnalysis = new Kraken(this)
krakenAnalysis.input = fastqFiles
krakenAnalysis.output = new File(outputDir, s"$outputName.krkn.raw")
krakenAnalysis.paired = fastqFiles.length == 2
krakenAnalysis.classified_out = Some(new File(outputDir, s"$outputName.krkn.classified.fastq"))
krakenAnalysis.unclassified_out = Some(new File(outputDir, s"$outputName.krkn.unclassified.fastq"))
add(krakenAnalysis)
outputFiles += ("kraken_output_raw" -> krakenAnalysis.output)
outputFiles += ("kraken_classified_out" -> krakenAnalysis.classified_out.getOrElse(""))
outputFiles += ("kraken_unclassified_out" -> krakenAnalysis.unclassified_out.getOrElse(""))
// create kraken summary file
val krakenReport = new KrakenReport(this)
krakenReport.input = krakenAnalysis.output
krakenReport.show_zeros = true
krakenReport.output = new File(outputDir, s"$outputName.krkn.full")
add(krakenReport)
outputFiles += ("kraken_report_input" -> krakenReport.input)
outputFiles += ("kraken_report_output" -> krakenReport.output)
val krakenReportJSON = new KrakenReportToJson(this)
krakenReportJSON.inputReport = krakenReport.output
krakenReportJSON.output = new File(outputDir, s"$outputName.krkn.json")
krakenReportJSON.skipNames = config("skipNames", default = false)
add(krakenReportJSON)
addSummarizable(krakenReportJSON, "krakenreport")
outputFiles += ("kraken_report_json_input" -> krakenReportJSON.inputReport)
outputFiles += ("kraken_report_json_output" -> krakenReportJSON.output)
addSummaryJobs() addSummaryJobs()
} }
......
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