Commit ba0deb1c authored by Sander Bollen's avatar Sander Bollen
Browse files

Merge branch 'fix-BIOPET-483' into 'develop'

Adding bgzipped fasta



See merge request !498
parents 45c2a57d 4a702a03
......@@ -17,21 +17,28 @@ package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/** Wrapper for the bgzip command */
class Bgzip(val root: Configurable) extends BiopetCommandLineFunction {
@Input(doc = "Input files", required = true)
@Input(doc = "Input files", required = false)
var input: List[File] = Nil
@Output(doc = "Compressed output file", required = true)
@Output(doc = "Compressed output file", required = false)
var output: File = null
var f: Boolean = config("f", default = false)
executable = config("exe", default = "bgzip", freeVar = false)
override def beforeGraph(): Unit = {
super.beforeGraph()
if (input.isEmpty && !inputAsStdin) Logging.addError("Input is missing for Bgzip")
if (output == null && !outputAsStsout) Logging.addError("Output is missing for Bgzip")
}
def cmdLine = required(executable) +
conditional(f, "-f") +
" -c " + repeat(input) +
......
......@@ -25,13 +25,14 @@ class SamtoolsFaidx(val root: Configurable) extends Samtools {
var input: File = _
@Output(doc = "output File")
private var _output: File = _
private var _output: List[File] = Nil
def output = _output
override def beforeGraph: Unit = {
super.beforeGraph
_output = new File(input.getParentFile, input.getName + ".fai")
_output = List(new File(input.getAbsolutePath + ".fai"))
if (input.getName.endsWith(".gz")) _output :+= new File(input.getAbsolutePath + ".gzi")
}
/** Returns command to execute */
......@@ -42,7 +43,8 @@ object SamtoolsFaidx {
def apply(root: Configurable, input: File): SamtoolsFaidx = {
val faidx = new SamtoolsFaidx(root)
faidx.input = input
faidx._output = new File(input.getParentFile, input.getName + ".fai")
faidx._output = List(new File(input.getAbsolutePath + ".fai"))
if (input.getName.endsWith(".gz")) faidx._output :+= new File(input.getAbsolutePath + ".gzi")
faidx
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ package nl.lumc.sasc.biopet.pipelines.generateindexes
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import nl.lumc.sasc.biopet.extensions.bowtie.{ Bowtie2Build, BowtieBuild }
import nl.lumc.sasc.biopet.extensions.{ Ln, Star }
import nl.lumc.sasc.biopet.extensions.{ Bgzip, Ln, Star }
import nl.lumc.sasc.biopet.extensions.bwa.BwaIndex
import nl.lumc.sasc.biopet.extensions.gmap.GmapBuild
import nl.lumc.sasc.biopet.extensions.hisat.Hisat2Build
......@@ -44,9 +44,13 @@ class GenerateIndexes(val root: Configurable) extends QScript with BiopetQScript
var outputConfig: Map[String, Any] = Map("reference_fasta" -> fastaFile)
val configDeps = new ListBuffer[File]()
val bgzipFasta = new File(fastaFile.getAbsolutePath + ".gz")
add(fastaFile :<: new Bgzip(this) > bgzipFasta)
add(SamtoolsFaidx(this, bgzipFasta))
val faidx = SamtoolsFaidx(this, fastaFile)
add(faidx)
configDeps += faidx.output
faidx.output.foreach(configDeps += _)
val createDict = new CreateSequenceDictionary(this)
createDict.reference = fastaFile
......@@ -59,10 +63,10 @@ class GenerateIndexes(val root: Configurable) extends QScript with BiopetQScript
def createLinks(dir: File): File = {
val newFastaFile = new File(dir, fastaFile.getName)
val newFai = new File(dir, faidx.output.getName)
val newFai = new File(dir, faidx.output.head.getName)
val newDict = new File(dir, createDict.output.getName)
add(Ln(this, faidx.output, newFai))
add(Ln(this, faidx.output.head, newFai))
add(Ln(this, createDict.output, newDict))
val lnFasta = Ln(this, fastaFile, newFastaFile)
lnFasta.deps ++= List(newFai, newDict)
......
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