Commit 8b7765a4 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Switched to reference module

parent b2fd3e7c
......@@ -19,7 +19,11 @@ trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction wit
if (config.contains("intervals")) intervals = config("intervals").asFileList
if (config.contains("exclude_intervals")) excludeIntervals = config("exclude_intervals").asFileList
reference_sequence = referenceFasta()
if (config.contains("gatk_key")) gatk_key = config("gatk_key")
if (config.contains("pedigree")) pedigree = config("pedigree")
override def beforeGraph: Unit = {
super.beforeGraph
if (reference_sequence == null) reference_sequence = referenceFasta()
}
}
......@@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.{Reference, BiopetCommandLineFunction}
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
......@@ -26,7 +26,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
*
* Based on version 1.1.1
*/
class Bowtie(val root: Configurable) extends BiopetCommandLineFunction {
class Bowtie(val root: Configurable) extends BiopetCommandLineFunction with Reference {
@Input(doc = "Fastq file R1", shortName = "R1")
var R1: File = null
......@@ -34,7 +34,7 @@ class Bowtie(val root: Configurable) extends BiopetCommandLineFunction {
var R2: Option[File] = None
@Input(doc = "The reference file for the bam files.", shortName = "R", required = true)
var reference: File = config("reference")
var reference: File = null
@Output(doc = "Output file SAM", shortName = "output", required = true)
var output: File = null
......@@ -59,6 +59,11 @@ class Bowtie(val root: Configurable) extends BiopetCommandLineFunction {
var maqerr: Option[Int] = config("maqerr")
var maxins: Option[Int] = config("maxins")
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
/** return commandline to execute */
def cmdLine = {
required(executable) +
......
......@@ -19,14 +19,14 @@ import java.io.File
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.{Reference, BiopetCommandLineFunction}
import nl.lumc.sasc.biopet.core.config.Configurable
/**
* Wrapper for the gsnap command line tool
* Written based on gsnap version 2014-05-15
*/
class Gsnap(val root: Configurable) extends BiopetCommandLineFunction {
class Gsnap(val root: Configurable) extends BiopetCommandLineFunction with Reference {
/** default executable */
executable = config("exe", default = "gsnap", freeVar = false)
......
......@@ -17,12 +17,12 @@ package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.{Reference, BiopetCommandLineFunction}
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/** Extension for stampy */
class Stampy(val root: Configurable) extends BiopetCommandLineFunction {
class Stampy(val root: Configurable) extends BiopetCommandLineFunction with Reference {
@Input(doc = "FastQ file R1", shortName = "R1")
var R1: File = _
......@@ -30,7 +30,7 @@ class Stampy(val root: Configurable) extends BiopetCommandLineFunction {
var R2: File = _
@Input(doc = "The reference file for the bam files.", shortName = "ref")
var reference: File = config("reference")
var reference: File = null
@Input(doc = "The genome prefix.")
var genome: File = config("genome")
......@@ -73,6 +73,7 @@ class Stampy(val root: Configurable) extends BiopetCommandLineFunction {
override def beforeGraph: Unit = {
super.beforeGraph
require(readgroup != null)
if (reference == null) reference = referenceFasta()
}
/** Returns command to execute */
......
......@@ -17,16 +17,16 @@ package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.{Reference, BiopetCommandLineFunction}
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
/**
* Extension for STAR
*/
class Star(val root: Configurable) extends BiopetCommandLineFunction {
class Star(val root: Configurable) extends BiopetCommandLineFunction with Reference {
@Input(doc = "The reference file for the bam files.", required = false)
var reference: File = new File(config("reference"))
var reference: File = null
@Input(doc = "Fastq file R1", required = false)
var R1: File = _
......@@ -57,7 +57,7 @@ class Star(val root: Configurable) extends BiopetCommandLineFunction {
@Argument(doc = "Output Directory")
var outputDir: File = _
var genomeDir: File = config("genomeDir", new File(reference.getAbsoluteFile.getParent, "star"))
var genomeDir: File = null
var runmode: String = _
var sjdbOverhang: Int = _
var outFileNamePrefix: String = _
......@@ -68,6 +68,9 @@ class Star(val root: Configurable) extends BiopetCommandLineFunction {
/** Sets output files for the graph */
override def beforeGraph() {
super.beforeGraph
if (reference == null) reference = referenceFasta()
genomeDir = config("genomeDir", new File(reference.getAbsoluteFile.getParent, "star"))
if (outFileNamePrefix != null && !outFileNamePrefix.endsWith(".")) outFileNamePrefix += "."
val prefix = if (outFileNamePrefix != null) outputDir + outFileNamePrefix else outputDir
if (runmode == null) {
......
......@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.extensions.bwa
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
......@@ -27,12 +28,12 @@ import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
*
* Created by pjvan_thof on 1/16/15.
*/
class BwaAln(val root: Configurable) extends Bwa {
class BwaAln(val root: Configurable) extends Bwa with Reference {
@Input(doc = "Fastq file", required = true)
var fastq: File = _
@Input(doc = "The reference file for the bam files.", required = true)
var reference: File = config("reference")
var reference: File = null
@Output(doc = "Output file SAM", required = false)
var output: File = _
......@@ -63,6 +64,11 @@ class BwaAln(val root: Configurable) extends Bwa {
override val defaultCoreMemory = 4.0
override val defaultThreads = 8
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
/** Returns command to execute */
def cmdLine = required(executable) +
required("aln") +
......
......@@ -35,7 +35,7 @@ class BwaMem(val root: Configurable) extends Bwa with Reference {
var R2: File = _
@Input(doc = "The reference file for the bam files.", shortName = "R")
var reference: File = referenceFasta()
var reference: File = null
@Output(doc = "Output file SAM", shortName = "output")
var output: File = _
......@@ -72,6 +72,11 @@ class BwaMem(val root: Configurable) extends Bwa with Reference {
override val defaultCoreMemory = 4.0
override val defaultThreads = 8
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
def cmdLine = {
required(executable) +
required("mem") +
......
......@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.extensions.bwa
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
......@@ -26,7 +27,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
* based on executable version 0.7.10-r789
*
*/
class BwaSampe(val root: Configurable) extends Bwa {
class BwaSampe(val root: Configurable) extends Bwa with Reference {
@Input(doc = "Fastq file R1", required = true)
var fastqR1: File = _
......@@ -40,7 +41,7 @@ class BwaSampe(val root: Configurable) extends Bwa {
var saiR2: File = _
@Input(doc = "The reference file for the bam files.", required = true)
var reference: File = config("reference")
var reference: File = null
@Output(doc = "Output file SAM", required = false)
var output: File = _
......@@ -56,6 +57,11 @@ class BwaSampe(val root: Configurable) extends Bwa {
var r: String = _
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
def cmdLine = required(executable) +
required("sampe") +
optional("-a", a) +
......
......@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.extensions.bwa
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
......@@ -26,7 +27,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
* based on executable version 0.7.10-r789
*
*/
class BwaSamse(val root: Configurable) extends Bwa {
class BwaSamse(val root: Configurable) extends Bwa with Reference {
@Input(doc = "Fastq file", required = true)
var fastq: File = _
......@@ -34,7 +35,7 @@ class BwaSamse(val root: Configurable) extends Bwa {
var sai: File = _
@Input(doc = "The reference file for the bam files.", required = true)
var reference: File = config("reference")
var reference: File = null
@Output(doc = "Output file SAM", required = false)
var output: File = _
......@@ -42,6 +43,11 @@ class BwaSamse(val root: Configurable) extends Bwa {
var n: Option[Int] = config("n")
var r: String = _
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
/** Returns command to execute */
def cmdLine = required(executable) +
required("samse") +
......
......@@ -34,7 +34,7 @@ abstract class Gatk extends BiopetJavaCommandLineFunction with Reference {
override val defaultCoreMemory = 3.0
@Input(required = true)
var reference: File = referenceFasta()
var reference: File = null
@Input(required = false)
var gatkKey: Option[File] = config("gatk_key")
......@@ -48,6 +48,11 @@ abstract class Gatk extends BiopetJavaCommandLineFunction with Reference {
@Input(required = false)
var pedigree: List[File] = config("pedigree", default = Nil)
override def beforeGraph: Unit = {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
override def commandLine = super.commandLine +
required("-T", analysisType) +
required("-R", reference) +
......
......@@ -16,12 +16,13 @@
package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard CollectGcBiasMetrics */
class CollectGcBiasMetrics(val root: Configurable) extends Picard with Summarizable {
class CollectGcBiasMetrics(val root: Configurable) extends Picard with Summarizable with Reference {
javaMainClass = new picard.analysis.CollectGcBiasMetrics().getClass.getName
@Input(doc = "The input SAM or BAM files to analyze. Must be coordinate sorted.", required = true)
......@@ -36,8 +37,8 @@ class CollectGcBiasMetrics(val root: Configurable) extends Picard with Summariza
@Output(doc = "Output summary", required = false)
var outputSummary: File = _
@Argument(doc = "Reference file", required = false)
var reference: File = config("reference")
@Input(doc = "Reference file", required = false)
var reference: File = null
@Argument(doc = "Window size", required = false)
var windowSize: Option[Int] = config("windowsize")
......@@ -52,7 +53,9 @@ class CollectGcBiasMetrics(val root: Configurable) extends Picard with Summariza
var isBisulfiteSequinced: Option[Boolean] = config("isbisulfitesequinced")
override def beforeGraph {
super.beforeGraph
if (outputChart == null) outputChart = new File(output + ".pdf")
if (reference == null) reference = referenceFasta()
}
/** Returns command to execute */
......
......@@ -2,6 +2,7 @@ package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Output, Input }
......@@ -9,7 +10,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Argument, Output, Input }
/**
* Created by pjvan_thof on 4/16/15.
*/
class CollectWgsMetrics(val root: Configurable) extends Picard with Summarizable {
class CollectWgsMetrics(val root: Configurable) extends Picard with Summarizable with Reference {
javaMainClass = new picard.analysis.CollectWgsMetrics().getClass.getName
......@@ -20,7 +21,7 @@ class CollectWgsMetrics(val root: Configurable) extends Picard with Summarizable
var output: File = null
@Input(doc = "Reference", required = true)
var reference: File = config("reference")
var reference: File = null
@Argument(doc = "MINIMUM_MAPPING_QUALITY", required = false)
var minMapQ: Option[Int] = config("minimum_mapping_quality")
......@@ -37,6 +38,11 @@ class CollectWgsMetrics(val root: Configurable) extends Picard with Summarizable
@Argument(doc = "INCLUDE_BQ_HISTOGRAM", required = false)
var includeBqHistogram: Boolean = config("include_bq_histogram", default = false)
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......
......@@ -17,11 +17,12 @@ package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
import nl.lumc.sasc.biopet.core.config.Configurable
class ReorderSam(val root: Configurable) extends Picard {
class ReorderSam(val root: Configurable) extends Picard with Reference {
javaMainClass = new picard.sam.ReorderSam().getClass.getName
......@@ -40,6 +41,11 @@ class ReorderSam(val root: Configurable) extends Picard {
@Argument(doc = "Allow contig length discordance", required = false)
var allowContigLengthDiscordance: Boolean = config("allow_contig_length_discordance", default = false)
override def beforeGraph: Unit = {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
override def commandLine = super.commandLine +
conditional(allowIncompleteDictConcordance, "ALLOW_INCOMPLETE_DICT_CONCORDANCE=TRUE") +
conditional(allowContigLengthDiscordance, "ALLOW_CONTIG_LENGTH_DISCORDANCE=TRUE") +
......
......@@ -44,7 +44,10 @@ import nl.lumc.sasc.biopet.tools.{ MergeTables, WipeReads }
*
* @author Wibowo Arindrarto <w.arindrarto@lumc.nl>
*/
class Gentrap(val root: Configurable) extends QScript with MultiSampleQScript with SummaryQScript { qscript =>
class Gentrap(val root: Configurable) extends QScript
with MultiSampleQScript
with SummaryQScript
with Reference { qscript =>
import Gentrap._
import Gentrap.ExpMeasures._
......@@ -312,21 +315,8 @@ class Gentrap(val root: Configurable) extends QScript with MultiSampleQScript wi
job
}
// used to ensure that the required .dict file is present before the run starts
// can not store it in config since the tools that use it (Picard) have this value based on the reference file name
protected def checkDictFile(): Unit = {
val refFile: File = config("reference")
val refName: String = refFile.getName
require(refName.contains('.'), "Reference file must have an extension")
val dictFile = new File(Option(refFile.getParentFile).getOrElse(new File(".")),
refName.take(refName.lastIndexOf('.')) + ".dict")
require(dictFile.exists, s"Dict file '$dictFile' must exist")
}
/** Steps to run before biopetScript */
def init(): Unit = {
checkDictFile()
// TODO: validate that exons are flattened or not (depending on another option flag?)
// validate required annotation files
if (expMeasures.contains(FragmentsPerGene))
......
......@@ -41,7 +41,6 @@ class GentrapTest extends TestNGSuite with Matchers {
override def globalConfig = new Config(map)
// disable dict file check since it is based on the reference file name (which we can't modify here since
// we use the mock /usr/bin/test file
override def checkDictFile: Unit = {}
qSettings = new QSettings
qSettings.runName = "test"
}
......@@ -198,7 +197,6 @@ object GentrapTest {
copyFile("ref.fa.fai")
val executables = Map(
"reference" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"dict" -> "test",
"refFlat" -> "test",
......
......@@ -59,9 +59,6 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
/** Aligner */
protected var aligner: String = config("aligner", default = "bwa")
/** Reference */
protected var reference: File = config("reference")
/** Number of chunks, when not defined pipeline will automatic calculate number of chunks */
protected var numberChunks: Option[Int] = config("number_chunks")
......@@ -344,17 +341,9 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
gsnapCommand.isIntermediate = true
add(gsnapCommand)
val sortSam = new SortSam(this)
sortSam.input = gsnapCommand.output
sortSam.output = swapExt(output.getParent, output, ".bam", ".sorted.bam")
sortSam.sortOrder = "coordinate"
sortSam.isIntermediate = chunking || !skipMarkduplicates
add(sortSam)
val reorderSam = new ReorderSam(this)
reorderSam.input = sortSam.output
reorderSam.input = gsnapCommand.output
reorderSam.output = swapExt(output.getParent, output, ".sorted.bam", ".reordered.bam")
reorderSam.reference = reference
add(reorderSam)
addAddOrReplaceReadGroups(reorderSam.output, output)
......@@ -373,14 +362,7 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
tophat.keep_fasta_order = true
add(tophat)
val sortSam = new SortSam(this)
sortSam.input = tophat.outputAcceptedHits
sortSam.output = swapExt(output.getParentFile, output, ".bam", ".sorted.bam")
sortSam.sortOrder = "coordinate"
sortSam.isIntermediate = chunking || !skipMarkduplicates
add(sortSam)
addAddOrReplaceReadGroups(sortSam.output, output)
addAddOrReplaceReadGroups(tophat.outputAcceptedHits, output)
}
/**
* Adds stampy jobs
......
......@@ -47,7 +47,7 @@ class MappingTest extends TestNGSuite with Matchers {
@DataProvider(name = "mappingOptions")
def mappingOptions = {
val aligners = Array("bwa", "bwa-aln", "star", "star-2pass", "bowtie", "stampy")
val aligners = Array("bwa", "bwa-aln", "star", "star-2pass", "bowtie", "stampy", "gsnap", "tophat")
val paired = Array(true, false)
val chunks = Array(1, 5, 10, 100)
val skipMarkDuplicates = Array(true, false)
......@@ -110,7 +110,7 @@ class MappingTest extends TestNGSuite with Matchers {
// Sort sam or replace readgroup
val sort = aligner match {
case "bwa" | "bwa-aln" | "stampy" => "sortsam"
case "star" | "star-2pass" | "bowtie" => "replacereadgroups"
case "star" | "star-2pass" | "bowtie" | "gsnap" | "tophat" => "replacereadgroups"
case _ => throw new IllegalArgumentException("aligner: " + aligner + " does not exist")
}
......@@ -142,10 +142,13 @@ object MappingTest {
copyFile("ref.fa.fai")
val executables = Map(
"reference" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"db" -> "test",
"bowtie_index" -> "test",
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"gsnap" -> Map("exe" -> "test"),
"tophat" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
"cutadapt" -> Map("exe" -> "test"),
"bwa" -> Map("exe" -> "test"),
......
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