Commit fb266355 authored by Wai Yi Leung's avatar Wai Yi Leung

Commit changes before removing branch

parent 18f4992e
package nl.lumc.sasc.biopet.extensions.sambamba
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import java.io.File
class SambambaMarkdup(val root: Configurable) extends Sambamba {
override val defaultThreads = 4
@Input(doc = "Bam File")
var input: File = _
@Output(doc = "Markdup output bam")
var output: File = _
var remove_duplicates: Boolean = config("remove_duplicates", default = false)
// @doc: compression_level 6 is average, 0 = no compression, 9 = best
val compression_level: Option[Int] = config("compression_level", default=6)
val hash_table_size: Option[Int] = config("hash-table-size", default=262144)
val overflow_list_size: Option[Int] = config("overflow-list-size", default=200000)
val io_buffer_size: Option[Int] = config("io-buffer-size", default=128)
def cmdLine = required(executable) +
required("markdup") +
conditional(remove_duplicates, "--remove-duplicates") +
optional("-t", nCoresRequest) +
optional("-l", compression_level) +
optional("--hash-table-size=", hash_table_size, spaceSeparated=false ) +
optional("--overflow-list-size=", overflow_list_size, spaceSeparated=false ) +
optional("--io-buffer-size=", io_buffer_size, spaceSeparated=false ) +
required(input) +
required(output)
}
object SambambaMarkdup {
def apply(root: Configurable, input: File, output: File): SambambaMarkdup = {
val flagstat = new SambambaMarkdup(root)
flagstat.input = input
flagstat.output = output
return flagstat
}
def apply(root: Configurable, input: File, outputDir: String): SambambaMarkdup = {
val dir = if (outputDir.endsWith("/")) outputDir else outputDir + "/"
val outputFile = new File(dir + swapExtension(input.getName))
return apply(root, input, outputFile)
}
def apply(root: Configurable, input: File): SambambaMarkdup = {
return apply(root, input, new File(swapExtension(input.getAbsolutePath)))
}
private def swapExtension(inputFile: String) = inputFile.stripSuffix(".bam") + ".bam.bai"
}
\ No newline at end of file
......@@ -11,33 +11,34 @@ import java.io.File
class BreakdancerConfig(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", default = "bam2cfg.pl", freeVar = false)
@Input(doc = "Bam File")
var input: File = _
@Output(doc = "Output File")
var output: File = _
var MIN_MQ: Option[Int] = config("min_mq", default = 20) // minimum of MQ to consider for taking read into histogram
var USE_MQ: Boolean = config("use_mq", default = false)
var MIN_INSERTSIZE: Option[Int] = config("min_insertsize", default = 450)
var SOLID_DATA: Boolean = config("solid", default = false)
var SD_CUTOFF: Option[Int] = config("sd_cutoff", default = 4) // Cutoff in unit of standard deviation [4]
var min_mq: Option[Int] = config("min_mq", default = 20) // minimum of MQ to consider for taking read into histogram
var use_mq: Boolean = config("use_mq", default = false)
var min_insertsize: Option[Int] = config("min_insertsize", default = 450)
var solid_data: Boolean = config("solid", default = false)
var sd_cutoff: Option[Int] = config("sd_cutoff", default = 4) // Cutoff in unit of standard deviation [4]
// we set this to a higher number to avoid biases in small numbers in sorted bams
var MIN_OBSERVATIONS: Option[Int] = config("min_observations", default = 1000000) // Number of observation required to estimate mean and s.d. insert size [10_000]
var COEFVAR_CUTOFF: Option[Int] = config("coef_cutoff", default = 1) // Cutoff on coefficients of variation [1]
var HISTOGRAM_BINS: Option[Int] = config("histogram_bins", default = 50) // Number of bins in the histogram [50]
var min_observations: Option[Int] = config("min_observations", default = 10000) // Number of observation required to estimate mean and s.d. insert size [10_000]
var coefvar_cutoff: Option[Int] = config("coef_cutoff", default = 1) // Cutoff on coefficients of variation [1]
var histogram_bins: Option[Int] = config("histogram_bins", default = 50) // Number of bins in the histogram [50]
def cmdLine = required(executable) +
optional("-q", MIN_MQ) +
conditional(USE_MQ, "-m") +
optional("-s", MIN_INSERTSIZE) +
conditional(SOLID_DATA, "-s") +
optional("-c", SD_CUTOFF) +
optional("-n", MIN_OBSERVATIONS) +
optional("-v", COEFVAR_CUTOFF) +
optional("-b", HISTOGRAM_BINS)
required(input) + " > " + required(output)
optional("-q", min_mq) +
conditional(use_mq, "-m") +
optional("-s", min_insertsize) +
conditional(solid_data, "-s") +
optional("-c", sd_cutoff) +
optional("-n", min_observations) +
optional("-v", coefvar_cutoff) +
optional("-b", histogram_bins) +
required(input) + " 1> " + required(output)
}
object BreakdancerConfig {
......@@ -74,18 +75,18 @@ class BreakdancerCaller(val root: Configurable) extends BiopetCommandLineFunctio
executable = config("exe", default = "breakdancer-max", freeVar = false)
override val defaultVmem = "4G"
override val defaultThreads = 8
override val defaultThreads = 1 // breakdancer can only work on 1 single thread
override val versionRegex = """.*[Vv]ersion:? (.*)""".r
// override val versionExitcode = List(0, 1)
override val versionExitcode = List(1)
override def versionCommand = executable
@Input(doc = "The breakdancer configuration file")
var input: File = _
@Argument(doc = "Work directory")
var workdir: String = _
// @Argument(doc = "Work directory")
// var workdir: String = _
@Output(doc = "Breakdancer VCF output")
var output: File = _
......@@ -125,8 +126,6 @@ class BreakdancerCaller(val root: Configurable) extends BiopetCommandLineFunctio
var y: Option[Int] = config("y", default = 30)
override def beforeCmd {
if (workdir == null) throw new Exception("Breakdancer :: Workdirectory is not defined")
// if (input.getName.endsWith(".sort.bam")) sorted = true
}
def cmdLine = required(executable) +
......@@ -176,6 +175,10 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript {
// new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.vcf")
// }
@Output(doc = "Breakdancer config")
lazy val configfile: File = {
new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.cfg")
}
@Output(doc = "Breakdancer raw output")
lazy val outputraw: File = {
new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.tsv")
......@@ -188,7 +191,7 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript {
// read config and set all parameters for the pipeline
logger.info("Starting Breakdancer configuration")
val bdcfg = BreakdancerConfig(this, input, workdir)
val bdcfg = BreakdancerConfig(this, input, this.configfile)
outputFiles += ("breakdancer_cfg" -> bdcfg.output )
add( bdcfg )
......@@ -202,8 +205,6 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript {
}
// private def swapExtension(inputFile: String) = inputFile.substring(0, inputFile.lastIndexOf(".bam")) + ".breakdancer.tsv"
}
object Breakdancer extends PipelineCommand {
......
......@@ -20,6 +20,7 @@ class Clever(val root: Configurable) extends BiopetCommandLineFunction {
override def versionCommand = versionexecutable.getAbsolutePath
override val versionRegex = """(.*)""".r
override val versionExitcode = List(0, 1)
@Input(doc = "Input file (bam)")
var input: File = _
......@@ -92,7 +93,6 @@ class CleverPipeline(val root: Configurable) extends QScript with BiopetQScript
@Argument(doc = "Work directory")
var workdir: String = _
@Argument(doc = "Current working directory")
var cwd: String = _
......@@ -117,6 +117,8 @@ object CleverPipeline extends PipelineCommand {
val cleverpipeline = new CleverPipeline( root )
cleverpipeline.input = input
cleverpipeline.workdir = runDir
cleverpipeline.init
cleverpipeline.biopetScript
return cleverpipeline
}
......
......@@ -76,9 +76,6 @@ class Yamsvp(val root: Configurable) extends QScript with MultiSampleQScript {
// this is extending the libraryBamfiles list like '~=' in D or .append in Python or .push_back in C++
libraryBamfiles ++= List(libraryOutput.mappedBamFile)
}
logger.debug( "We have the following bamfiles for merging" )
logger.debug( libraryBamfiles )
val bamFile: File =
if (libraryBamfiles.size == 1) libraryBamfiles.head
......@@ -93,8 +90,6 @@ class Yamsvp(val root: Configurable) extends QScript with MultiSampleQScript {
mergeSamFiles.output
} else null
logger.debug( bamFile )
/// bamfile will be used as input for the SV callers. First run Clever
// val cleverVCF : File = sampleDir + "/" + sampleID + ".clever.vcf"
......@@ -108,8 +103,8 @@ class Yamsvp(val root: Configurable) extends QScript with MultiSampleQScript {
val breakdancer = Breakdancer(this, bamFile, this.reference, breakdancerDir)
sampleOutput.vcf += ("breakdancer" -> List(breakdancer.outputraw))
addAll(breakdancer.functions)
//
//
// for pindel we should use per library config collected into one config file
// val pindelDir = svcallingDir + sampleID + ".pindel/"
// val pindel = Pindel(this, bamFile, this.reference, pindelDir)
// sampleOutput.vcf += ("pindel" -> List(pindel.outputvcf))
......@@ -123,14 +118,13 @@ class Yamsvp(val root: Configurable) extends QScript with MultiSampleQScript {
def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): LibraryOutput = {
val libraryOutput = new LibraryOutput
var outputFiles: Map[String, File] = Map()
val runID: String = runConfig("ID").toString
val sampleID: String = sampleConfig("ID").toString
val alignmentDir: String = outputDir + sampleID + "/alignment/"
val runDir: String = alignmentDir + "run_" + runID + "/"
if (runConfig.contains("R1")) {
// val mapping = Mapping.loadFromLibraryConfig(this, runConfig, sampleConfig, runDir)
val mapping = new Mapping(this)
mapping.defaultAligner = "stampy"
......@@ -153,7 +147,6 @@ class Yamsvp(val root: Configurable) extends QScript with MultiSampleQScript {
// start sambamba dedup
// outputFiles += ("final_bam" -> mapping.outputFiles("finalBamFile"))
libraryOutput.mappedBamFile = mapping.outputFiles("finalBamFile")
} else this.logger.error("Sample: " + sampleID + ": No R1 found for run: " + runConfig)
return libraryOutput
......
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