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

convert MergeSamFiles to biopet function

parent 9b20e271
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 MergeSamFiles(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.MergeSamFiles"
@Input(doc = "The input SAM or BAM files to analyze.", required = true)
var input: List[File] = Nil
@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 = _
@Argument(doc = "ASSUME_SORTED", required = false)
var assumeSorted: Boolean = config("assumesorted", default = false)
@Argument(doc = "MERGE_SEQUENCE_DICTIONARIES", required = false)
var mergeSequenceDictionaries: Boolean = config("merge_sequence_dictionaries", default = false)
@Argument(doc = "USE_THREADING", required = false)
var useThreading: Boolean = config("use_threading", default = false)
@Argument(doc = "COMMENT", required = false)
var comment: String = config("comment")
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
required("SORT_ORDER=", sortOrder, spaceSeparated = false) +
conditional(assumeSorted, "ASSUME_SORTED=TRUE") +
conditional(mergeSequenceDictionaries, "MERGE_SEQUENCE_DICTIONARIES=TRUE") +
optional("COMMENT=", comment, spaceSeparated = false)
}
object MergeSamFiles {
def apply(root: Configurable, input: List[File], outputDir: String, sortOrder: String = null): MergeSamFiles = {
val mergeSamFiles = new MergeSamFiles(root)
mergeSamFiles.input = input
mergeSamFiles.output = new File(outputDir, input.head.getName.stripSuffix(".bam").stripSuffix(".sam") + ".merge.bam")
if (sortOrder == null) mergeSamFiles.sortOrder = "coordinate"
else mergeSamFiles.sortOrder = sortOrder
return mergeSamFiles
}
}
\ 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, SortSam}
import nl.lumc.sasc.biopet.extensions.picard.{MarkDuplicates, SortSam, MergeSamFiles}
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, AddOrReplaceReadGroups }
import org.broadinstitute.gatk.queue.extensions.picard.{ AddOrReplaceReadGroups }
import scala.math._
class Mapping(val root: Configurable) extends QScript with BiopetQScript {
......@@ -218,7 +218,11 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
if (!skipMarkduplicates) {
bamFile = new File(outputDir + outputName + ".dedup.bam")
add(MarkDuplicates(this, bamFiles, bamFile))
} else if (skipMarkduplicates && chunking) bamFile = addMergeBam(bamFiles, new File(outputDir + outputName + ".bam"), outputDir)
} else if (skipMarkduplicates && chunking) {
val mergeSamFile = MergeSamFiles(this, bamFiles, outputDir)
add(mergeSamFile)
bamFile = mergeSamFile.output
}
if (!skipMetrics) addAll(BamMetrics.apply(this, bamFile, outputDir + "metrics/").functions)
......@@ -239,21 +243,21 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
// return sortSam.output
// }
def addMergeBam(inputSam: List[File], outputFile: File, dir: String): File = {
val mergeSam = new MergeSamFiles
mergeSam.input = inputSam
mergeSam.createIndex = true
mergeSam.output = outputFile
mergeSam.memoryLimit = 2
mergeSam.nCoresRequest = 2
mergeSam.assumeSorted = true
mergeSam.USE_THREADING = true
mergeSam.jobResourceRequests :+= "h_vmem=4G"
if (!skipMarkduplicates) mergeSam.isIntermediate = true
add(mergeSam)
return mergeSam.output
}
// def addMergeBam(inputSam: List[File], outputFile: File, dir: String): File = {
// val mergeSam = new MergeSamFiles
// mergeSam.input = inputSam
// mergeSam.createIndex = true
// mergeSam.output = outputFile
// mergeSam.memoryLimit = 2
// mergeSam.nCoresRequest = 2
// mergeSam.assumeSorted = true
// mergeSam.USE_THREADING = true
// mergeSam.jobResourceRequests :+= "h_vmem=4G"
// if (!skipMarkduplicates) mergeSam.isIntermediate = true
// add(mergeSam)
//
// return mergeSam.output
// }
def addAddOrReplaceReadGroups(inputSam: List[File], outputFile: File, dir: String): File = {
val addOrReplaceReadGroups = new AddOrReplaceReadGroups
......
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