Commit 6ebb058a authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

- Fixed output of star

parent 4785e578
......@@ -9,39 +9,31 @@ import scala.sys.process._
class Star(private var globalConfig: Config) extends CommandLineFunction {
def this() = this(new Config(Map()))
this.analysisName = "STAR"
var config: Config = _
var config: Config = Config.mergeConfigs(globalConfig.getAsConfig("star"), globalConfig)
@Argument(doc="STAR executeble", shortName="star_exe", required=false) var star_exe: String = _
@Input(doc="The reference file for the bam files.", shortName="R") var referenceFile: File = _
@Argument(doc="STAR executeble", shortName="star_exe", required=false)
var star_exe: String = config.getAsString("exe", "/usr/local/bin/STAR")
@Input(doc="The reference file for the bam files.", shortName="R") var referenceFile: File = new File(config.getAsString("referenceFile"))
@Input(doc="Fastq file R1", shortName="R1") var R1: File = _
@Input(doc="Fastq file R2", shortName="R2", required=false) var R2: File = _
@Argument(doc="Output Directory", shortName="outputDir") var outputDir: String = _
@Argument(doc="GenomeDir", required=false) var genomeDir: String = _
if (genomeDir == null) genomeDir = config.getAsString("genomeDir", referenceFile.getParent + "/star")
@Argument(doc="STAR runmode", shortName="runmode", required=false) var runmode: String = _
@Output
var outputSam: File = _
def init() {
config = Config.mergeConfigs(globalConfig.getAsConfig("star"), globalConfig)
star_exe = config.getAsString("exe", "/usr/local/bin/STAR")
if (genomeDir == null) genomeDir = config.getAsString("genomeDir", referenceFile.getParent + "/star")
this.addJobReportBinding("version", "NA")
jobResourceRequests :+= "h_vmem=" + config.getAsString("vmem", "6G")
var threads: Int = config.getAsInt("threads", 8)
var maxThreads: Int = config.getAsInt("maxthreads", 24)
if (threads > maxThreads) threads = maxThreads
nCoresRequest = Option(threads)
referenceFile = new File(config.getAsString("referenceFile"))
outputSam = new File(outputDir + "/star_output.sam")
}
this.addJobReportBinding("version", "NA")
jobResourceRequests :+= "h_vmem=" + config.getAsString("vmem", "6G")
var threads: Int = config.getAsInt("threads", 8)
var maxThreads: Int = config.getAsInt("maxthreads", 24)
if (threads > maxThreads) threads = maxThreads
nCoresRequest = Option(threads)
@Output var outputSam: File = new File(outputDir + "/star_output.sam")
def commandLine : String= {
init()
//init()
var cmd: String = required("cd",outputDir) + "&&" + required(star_exe)
if (runmode != null && runmode == "genomeGenerate") { // Create index
cmd += required("--runmode", runmode) +
......
......@@ -14,6 +14,7 @@ import scala.util.parsing.json._
import org.broadinstitute.sting.utils.variant._
class Mapping(private var globalConfig: Config) extends QScript {
qscript =>
@Argument(doc="Config Json file",shortName="config", required=false) var configfiles: List[File] = Nil
@Input(doc="R1 fastq file", shortName="R1",required=true) var input_R1: File = _
@Input(doc="R2 fastq file", shortName="R2", required=false) var input_R2: File = _
......@@ -79,21 +80,22 @@ class Mapping(private var globalConfig: Config) extends QScript {
fastq_R1 = flexiprep.outputFiles("output_R1")
if (paired) fastq_R2 = flexiprep.outputFiles("output_R2")
}
var bamFile:File = ""
var bamFile:File = null
if (aligner == "bwa") {
val bwaCommand = new Bwa(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2;
RG = getReadGroup; output = new File(outputDir + outputName + ".sam") }
add(bwaCommand)
bamFile = addSortSam(List(bwaCommand.output), swapExt(outputDir,bwaCommand.output,".sam",".bam"), outputDir)
} else if (aligner == "star") {
val starCommand = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2; this.outputDir = outputDir }
val starCommand = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2; this.outputDir = qscript.outputDir + "star/" ;
outputSam = new File(this.outputDir + "/star_output.sam") }
add(starCommand)
bamFile = addAddOrReplaceReadGroups(List(starCommand.outputSam), swapExt(outputDir,starCommand.outputSam,".sam",".bam"), outputDir)
}
if (!skipMarkduplicates) bamFile = addMarkDuplicates(List(bamFile), swapExt(outputDir,bamFile,".bam",".dedup.bam"), outputDir)
}
def addSortSam(inputSam:List[File], outputFile:File, dir:String) : File = {
val sortSam = new SortSam {
input = inputSam
......@@ -124,6 +126,8 @@ class Mapping(private var globalConfig: Config) extends QScript {
if (RGCN != null) this.RGCN = RGCN
if (RGDS != null) this.RGDS = RGDS
}
add(addOrReplaceReadGroups)
return addOrReplaceReadGroups.output
}
......
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