Commit 29a61dfe authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Merge branch 'fix-reference_dict_check' into 'develop'

Extract checkDict and checkFai in a public method

Fix for #173

Still needs testing.

See merge request !190
parents 30ddf578 b605f886
......@@ -15,15 +15,16 @@ trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction wit
jarFile = config("gatk_jar")
override val defaultCoreMemory = 4.0
override def defaultCoreMemory = 4.0
override def faiRequired = true
if (config.contains("intervals")) intervals = config("intervals").asFileList
if (config.contains("exclude_intervals")) excludeIntervals = config("exclude_intervals").asFileList
if (config.contains("gatk_key")) gatk_key = config("gatk_key")
if (config.contains("pedigree")) pedigree = config("pedigree")
override val versionRegex = """(.*)""".r
override val versionExitcode = List(0, 1)
override def versionRegex = """(.*)""".r
override def versionExitcode = List(0, 1)
override def versionCommand = executable + " -jar " + jarFile + " -version"
override def getVersion = super.getVersion.collect { case version => "Gatk " + version }
......
......@@ -33,11 +33,11 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
var deps: List[File] = Nil
var threads = 0
val defaultThreads = 1
def defaultThreads = 1
var vmem: Option[String] = config("vmem")
protected val defaultCoreMemory: Double = 1.0
protected val defaultVmemFactor: Double = 1.4
protected def defaultCoreMemory: Double = 1.0
protected def defaultVmemFactor: Double = 1.4
var vmemFactor: Double = config("vmem_factor", default = defaultVmemFactor)
var residentFactor: Double = config("resident_factor", default = 1.2)
......@@ -151,10 +151,10 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
protected def versionCommand: String = null
/** Regex to get version from version command output */
protected val versionRegex: Regex = null
protected def versionRegex: Regex = null
/** Allowed exit codes for the version command */
protected val versionExitcode = List(0)
protected def versionExitcode = List(0)
/** Executes the version command */
private[core] def getVersionInternal(): Option[String] = {
......
......@@ -25,7 +25,7 @@ trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetC
javaGCHeapFreeLimit = config("java_gc_heap_freelimit")
javaGCTimeLimit = config("java_gc_timelimit")
override protected val defaultVmemFactor: Double = 2.0
override protected def defaultVmemFactor: Double = 2.0
/** Constructs java opts, this adds scala threads */
override def javaOpts = super.javaOpts +
......
......@@ -59,6 +59,7 @@ trait Reference extends Configurable {
/** Create summary part for reference */
def referenceSummary: Map[String, Any] = {
Reference.requireDict(referenceFasta())
val file = new IndexedFastaSequenceFile(referenceFasta())
Map("contigs" ->
(for (seq <- file.getSequenceDictionary.getSequences) yield seq.getSequenceName -> {
......@@ -77,16 +78,8 @@ trait Reference extends Configurable {
if (!Reference.checked.contains(file)) {
require(file.exists(), "Reference not found: " + file)
if (dictRequired) {
val dict = new File(file.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
require(dict.exists(), "Reference is missing a dict file")
}
if (faiRequired) {
val fai = new File(file.getAbsolutePath + ".fai")
require(fai.exists(), "Reference is missing a fai file")
require(IndexedFastaSequenceFile.canCreateIndexedFastaReader(file), "Index of reference cannot be loaded, reference: " + file)
}
if (dictRequired) Reference.requireDict(file)
if (faiRequired) Reference.requireFai(file)
Reference.checked += file
}
......@@ -97,4 +90,26 @@ object Reference {
/** Used as cache to avoid double checking */
private var checked: Set[File] = Set()
/**
* Raise an exception when given fasta file has no fai file
* @param fastaFile Fasta file
* @throws IllegalArgumentException
*/
def requireFai(fastaFile: File): Unit = {
val fai = new File(fastaFile.getAbsolutePath + ".fai")
require(fai.exists(), "Reference is missing a fai file")
require(IndexedFastaSequenceFile.canCreateIndexedFastaReader(fastaFile),
"Index of reference cannot be loaded, reference: " + fastaFile)
}
/**
* Raise an exception when given fasta file has no dict file
* @param fastaFile Fasta file
* @throws IllegalArgumentException
*/
def requireDict(fastaFile: File): Unit = {
val dict = new File(fastaFile.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
require(dict.exists(), "Reference is missing a dict file")
}
}
......@@ -26,7 +26,7 @@ trait ReportBuilderExtension extends ToolCommandFuntion {
/** Arguments that are passed on the commandline */
var args: Map[String, String] = Map()
override val defaultCoreMemory = 3.0
override def defaultCoreMemory = 3.0
override def beforeGraph: Unit = {
super.beforeGraph
......
......@@ -40,12 +40,12 @@ class Bowtie(val root: Configurable) extends BiopetCommandLineFunction with Refe
var output: File = null
executable = config("exe", default = "bowtie", freeVar = false)
override val versionRegex = """.*[Vv]ersion:? (.*)""".r
override val versionExitcode = List(0, 1)
override def versionRegex = """.*[Vv]ersion:? (.*)""".r
override def versionExitcode = List(0, 1)
override def versionCommand = executable + " --version"
override val defaultCoreMemory = 4.0
override val defaultThreads = 8
override def defaultCoreMemory = 4.0
override def defaultThreads = 8
var sam: Boolean = config("sam", default = true)
var sam_RG: Option[String] = config("sam-RG")
......
......@@ -30,10 +30,10 @@ class Cufflinks(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", default = "cufflinks")
/** default threads */
override val defaultThreads = 8
override def defaultThreads = 8
/** default vmem for cluster jobs */
override val defaultCoreMemory = 6.0
override def defaultCoreMemory = 6.0
/** input file */
@Input(doc = "Input file (SAM or BAM)", required = true)
......@@ -184,9 +184,9 @@ class Cufflinks(val root: Configurable) extends BiopetCommandLineFunction {
/** do not contact server to check for update availability [FALSE] */
var no_update_check: Boolean = config("no_update_check", default = false)
override val versionRegex = """cufflinks v(.*)""".r
override def versionRegex = """cufflinks v(.*)""".r
override def versionCommand = executable
override val versionExitcode = List(0, 1)
override def versionExitcode = List(0, 1)
def cmdLine =
required(executable) +
......
......@@ -117,9 +117,9 @@ class Cuffquant(val root: Configurable) extends BiopetCommandLineFunction {
/** Disable SCV correction */
var no_scv_correction: Boolean = config("no_scv_correction", default = false)
override val versionRegex = """cuffquant v(.*)""".r
override def versionRegex = """cuffquant v(.*)""".r
override def versionCommand = executable
override val versionExitcode = List(0, 1)
override def versionExitcode = List(0, 1)
def cmdLine =
required(executable) +
......
......@@ -40,7 +40,7 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
executable = config("exe", default = "cutadapt")
override def versionCommand = executable + " --version"
override val versionRegex = """(.*)""".r
override def versionRegex = """(.*)""".r
var default_clip_mode: String = config("default_clip_mode", default = "3")
var opt_adapter: Set[String] = config("adapter", default = Nil)
......
......@@ -48,9 +48,9 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction {
var nogroup: Boolean = config("nogroup", default = false)
var extract: Boolean = config("extract", default = true)
override val versionRegex = """FastQC (.*)""".r
override def versionRegex = """FastQC (.*)""".r
override def versionCommand = executable + " --version"
override val defaultThreads = 4
override def defaultThreads = 4
/** Sets contaminants and adapters when not yet set */
override def beforeGraph {
......
......@@ -39,7 +39,7 @@ class Freebayes(val root: Configurable) extends BiopetCommandLineFunction with R
var haplotypeLength: Option[Int] = config("haplotype_length")
executable = config("exe", default = "freebayes")
override val versionRegex = """version: (.*)""".r
override def versionRegex = """version: (.*)""".r
override def versionCommand = executable + " --version"
override def beforeGraph: Unit = {
......
......@@ -32,10 +32,10 @@ class Gsnap(val root: Configurable) extends BiopetCommandLineFunction with Refer
executable = config("exe", default = "gsnap", freeVar = false)
/** default threads */
override val defaultThreads = 8
override def defaultThreads = 8
/** default vmem for cluster jobs */
override val defaultCoreMemory = 10.0
override def defaultCoreMemory = 10.0
/** input file */
@Input(doc = "Input FASTQ file(s)", required = true) //var input: List[File] = _
......@@ -329,7 +329,7 @@ class Gsnap(val root: Configurable) extends BiopetCommandLineFunction with Refer
/** value to put into read-group library (rg-pl) field */
var read_group_platform: Option[String] = config("read_group_platform")
override val versionRegex = """.* version (.*)""".r
override def versionRegex = """.* version (.*)""".r
override def versionCommand = executable + " --version"
def cmdLine = {
......
......@@ -29,7 +29,7 @@ class Gzip(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", default = "gzip")
override val versionRegex = """gzip (.*)""".r
override def versionRegex = """gzip (.*)""".r
override def versionCommand = executable + " --version"
def cmdLine = required(executable) + " -c " + repeat(input) + " > " + required(output)
......
......@@ -69,7 +69,7 @@ class HtseqCount(val root: Configurable) extends BiopetCommandLineFunction {
/** suppress progress report */
var quiet: Boolean = config("quiet", default = false)
override val versionRegex = """.*, version (.*)\.""".r
override def versionRegex = """.*, version (.*)\.""".r
override def versionCommand = executable + " --help"
def cmdLine = {
......
......@@ -33,7 +33,7 @@ class Md5sum(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", default = "md5sum")
override val versionRegex = """md5sum \(GNU coreutils\) (.*)""".r
override def versionRegex = """md5sum \(GNU coreutils\) (.*)""".r
override def versionCommand = executable + " --version"
/** return commandline to execute */
......
......@@ -33,8 +33,8 @@ class Pbzip2(val root: Configurable) extends BiopetCommandLineFunction {
var decomrpess = true
var memory: Option[Int] = config("memory")
override val defaultCoreMemory = memory.getOrElse(1000).toDouble / 1000
override val defaultThreads = 2
override def defaultCoreMemory = memory.getOrElse(1000).toDouble / 1000
override def defaultThreads = 2
override def beforeCmd {
if (!memory.isEmpty) memory = Option(memory.get * threads)
......
......@@ -27,9 +27,9 @@ import scalaz.std.boolean.option
*/
class Raxml(val root: Configurable) extends BiopetCommandLineFunction {
override val defaultThreads = 1
override def defaultThreads = 1
override def versionCommand = executable + " -v"
override val versionRegex = """.*version ([\w\.]*) .*""".r
override def versionRegex = """.*version ([\w\.]*) .*""".r
@Input(doc = "Input phy/fasta file", required = true)
var input: File = _
......
......@@ -58,7 +58,7 @@ class Sickle(val root: Configurable) extends BiopetCommandLineFunction with Summ
var discardN: Boolean = config("discardN", default = false)
var quiet: Boolean = config("quiet", default = false)
var defaultQualityType: String = config("defaultqualitytype", default = "sanger")
override val versionRegex = """sickle version (.*)""".r
override def versionRegex = """sickle version (.*)""".r
override def versionCommand = executable + " --version"
/** Sets qualityType is still empty */
......
......@@ -60,12 +60,12 @@ class Stampy(val root: Configurable) extends BiopetCommandLineFunction with Refe
var logfile: Option[String] = config("logfile")
executable = config("exe", default = "stampy.py", freeVar = false)
override val versionRegex = """stampy v(.*) \(.*\), .*""".r
override val versionExitcode = List(0, 1)
override def versionRegex = """stampy v(.*) \(.*\), .*""".r
override def versionExitcode = List(0, 1)
/// Stampy uses approx factor 1.1 times the size of the genome in memory.
override val defaultCoreMemory = 4.0
override val defaultThreads = 8
override def defaultCoreMemory = 4.0
override def defaultThreads = 8
override def versionCommand = executable + " --help"
......
......@@ -63,8 +63,8 @@ class Star(val root: Configurable) extends BiopetCommandLineFunction with Refere
var outFileNamePrefix: String = _
var runThreadN: Option[Int] = config("runThreadN")
override val defaultCoreMemory = 4.0
override val defaultThreads = 8
override def defaultCoreMemory = 4.0
override def defaultThreads = 8
/** Sets output files for the graph */
override def beforeGraph() {
......
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