Commit 8d604404 authored by Peter van 't Hof's avatar Peter van 't Hof

fai and dict check are not optional

parent 87248d7c
......@@ -37,10 +37,14 @@ trait Reference extends Configurable {
List("references", referenceSpecies, referenceName)
}
protected def faiRequired = false
protected def dictRequired = false
/** Returns the fasta file */
def referenceFasta(): File = {
val file: File = config("reference_fasta")
Reference.checkFasta(file)
checkFasta(file)
val dict = new File(file.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
val fai = new File(file.getAbsolutePath + ".fai")
......@@ -65,29 +69,32 @@ trait Reference extends Configurable {
"name" -> referenceName
)
}
}
object Reference {
/** Used as cache to avoid double checking */
private var checked: Set[File] = Set()
//TODO: this become obsolete when index get autogenerated
/** Check fasta file if file exist and index file are there */
def checkFasta(file: File): Unit = {
if (!checked.contains(file)) {
if (!Reference.checked.contains(file)) {
require(file.exists(), "Reference not found: " + file)
val dict = new File(file.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
require(dict.exists(), "Reference is missing a dict file")
val fai = new File(file.getAbsolutePath + ".fai")
require(fai.exists(), "Reference is missing a fai file")
if (dictRequired) {
val dict = new File(file.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
require(dict.exists(), "Reference is missing a dict file")
}
require(IndexedFastaSequenceFile.canCreateIndexedFastaReader(file), "Index of reference cannot be loaded, reference: " + 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)
}
checked += file
Reference.checked += file
}
}
}
object Reference {
/** Used as cache to avoid double checking */
private var checked: Set[File] = Set()
}
......@@ -48,6 +48,8 @@ abstract class Gatk extends BiopetJavaCommandLineFunction with Reference {
@Input(required = false)
var pedigree: List[File] = config("pedigree", default = Nil)
override def dictRequired = true
override def beforeGraph: Unit = {
super.beforeGraph
if (reference == null) reference = referenceFasta()
......
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