Commit 6c3cd444 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Add bowtie2 to Mapping (and add wrapper for bowtie2)

parent abb2a281
package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.{BiopetCommandLineFunction, Reference, Version}
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
/**
* Extension for bowtie 2
*
* Based on version 2.2.6
*/
class Bowtie2(val root: Configurable) extends BiopetCommandLineFunction with Reference with Version {
@Input(doc = "Fastq file R1", shortName = "R1")
var R1: File = null
@Input(doc = "Fastq file R2", shortName = "R2", required = false)
var R2: Option[File] = None
@Output(doc = "Output file SAM", shortName = "output", required = true)
var output: File = null
executable = config("exe", default = "bowtie2", freeVar = false)
def versionRegex = """.*[Vv]ersion:? (.*)""".r
override def versionExitcode = List(0, 1)
def versionCommand = executable + " --version"
override def defaultCoreMemory = 4.0
override def defaultThreads = 4
/* Required */
var bowtieIndex: String = config("bowtie_index")
/* Input options */
var q: Boolean = config("q", default=true)
var qseq: Boolean = config("qseq", default=false)
var f: Boolean = config("f", default=false)
var r: Boolean = config("r", default=false)
var c: Boolean = config("c", default=false)
var skip: Option[Int] = config("skip")
var upto: Option[Int] = config("upto")
var trim5: Option[Int] = config("trim5")
var trim3: Option[Int] = config("trim3")
var phred33: Boolean = config("phred33")
var phred64: Boolean = config("phred64")
var int_quals: Boolean = config("int_quals")
/* Alignment options */
var N: Option[Int] = config("N")
var L: Option[Int] = config("L")
var i: Option[String] = config("i")
var n_ceil: Option[String] = config("n_ceil")
var dpad: Option[Int] = config("dpad")
var gbar: Option[Int] = config("gbar")
var ignore_quals: Boolean = config("ignore_quals")
var nofw: Boolean = config("nofw")
var norc: Boolean = config("norc")
var no_1mm_upfront: Boolean = config("no_1mm_upfront")
var end_to_end: Boolean = config("end_to_end")
var local: Boolean = config("local")
/* Scoring */
var ma: Option[Int] = config("ma")
var mp: Option[Int] = config("mp")
var np: Option[Int] = config("np")
var rdg: Option[String] = config("rdg")
var rfg: Option[String] = config("rfg")
var score_min: Option[String] = config("score_min")
/* Reporting */
var k: Option[Int] = config("k")
var all: Option[Int] = config("all")
/* Effort */
var D: Option[Int] = config("D")
var R: Option[Int] = config("R")
/* Paired-end */
var minins: Option[Int] = config("minins")
var maxins: Option[Int] = config("maxins")
var fr: Boolean = config("fr")
var rf: Boolean = config("rf")
var ff: Boolean = config("ff")
var no_mixed: Boolean = config("no_mixed")
var no_discordant: Boolean = config("no_discordant")
var no_dovetail: Boolean = config("no_dovetail")
var no_contain: Boolean = config("no_contain")
var no_overlap: Boolean = config("no_overlap")
/* Output */
var time: Boolean = config("no_overlap")
var un: Option[String] = config("un")
var al: Option[String] = config("al")
var un_conc: Option[String] = config("un_conc")
var al_conc: Option[String] = config("al_conc")
var un_gz: Option[String] = config("un_gz")
var al_gz: Option[String] = config("al_gz")
var un_conc_gz: Option[String] = config("un_conc_gz")
var al_conc_gz: Option[String] = config("al_conc_gz")
var un_bz2: Option[String] = config("un_bz2")
var al_bz2: Option[String] = config("al_bz2")
var un_conc_bz2: Option[String] = config("un_conc_bz2")
var al_conc_bz2: Option[String] = config("al_conc_bz2")
var quiet: Boolean = config("quiet")
var met_file: Option[String] = config("met_file")
var met_stderr: Boolean = config("met_stderr")
var met: Option[Int] = config("met")
var no_unal: Boolean = config("no_unal")
var no_head: Boolean = config("no_head")
var no_sq: Boolean = config("no_sq")
var rg_id: Option[String] = config("rg_id")
var rg: Option[String] = config("rg")
var omit_sec_seq: Boolean = config("omit_sec_seq")
/* Performance */
var reorder: Boolean = config("reorder")
var mm: Boolean = config("mm")
/* Other */
var qc_filter: Boolean = config("qc_filter")
var seed: Option[Int] = config("seed")
var non_deterministic: Boolean = config("non_deterministic")
/** return commandline to execute */
def cmdLine = required(executable) +
conditional(q, "-q") +
conditional(qseq, "--qseq") +
conditional(f, "-f") +
conditional(r, "-r") +
conditional(c, "-c") +
optional("--skip", skip) +
optional("--upto", upto) +
optional("--trim3", trim3) +
optional("--trim5", trim5) +
conditional(phred33, "--phred33") +
conditional(phred64, "--phred64") +
conditional(int_quals, "--int-quals") +
/* Alignment options */
optional("-N", N) +
optional("-L", L) +
optional("-i", i) +
optional("--n-ceil", n_ceil) +
optional("--dpad", dpad) +
optional("--gbar", gbar) +
optional("--ignore-quals", ignore_quals) +
conditional(nofw, "--nofw") +
conditional(norc, "--norc") +
conditional(no_1mm_upfront, "--no-1mm-upfront") +
conditional(end_to_end, "--end-to-end") +
conditional(local, "--local") +
/* Scoring */
optional("--ma", ma) +
optional("--mp", mp) +
optional("--np", np) +
optional("--rdg", rdg) +
optional("--rfg", rfg) +
optional("--score-min", score_min) +
/* Reporting */
optional("-k", k) +
optional("--all", all) +
/* Effort */
optional("-D", D) +
optional("-R", R) +
/* Paired End */
optional("-minins", minins) +
optional("-maxins", maxins) +
conditional(fr, "--fr") +
conditional(rf, "--rf") +
conditional(ff, "--ff") +
conditional(no_mixed, "--no-mixed") +
conditional(no_discordant, "--no-discordant") +
conditional(no_dovetail, "--no-dovetail") +
conditional(no_contain, "--no-contain") +
conditional(no_overlap, "--no-overlap") +
/* Output */
conditional(time, "--time") +
optional("--un", un) +
optional("--al", al) +
optional("--un-conc", un_conc) +
optional("--al-conc", al_conc) +
optional("--un-gz", un_gz) +
optional("--al-gz", al_gz) +
optional("--un-conc-gz", un_conc_gz) +
optional("--al-conc-gz", al_conc_gz) +
optional("--un-bz2", un_bz2) +
optional("--al-bz2", al_bz2) +
optional("--un-conc-bz2", un_conc_bz2) +
optional("--al-conc-bz2", al_conc_bz2) +
conditional(quiet, "--quiet") +
optional("--met-file", met_file) +
conditional(met_stderr, "--met-stderr") +
optional("--met", met) +
conditional(no_unal, "--no-unal") +
conditional(no_head, "--no-head") +
conditional(no_sq, "--no-sq") +
optional("--rg-id", rg_id) +
optional("--rg", rg) +
conditional(omit_sec_seq, "--omit-sec-seq") +
/* Performance */
optional("--threads", threads) +
optional("--reorder", reorder) +
optional("--mm", mm) +
/* Other */
conditional(qc_filter, "--qc-filter") +
optional("--seed", seed) +
conditional(non_deterministic, "--non-deterministic") +
/* Required */
required("-x", bowtieIndex) +
(R2 match {
case Some(r2) =>
required("-1", R1) +
optional("-2", r2)
case _ => required("-U", R1)
}) +
(if (outputAsStsout) "" else required("-S", output))
}
...@@ -23,7 +23,7 @@ import nl.lumc.sasc.biopet.core.summary.SummaryQScript ...@@ -23,7 +23,7 @@ import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.bwa.{ BwaAln, BwaMem, BwaSampe, BwaSamse } import nl.lumc.sasc.biopet.extensions.bwa.{ BwaAln, BwaMem, BwaSampe, BwaSamse }
import nl.lumc.sasc.biopet.extensions.picard.{ AddOrReplaceReadGroups, MarkDuplicates, MergeSamFiles, ReorderSam, SortSam } import nl.lumc.sasc.biopet.extensions.picard.{ AddOrReplaceReadGroups, MarkDuplicates, MergeSamFiles, ReorderSam, SortSam }
import nl.lumc.sasc.biopet.extensions.tools.FastqSplitter import nl.lumc.sasc.biopet.extensions.tools.FastqSplitter
import nl.lumc.sasc.biopet.extensions.{ Gsnap, Tophat, _ } import nl.lumc.sasc.biopet.extensions._
import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics
import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig
import nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep import nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep
...@@ -219,6 +219,7 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S ...@@ -219,6 +219,7 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
case "bwa-mem" => addBwaMem(R1, R2, outputBam) case "bwa-mem" => addBwaMem(R1, R2, outputBam)
case "bwa-aln" => addBwaAln(R1, R2, outputBam) case "bwa-aln" => addBwaAln(R1, R2, outputBam)
case "bowtie" => addBowtie(R1, R2, outputBam) case "bowtie" => addBowtie(R1, R2, outputBam)
case "bowtie2" => addBowtie2(R1, R2, outputBam)
case "gsnap" => addGsnap(R1, R2, outputBam) case "gsnap" => addGsnap(R1, R2, outputBam)
// TODO: make TopHat here accept multiple input files // TODO: make TopHat here accept multiple input files
case "tophat" => addTophat(R1, R2, outputBam) case "tophat" => addTophat(R1, R2, outputBam)
...@@ -437,6 +438,20 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S ...@@ -437,6 +438,20 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
ar._2 ar._2
} }
/** Add bowtie2 jobs **/
def addBowtie2(R1: File, R2: Option[File], output: File): File = {
val bowtie2 = new Bowtie2(this)
bowtie2.R1 = R1
if (paired) bowtie2.R2 = Some(R2.get)
val sortSam = new SortSam(this)
sortSam.output = output
val pipe = bowtie2 | sortSam
pipe.isIntermediate = chunking || !skipMarkduplicates
pipe.threadsCorrection = -1
add(pipe)
output
}
/** Adds Star jobs */ /** Adds Star jobs */
def addStar(R1: File, R2: Option[File], output: File): File = { def addStar(R1: File, R2: Option[File], output: File): File = {
val zcatR1 = extractIfNeeded(R1, output.getParentFile) val zcatR1 = extractIfNeeded(R1, output.getParentFile)
......
...@@ -98,6 +98,7 @@ class MappingBwaAlnTest extends AbstractTestMapping("bwa-aln") ...@@ -98,6 +98,7 @@ class MappingBwaAlnTest extends AbstractTestMapping("bwa-aln")
class MappingStarTest extends AbstractTestMapping("star") class MappingStarTest extends AbstractTestMapping("star")
class MappingStar2PassTest extends AbstractTestMapping("star-2pass") class MappingStar2PassTest extends AbstractTestMapping("star-2pass")
class MappingBowtieTest extends AbstractTestMapping("bowtie") class MappingBowtieTest extends AbstractTestMapping("bowtie")
class MappingBowtie2Test extends AbstractTestMapping("bowtie2")
class MappingStampyTest extends AbstractTestMapping("stampy") class MappingStampyTest extends AbstractTestMapping("stampy")
class MappingGsnapTest extends AbstractTestMapping("gsnap") class MappingGsnapTest extends AbstractTestMapping("gsnap")
class MappingTophatTest extends AbstractTestMapping("tophat") class MappingTophatTest extends AbstractTestMapping("tophat")
...@@ -142,6 +143,7 @@ object MappingTest { ...@@ -142,6 +143,7 @@ object MappingTest {
"bwa" -> Map("exe" -> "test"), "bwa" -> Map("exe" -> "test"),
"star" -> Map("exe" -> "test"), "star" -> Map("exe" -> "test"),
"bowtie" -> Map("exe" -> "test"), "bowtie" -> Map("exe" -> "test"),
"bowtie2" -> Map("exe" -> "test"),
"stampy" -> Map("exe" -> "test", "genome" -> "test", "hash" -> "test"), "stampy" -> Map("exe" -> "test", "genome" -> "test", "hash" -> "test"),
"samtools" -> Map("exe" -> "test"), "samtools" -> Map("exe" -> "test"),
"md5sum" -> Map("exe" -> "test") "md5sum" -> Map("exe" -> "test")
......
Supports Markdown
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