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

Convert SortSam to biopet function

parent 2cd4fb00
package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
class SortSam(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.SortSam"
@Input(doc = "The input SAM or BAM files to analyze.", required = true)
var input: File = _
@Output(doc = "The output file to bam file to", required = true)
var output: File = _
@Argument(doc = "Sort order of output file Required. Possible values: {unsorted, queryname, coordinate} ", required = true)
var sortOrder: String = _
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
required("SORT_ORDER=", sortOrder, spaceSeparated = false)
}
object SortSam {
def apply(root: Configurable, input: File, outputDir: String, sortOrder: String = null): SortSam = {
val sortSam = new SortSam(root)
sortSam.input = input
sortSam.output = new File(outputDir, input.getName.stripSuffix(".bam").stripSuffix(".sam") + ".sorted.bam")
if (sortOrder == null) sortSam.sortOrder = "coordinate"
else sortSam.sortOrder = sortOrder
return sortSam
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@ import java.util.Date
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import nl.lumc.sasc.biopet.core.apps.FastqSplitter
import nl.lumc.sasc.biopet.extensions.aligners.{ Bwa, Star }
import nl.lumc.sasc.biopet.extensions.picard.MarkDuplicates
import nl.lumc.sasc.biopet.extensions.picard.{MarkDuplicates, SortSam}
import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics
import nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.utils.commandline.{ Input, Argument, ClassType }
import org.broadinstitute.gatk.queue.extensions.picard.{ MergeSamFiles, SortSam, AddOrReplaceReadGroups }
import org.broadinstitute.gatk.queue.extensions.picard.{ MergeSamFiles, AddOrReplaceReadGroups }
import scala.math._
class Mapping(val root: Configurable) extends QScript with BiopetQScript {
......@@ -192,7 +192,10 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
bwaCommand.R = getReadGroup
bwaCommand.output = new File(chunkDir + outputName + ".sam")
add(bwaCommand, isIntermediate = true)
bamFiles :+= addSortSam(List(bwaCommand.output), swapExt(chunkDir, bwaCommand.output, ".sam", ".bam"), chunkDir)
val sortSam = SortSam(this, bwaCommand.output, chunkDir)
if (chunking || !skipMarkduplicates) sortSam.isIntermediate = true
add(sortSam)
bamFiles :+= sortSam.output
} else if (aligner == "star") {
val starCommand = Star(this, R1, if (paired) R2 else null, outputDir, isIntermediate = true, deps = deps)
add(starCommand)
......@@ -219,19 +222,19 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
outputFiles += ("finalBamFile" -> bamFile)
}
def addSortSam(inputSam: List[File], outputFile: File, dir: String): File = {
val sortSam = new SortSam
sortSam.input = inputSam
sortSam.createIndex = true
sortSam.output = outputFile
sortSam.memoryLimit = 2
sortSam.nCoresRequest = 2
sortSam.jobResourceRequests :+= "h_vmem=4G"
if (!skipMarkduplicates) sortSam.isIntermediate = true
add(sortSam)
return sortSam.output
}
// def addSortSam(inputSam: List[File], outputFile: File, dir: String): File = {
// val sortSam = new SortSam
// sortSam.input = inputSam
// sortSam.createIndex = true
// sortSam.output = outputFile
// sortSam.memoryLimit = 2
// sortSam.nCoresRequest = 2
// sortSam.jobResourceRequests :+= "h_vmem=4G"
// if (!skipMarkduplicates) sortSam.isIntermediate = true
// add(sortSam)
//
// return sortSam.output
// }
def addMergeBam(inputSam: List[File], outputFile: File, dir: String): File = {
val mergeSam = new MergeSamFiles
......
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