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

Added scala docs for picard

parent 74fa6d37
......@@ -77,7 +77,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
}
List(bamFile)
} else {
val markDup = MarkDuplicates(this, files, new File(outputDir + outputName + ".dedup.bam"))
val markDup = MarkDuplicates(this, files, new File(outputDir, outputName + ".dedup.bam"))
markDup.isIntermediate = useIndelRealigner
add(markDup)
if (useIndelRealigner) {
......
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard AddOrReplaceReadGroups */
class AddOrReplaceReadGroups(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.AddOrReplaceReadGroups"
......@@ -61,6 +62,7 @@ class AddOrReplaceReadGroups(val root: Configurable) extends Picard {
@Argument(doc = "RGPI", required = false)
var RGPI: Option[Int] = _
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -77,6 +79,7 @@ class AddOrReplaceReadGroups(val root: Configurable) extends Picard {
}
object AddOrReplaceReadGroups {
/** Returns default AddOrReplaceReadGroups */
def apply(root: Configurable, input: File, output: File, sortOrder: String = null): AddOrReplaceReadGroups = {
val addOrReplaceReadGroups = new AddOrReplaceReadGroups(root)
addOrReplaceReadGroups.input = input
......
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard CalculateHsMetrics */
class CalculateHsMetrics(val root: Configurable) extends Picard {
javaMainClass = "picard.analysis.directed.CalculateHsMetrics"
......@@ -46,6 +47,7 @@ class CalculateHsMetrics(val root: Configurable) extends Picard {
@Argument(doc = "BAIT_SET_NAME", required = false)
var baitSetName: String = _
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -58,6 +60,7 @@ class CalculateHsMetrics(val root: Configurable) extends Picard {
}
object CalculateHsMetrics {
/** Returns default CalculateHsMetrics */
def apply(root: Configurable, input: File, baitIntervals: File, targetIntervals: File, outputDir: File): CalculateHsMetrics = {
val calculateHsMetrics = new CalculateHsMetrics(root)
calculateHsMetrics.input = input
......
......@@ -20,6 +20,7 @@ import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard CollectAlignmentSummaryMetrics */
class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard with Summarizable {
javaMainClass = "picard.analysis.CollectAlignmentSummaryMetrics"
......@@ -50,6 +51,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard with
@Argument(doc = "STOP_AFTER", required = false)
var stopAfter: Option[Long] = config("stopAfter")
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -63,6 +65,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard with
def summaryFiles: Map[String, File] = Map()
/** Returns stats for summary */
def summaryStats: Map[String, Any] = {
val (header, content) = Picard.getMetrics(output)
......@@ -79,6 +82,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard with
}
object CollectAlignmentSummaryMetrics {
/** Returns default CollectAlignmentSummaryMetrics */
def apply(root: Configurable, input: File, outputDir: File): CollectAlignmentSummaryMetrics = {
val collectAlignmentSummaryMetrics = new CollectAlignmentSummaryMetrics(root)
collectAlignmentSummaryMetrics.input = input
......
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard CollectGcBiasMetrics */
class CollectGcBiasMetrics(val root: Configurable) extends Picard {
javaMainClass = "picard.analysis.CollectGcBiasMetrics"
......@@ -51,9 +52,9 @@ class CollectGcBiasMetrics(val root: Configurable) extends Picard {
override def beforeGraph {
if (outputChart == null) outputChart = new File(output + ".pdf")
//require(reference.exists)
}
/** Returns command to execute */
override def commandLine = super.commandLine +
repeat("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -67,6 +68,7 @@ class CollectGcBiasMetrics(val root: Configurable) extends Picard {
}
object CollectGcBiasMetrics {
/** Returns default CollectGcBiasMetrics */
def apply(root: Configurable, input: File, outputDir: File): CollectGcBiasMetrics = {
val collectGcBiasMetrics = new CollectGcBiasMetrics(root)
collectGcBiasMetrics.input :+= input
......
......@@ -22,6 +22,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
import scala.collection.immutable.Nil
/** Extension for picard CollectInsertSizeMetrics */
class CollectInsertSizeMetrics(val root: Configurable) extends Picard with Summarizable {
javaMainClass = "picard.analysis.CollectInsertSizeMetrics"
......@@ -57,10 +58,9 @@ class CollectInsertSizeMetrics(val root: Configurable) extends Picard with Summa
override def beforeGraph {
outputHistogram = new File(output + ".pdf")
//if (outputHistogram == null) outputHistogram = new File(output + ".pdf")
//require(reference.exists)
}
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -72,8 +72,10 @@ class CollectInsertSizeMetrics(val root: Configurable) extends Picard with Summa
optional("HISTOGRAM_WIDTH=", histogramWidth, spaceSeparated = false) +
conditional(assumeSorted, "ASSUME_SORTED=TRUE")
/** Returns files for summary */
def summaryFiles: Map[String, File] = Map("output_histogram" -> outputHistogram)
/** Returns stats for summary */
def summaryStats: Map[String, Any] = {
val (header, content) = Picard.getMetrics(output)
(for (i <- 0 to header.size if i < content.head.size)
......@@ -82,6 +84,7 @@ class CollectInsertSizeMetrics(val root: Configurable) extends Picard with Summa
}
object CollectInsertSizeMetrics {
/** Returns default CollectInsertSizeMetrics */
def apply(root: Configurable, input: File, outputDir: File): CollectInsertSizeMetrics = {
val collectInsertSizeMetrics = new CollectInsertSizeMetrics(root)
collectInsertSizeMetrics.input = input
......
......@@ -20,6 +20,7 @@ import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard MarkDuplicates */
class MarkDuplicates(val root: Configurable) extends Picard with Summarizable {
javaMainClass = "picard.sam.MarkDuplicates"
......@@ -76,6 +77,7 @@ class MarkDuplicates(val root: Configurable) extends Picard with Summarizable {
if (createIndex) outputIndex = new File(output.getAbsolutePath.stripSuffix(".bam") + ".bai")
}
/** Returns command to execute */
override def commandLine = super.commandLine +
repeat("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -93,8 +95,10 @@ class MarkDuplicates(val root: Configurable) extends Picard with Summarizable {
optional("READ_NAME_REGEX=", readNameRegex, spaceSeparated = false) +
optional("OPTICAL_DUPLICATE_PIXEL_DISTANCE=", opticalDuplicatePixelDistance, spaceSeparated = false)
/** Returns files for summary */
def summaryFiles: Map[String, File] = Map()
/** Returns stats for summary */
def summaryStats: Map[String, Any] = {
val (header, content) = Picard.getMetrics(outputMetrics)
......@@ -110,19 +114,12 @@ class MarkDuplicates(val root: Configurable) extends Picard with Summarizable {
}
}
object MarkDuplicates {
def apply(root: Configurable, input: List[File], outputDir: String): MarkDuplicates = {
val markDuplicates = new MarkDuplicates(root)
markDuplicates.input = input
markDuplicates.output = new File(outputDir, input.head.getName.stripSuffix(".bam") + ".dedup.bam")
markDuplicates.outputMetrics = new File(outputDir, input.head.getName.stripSuffix(".bam") + ".dedup.metrics")
return markDuplicates
}
/** Returns default MarkDuplicates */
def apply(root: Configurable, input: List[File], output: File): MarkDuplicates = {
val markDuplicates = new MarkDuplicates(root)
markDuplicates.input = input
markDuplicates.output = output
markDuplicates.outputMetrics = new File(output.getParent, output.getName.stripSuffix(".bam") + ".metrics")
return markDuplicates
markDuplicates
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard MergeSamFiles */
class MergeSamFiles(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.MergeSamFiles"
......@@ -43,6 +44,7 @@ class MergeSamFiles(val root: Configurable) extends Picard {
@Argument(doc = "COMMENT", required = false)
var comment: Option[String] = config("comment")
/** Returns command to execute */
override def commandLine = super.commandLine +
repeat("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -53,12 +55,13 @@ class MergeSamFiles(val root: Configurable) extends Picard {
}
object MergeSamFiles {
/** Returns default MergeSamFiles */
def apply(root: Configurable, input: List[File], outputDir: File, 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
mergeSamFiles
}
}
\ No newline at end of file
......@@ -22,6 +22,11 @@ import org.broadinstitute.gatk.utils.commandline.{ Argument }
import scala.io.Source
/**
* General picard extension
*
* This is based on using class files directly from the jar
*/
abstract class Picard extends BiopetJavaCommandLineFunction {
override def subPath = "picard" :: super.subPath
......@@ -66,6 +71,11 @@ abstract class Picard extends BiopetJavaCommandLineFunction {
}
object Picard {
/**
* This function parse a metrics file in separated values
* @param file input metrics file
* @return (header, content)
*/
def getMetrics(file: File) = {
val lines = Source.fromFile(file).getLines().toArray
......
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard SamToFastq */
class SamToFastq(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.SamToFastq"
......@@ -70,6 +71,7 @@ class SamToFastq(val root: Configurable) extends Picard {
@Argument(doc = "includeNonPrimaryAlignments", required = false)
var includeNonPrimaryAlignments: Boolean = config("includeNonPrimaryAlignments", default = false)
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("FASTQ=", fastqR1, spaceSeparated = false) +
......@@ -90,11 +92,12 @@ class SamToFastq(val root: Configurable) extends Picard {
}
object SamToFastq {
/** Returns default SamToFastq */
def apply(root: Configurable, input: File, fastqR1: File, fastqR2: File = null): SamToFastq = {
val samToFastq = new SamToFastq(root)
samToFastq.input = input
samToFastq.fastqR1 = fastqR1
samToFastq.fastqR2 = fastqR2
return samToFastq
samToFastq
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard SortSam */
class SortSam(val root: Configurable) extends Picard {
javaMainClass = "picard.sam.SortSam"
......@@ -39,6 +40,7 @@ class SortSam(val root: Configurable) extends Picard {
if (createIndex) outputIndex = new File(output.getAbsolutePath.stripSuffix(".bam") + ".bai")
}
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......@@ -46,6 +48,7 @@ class SortSam(val root: Configurable) extends Picard {
}
object SortSam {
/** Returns default SortSam */
def apply(root: Configurable, input: File, output: File, sortOrder: String = null): SortSam = {
val sortSam = new SortSam(root)
sortSam.input = input
......
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