Commit 02b571a4 authored by bow's avatar bow

Update code style using scalariform

parent 96ccc270
......@@ -2,27 +2,27 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
import org.broadinstitute.gatk.queue.QScript
import nl.lumc.sasc.biopet.core.{BiopetQScript, PipelineCommand}
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import java.io.File
import nl.lumc.sasc.biopet.core.apps.{BedToInterval, BiopetFlagstat}
import nl.lumc.sasc.biopet.core.apps.{ BedToInterval, BiopetFlagstat }
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.function.bedtools.{BedtoolsCoverage, BedtoolsIntersect}
import nl.lumc.sasc.biopet.function.picard.{CollectInsertSizeMetrics, CollectGcBiasMetrics, CalculateHsMetrics, CollectAlignmentSummaryMetrics}
import nl.lumc.sasc.biopet.function.bedtools.{ BedtoolsCoverage, BedtoolsIntersect }
import nl.lumc.sasc.biopet.function.picard.{ CollectInsertSizeMetrics, CollectGcBiasMetrics, CalculateHsMetrics, CollectAlignmentSummaryMetrics }
import nl.lumc.sasc.biopet.function.samtools.SamtoolsFlagstat
class BamMetrics(val root:Configurable) extends QScript with BiopetQScript {
class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
def this() = this(null)
@Input(doc="Bam File", shortName="BAM",required=true)
@Input(doc = "Bam File", shortName = "BAM", required = true)
var inputBam: File = _
@Input(doc="Bed tracks targets", shortName="target",required=false)
@Input(doc = "Bed tracks targets", shortName = "target", required = false)
var bedFiles: List[File] = Nil
@Input(doc="Bed tracks bait", shortName="bait",required=false)
@Input(doc = "Bed tracks bait", shortName = "bait", required = false)
var baitBedFile: File = _
@Argument(doc="",required=false)
@Argument(doc = "", required = false)
var wholeGenome = false
def init() {
......@@ -50,12 +50,12 @@ class BamMetrics(val root:Configurable) extends QScript with BiopetQScript {
else targetInterval.output, targetInterval.output, targetDir))
val strictOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.strict.bam")
add(BedtoolsIntersect(this, inputBam, bedFile, strictOutputBam, minOverlap = config("strictintersectoverlap", default=1.0)), true)
add(BedtoolsIntersect(this, inputBam, bedFile, strictOutputBam, minOverlap = config("strictintersectoverlap", default = 1.0)), true)
add(SamtoolsFlagstat(this, strictOutputBam))
add(BiopetFlagstat(this, strictOutputBam, targetDir))
val looseOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.loose.bam")
add(BedtoolsIntersect(this, inputBam, bedFile, looseOutputBam, minOverlap = config("looseintersectoverlap", default=0.01)), true)
add(BedtoolsIntersect(this, inputBam, bedFile, looseOutputBam, minOverlap = config("looseintersectoverlap", default = 0.01)), true)
add(SamtoolsFlagstat(this, looseOutputBam))
add(BiopetFlagstat(this, looseOutputBam, targetDir))
......@@ -69,7 +69,7 @@ class BamMetrics(val root:Configurable) extends QScript with BiopetQScript {
object BamMetrics extends PipelineCommand {
override val pipeline = "/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.class"
def apply(root:Configurable, bamFile:File, outputDir:String) : BamMetrics = {
def apply(root: Configurable, bamFile: File, outputDir: String): BamMetrics = {
val bamMetrics = new BamMetrics(root)
bamMetrics.inputBam = bamFile
bamMetrics.outputDir = outputDir
......
......@@ -2,19 +2,19 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics.scripts
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.function.PythonCommandLineFunction
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import java.io.File
class CoverageStats(val root:Configurable) extends PythonCommandLineFunction {
class CoverageStats(val root: Configurable) extends PythonCommandLineFunction {
setPythonScript("bedtools_cov_stats.py")
@Input(doc="Input file")
@Input(doc = "Input file")
var input: File = _
@Output(doc="output File")
@Output(doc = "output File")
var output: File = _
@Output(doc="plot File (png)")
@Output(doc = "plot File (png)")
var plot: File = _
def cmdLine = getPythonCommand +
......@@ -22,7 +22,7 @@ class CoverageStats(val root:Configurable) extends PythonCommandLineFunction {
}
object CoverageStats {
def apply(root:Configurable, input:File, outputDir:String) : CoverageStats = {
def apply(root: Configurable, input: File, outputDir: String): CoverageStats = {
val coverageStats = new CoverageStats(root)
coverageStats.input = input
coverageStats.output = new File(outputDir, input.getName + ".stats")
......
......@@ -11,18 +11,18 @@ import scala.util.matching.Regex
trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurable {
analysisName = getClass.getSimpleName
@Input(doc="deps", required=false)
@Input(doc = "deps", required = false)
var deps: List[File] = Nil
@Argument(doc="Threads", required=false)
@Argument(doc = "Threads", required = false)
var threads = 0
val defaultThreads = 1
@Argument(doc="Vmem", required=false)
@Argument(doc = "Vmem", required = false)
var vmem: String = _
val defaultVmem: String = ""
@Argument(doc="Executable")
@Argument(doc = "Executable")
var executable: String = _
protected def beforeCmd {
......@@ -81,7 +81,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
protected def versionCommand: String = null
protected val versionRegex: Regex = null
protected val versionExitcode = List(0) // Can select multiple
def getVersion : String = {
def getVersion: String = {
if (versionCommand == null || versionRegex == null) return "N/A"
val buffer = new StringBuffer()
val process = Process(versionCommand).run(ProcessLogger(buffer append _))
......@@ -100,16 +100,16 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
return "N/A"
}
def getThreads(default:Int) : Int = {
val maxThreads: Int = config("maxthreads", default=8)
val threads: Int = config("threads", default=default)
def getThreads(default: Int): Int = {
val maxThreads: Int = config("maxthreads", default = 8)
val threads: Int = config("threads", default = default)
if (maxThreads > threads) return threads
else return maxThreads
}
def getThreads(default:Int, module:String) : Int = {
val maxThreads: Int = config("maxthreads", default=8, submodule=module)
val threads: Int = config("threads", default=default, submodule=module)
def getThreads(default: Int, module: String): Int = {
val maxThreads: Int = config("maxthreads", default = 8, submodule = module)
val threads: Int = config("threads", default = default, submodule = module)
if (maxThreads > threads) return threads
else return maxThreads
}
......
......@@ -9,7 +9,7 @@ abstract class BiopetJavaCommandLineFunction extends JavaCommandLineFunction wit
preCmdInternal
val cmd = super.commandLine
val finalCmd = executable + cmd.substring(cmd.indexOf(" "))
// addJobReportBinding("command", cmd)
// addJobReportBinding("command", cmd)
return cmd
}
}
......@@ -32,7 +32,7 @@ import org.broadinstitute.gatk.queue.util._
import org.broadinstitute.gatk.queue.QCommandPlugin
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.QScriptManager
import org.broadinstitute.gatk.queue.engine.{QStatusMessenger, QGraphSettings, QGraph}
import org.broadinstitute.gatk.queue.engine.{ QStatusMessenger, QGraphSettings, QGraph }
import collection.JavaConversions._
import org.broadinstitute.gatk.utils.classloader.PluginManager
import org.broadinstitute.gatk.utils.exceptions.UserException
......@@ -40,7 +40,7 @@ import org.broadinstitute.gatk.utils.io.IOUtils
import org.broadinstitute.gatk.utils.help.ApplicationDetails
import java.io.FileOutputStream
import java.net.URL
import java.util.{ResourceBundle, Arrays}
import java.util.{ ResourceBundle, Arrays }
import org.broadinstitute.gatk.utils.text.TextFormattingUtils
import org.apache.commons.io.FilenameUtils
......@@ -84,7 +84,7 @@ object BiopetQCommandLine extends Logging {
* Entry point of Queue. Compiles and runs QScripts passed in to the command line.
*/
class BiopetQCommandLine extends CommandLineProgram with Logging {
@Input(fullName="script", shortName="S", doc="QScript scala file", required=false)
@Input(fullName = "script", shortName = "S", doc = "QScript scala file", required = false)
@ClassType(classOf[File])
var scripts: Seq[File] = Nil
var pipelineName: String = _
......@@ -155,8 +155,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
// TODO: Default command plugin argument?
val remoteFileConverter = (
for (commandPlugin <- allCommandPlugins if (commandPlugin.remoteFileConverter != null))
yield commandPlugin.remoteFileConverter
).headOption.getOrElse(null)
yield commandPlugin.remoteFileConverter).headOption.getOrElse(null)
if (remoteFileConverter != null)
loadArgumentsIntoObject(remoteFileConverter)
......@@ -267,37 +266,35 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
override def getArgumentTypeDescriptors =
Arrays.asList(new ScalaCompoundArgumentTypeDescriptor)
override def getApplicationDetails : ApplicationDetails = {
override def getApplicationDetails: ApplicationDetails = {
new ApplicationDetails(createQueueHeader(),
Seq.empty[String],
ApplicationDetails.createDefaultRunningInstructions(getClass.asInstanceOf[Class[CommandLineProgram]]),
"")
}
private def createQueueHeader() : Seq[String] = {
private def createQueueHeader(): Seq[String] = {
Seq(String.format("Queue v%s, Compiled %s", getQueueVersion, getBuildTimestamp),
"Copyright (c) 2012 The Broad Institute",
"For support and documentation go to http://www.broadinstitute.org/gatk")
}
private def getQueueVersion : String = {
val stingResources : ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
private def getQueueVersion: String = {
val stingResources: ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
if ( stingResources.containsKey("org.broadinstitute.sting.queue.QueueVersion.version") ) {
if (stingResources.containsKey("org.broadinstitute.sting.queue.QueueVersion.version")) {
stingResources.getString("org.broadinstitute.sting.queue.QueueVersion.version")
}
else {
} else {
"<unknown>"
}
}
private def getBuildTimestamp : String = {
val stingResources : ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
private def getBuildTimestamp: String = {
val stingResources: ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
if ( stingResources.containsKey("build.timestamp") ) {
if (stingResources.containsKey("build.timestamp")) {
stingResources.getString("build.timestamp")
}
else {
} else {
"<unknown>"
}
}
......
......@@ -8,13 +8,13 @@ import org.broadinstitute.gatk.queue.QSettings
import org.broadinstitute.gatk.queue.function.QFunction
trait BiopetQScript extends Configurable {
@Argument(doc="Config Json file",shortName="config", required=false)
@Argument(doc = "Config Json file", shortName = "config", required = false)
val configfiles: List[File] = Nil
@Argument(doc="Output directory", shortName="outputDir", required=true)
@Argument(doc = "Output directory", shortName = "outputDir", required = true)
var outputDir: String = _
var outputFiles:Map[String,File] = Map()
var outputFiles: Map[String, File] = Map()
var qSettings: QSettings
......@@ -35,10 +35,9 @@ trait BiopetQScript extends Configurable {
}
def add(functions: QFunction*) // Gets implemeted at org.broadinstitute.sting.queue.QScript
def add(function: QFunction, isIntermediate:Boolean = false) {
def add(function: QFunction, isIntermediate: Boolean = false) {
function.isIntermediate = isIntermediate
add(function)
}
}
......@@ -4,33 +4,34 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
trait MultiSampleQScript extends BiopetQScript {
var samples:Map[String,Any] = Map()
var samples: Map[String, Any] = Map()
final def runSamplesJobs : Map[String,Map[String,File]] = {
var output: Map[String,Map[String,File]] = Map()
final def runSamplesJobs: Map[String, Map[String, File]] = {
var output: Map[String, Map[String, File]] = Map()
samples = config("samples")
if (samples == null) samples = Map()
if (globalConfig.contains("samples")) for ((key,value) <- samples) {
if (globalConfig.contains("samples")) for ((key, value) <- samples) {
var sample = Configurable.any2map(value)
if (!sample.contains("ID")) sample += ("ID" -> key)
if (sample("ID") == key) {
var files:Map[String,List[File]] = runSingleSampleJobs(sample)
var files: Map[String, List[File]] = runSingleSampleJobs(sample)
} else logger.warn("Key is not the same as ID on value for sample")
} else logger.warn("No Samples found in config")
}
else logger.warn("No Samples found in config")
return output
}
def runSingleSampleJobs(sampleConfig:Map[String,Any]) : Map[String,List[File]]
def runSingleSampleJobs(sample:String) : Map[String,List[File]] ={
def runSingleSampleJobs(sampleConfig: Map[String, Any]): Map[String, List[File]]
def runSingleSampleJobs(sample: String): Map[String, List[File]] = {
return runSingleSampleJobs(Configurable.any2map(samples(sample)))
}
final def runRunsJobs(sampleConfig:Map[String,Any]) : Map[String,Map[String,File]] = {
var output: Map[String,Map[String,File]] = Map()
final def runRunsJobs(sampleConfig: Map[String, Any]): Map[String, Map[String, File]] = {
var output: Map[String, Map[String, File]] = Map()
val sampleID = sampleConfig("ID")
if (sampleConfig.contains("runs")) {
val runs = Configurable.any2map(sampleConfig("runs"))
for ((key,value) <- runs) {
for ((key, value) <- runs) {
var run = Configurable.any2map(value)
if (!run.contains("ID")) run += ("ID" -> key)
if (run("ID") == key) {
......@@ -40,5 +41,5 @@ trait MultiSampleQScript extends BiopetQScript {
} else logger.warn("No runs found in config for sample: " + sampleID)
return output
}
def runSingleRunJobs(runConfig:Map[String,Any], sampleConfig:Map[String,Any]) : Map[String,File]
def runSingleRunJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): Map[String, File]
}
......@@ -11,16 +11,16 @@ import java.io.FileOutputStream
import org.broadinstitute.gatk.queue.util.Logging
trait PipelineCommand extends Logging {
// val src = ""
// val extension = ".scala"
// val src = ""
// val extension = ".scala"
val pipeline = ""
def main(args: Array[String]): Unit = {
// val tempFile = java.io.File.createTempFile(src + ".", extension)
// val is = getClass.getResourceAsStream(src + extension)
// val os = new FileOutputStream(tempFile)
// org.apache.commons.io.IOUtils.copy(is, os)
// os.close()
// val tempFile = java.io.File.createTempFile(src + ".", extension)
// val is = getClass.getResourceAsStream(src + extension)
// val os = new FileOutputStream(tempFile)
// org.apache.commons.io.IOUtils.copy(is, os)
// os.close()
var argv: Array[String] = Array()
//argv ++= Array("-S", tempFile.getAbsolutePath)
......
......@@ -5,20 +5,20 @@ import htsjdk.samtools.SAMSequenceRecord
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import java.io.PrintWriter
import scala.io.Source
class BedToInterval(val root:Configurable) extends BiopetJavaCommandLineFunction {
class BedToInterval(val root: Configurable) extends BiopetJavaCommandLineFunction {
javaMainClass = getClass.getName
@Input(doc="Input Bed file", required = true)
@Input(doc = "Input Bed file", required = true)
var input: File = _
@Input(doc="Bam File", required = true)
var bamFile:File = _
@Input(doc = "Bam File", required = true)
var bamFile: File = _
@Output(doc="Output interval list", required = true)
@Output(doc = "Output interval list", required = true)
var output: File = _
override val defaultVmem = "8G"
......@@ -28,7 +28,7 @@ class BedToInterval(val root:Configurable) extends BiopetJavaCommandLineFunction
}
object BedToInterval {
def apply(root:Configurable, inputBed:File, inputBam:File, outputDir:String) : BedToInterval = {
def apply(root: Configurable, inputBed: File, inputBam: File, outputDir: String): BedToInterval = {
val bedToInterval = new BedToInterval(root)
bedToInterval.input = inputBed
bedToInterval.bamFile = inputBam
......@@ -36,7 +36,7 @@ object BedToInterval {
return bedToInterval
}
def apply(root:Configurable, inputBed:File, inputBam:File, output:File) : BedToInterval = {
def apply(root: Configurable, inputBed: File, inputBam: File, output: File): BedToInterval = {
val bedToInterval = new BedToInterval(root)
bedToInterval.input = inputBed
bedToInterval.bamFile = inputBam
......
......@@ -2,22 +2,22 @@ package nl.lumc.sasc.biopet.core.apps
import htsjdk.samtools.SAMFileReader
import htsjdk.samtools.SAMRecord
import java.io.{BufferedInputStream, File, FileInputStream, PrintWriter}
import java.io.{ BufferedInputStream, File, FileInputStream, PrintWriter }
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import scala.io.Source
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import org.broadinstitute.gatk.queue.util.Logging
import scala.collection.JavaConversions._
import scala.collection.mutable.Map
class BiopetFlagstat(val root:Configurable) extends BiopetJavaCommandLineFunction {
class BiopetFlagstat(val root: Configurable) extends BiopetJavaCommandLineFunction {
javaMainClass = getClass.getName
@Input(doc="Input bam", shortName = "input", required = true)
@Input(doc = "Input bam", shortName = "input", required = true)
var input: File = _
@Output(doc="Output flagstat", shortName="output", required = true)
@Output(doc = "Output flagstat", shortName = "output", required = true)
var output: File = _
override val defaultVmem = "8G"
......@@ -27,13 +27,13 @@ class BiopetFlagstat(val root:Configurable) extends BiopetJavaCommandLineFunctio
}
object BiopetFlagstat extends Logging {
def apply(root:Configurable, input:File, output:File) : BiopetFlagstat = {
def apply(root: Configurable, input: File, output: File): BiopetFlagstat = {
val flagstat = new BiopetFlagstat(root)
flagstat.input = input
flagstat.output = output
return flagstat
}
def apply(root:Configurable, input:File, outputDir:String) : BiopetFlagstat = {
def apply(root: Configurable, input: File, outputDir: String): BiopetFlagstat = {
val flagstat = new BiopetFlagstat(root)
flagstat.input = input
flagstat.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".biopetflagstat")
......@@ -50,14 +50,13 @@ object BiopetFlagstat extends Logging {
val m = 10
val max = 60
for (t <- 0 to (max / m))
flagstatCollector.addFunction("MAPQ>"+(t * m), record => record.getMappingQuality > (t * m))
flagstatCollector.addFunction("MAPQ>" + (t * m), record => record.getMappingQuality > (t * m))
flagstatCollector.addFunction("First normal, second read inverted (paired end orientation)", record => {
if (record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag != record.getMateNegativeStrandFlag &&
((record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))
) true
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))) true
else false
})
flagstatCollector.addFunction("First normal, second read normal", record => {
......@@ -65,8 +64,7 @@ object BiopetFlagstat extends Logging {
((record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))
) true
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))) true
else false
})
flagstatCollector.addFunction("First inverted, second read inverted", record => {
......@@ -74,8 +72,7 @@ object BiopetFlagstat extends Logging {
((record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))
) true
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))) true
else false
})
flagstatCollector.addFunction("First inverted, second read normal", record => {
......@@ -83,8 +80,7 @@ object BiopetFlagstat extends Logging {
((record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))
) true
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))) true
else false
})
flagstatCollector.addFunction("Mate in same strand", record => record.getReadNegativeStrandFlag && record.getMateNegativeStrandFlag &&
......@@ -106,7 +102,7 @@ object BiopetFlagstat extends Logging {
private val names: Map[Int, String] = Map()
private var functions: Array[SAMRecord => Boolean] = Array()
private var totalCounts: Array[Long] = Array()
private var crossCounts = Array.ofDim[Int](1,1)
private var crossCounts = Array.ofDim[Int](1, 1)
def loadDefaultFunctions {
addFunction("All", record => true)
......@@ -130,7 +126,7 @@ object BiopetFlagstat extends Logging {
addFunction("SecondaryOrSupplementary", record => record.isSecondaryOrSupplementary)
}
def loadRecord(record:SAMRecord) {
def loadRecord(record: SAMRecord) {
readsCount += 1
val values: Array[Boolean] = new Array(names.size)
for (t <- 0 until names.size) {
......@@ -148,9 +144,9 @@ object BiopetFlagstat extends Logging {
}
}
def addFunction(name:String, function:SAMRecord => Boolean) {
def addFunction(name: String, function: SAMRecord => Boolean) {
functionCount += 1
crossCounts = Array.ofDim[Int](functionCount,functionCount)
crossCounts = Array.ofDim[Int](functionCount, functionCount)
totalCounts = new Array[Long](functionCount)
val temp = new Array[SAMRecord => Boolean](functionCount)
for (t <- 0 until (temp.size - 1)) temp(t) = functions(t)
......@@ -167,7 +163,7 @@ object BiopetFlagstat extends Logging {
buffer.append("Number\tTotal Flags\tFraction\tName\n")
for (t <- 0 until names.size) {
val precentage = (totalCounts(t).toFloat / readsCount) * 100
buffer.append("#" + (t+1) + "\t" + totalCounts(t) + "\t" + f"$precentage%.4f" + "%\t" + names(t) + "\n")
buffer.append("#" + (t + 1) + "\t" + totalCounts(t) + "\t" + f"$precentage%.4f" + "%\t" + names(t) + "\n")
}
buffer.append("\n")
......@@ -177,22 +173,22 @@ object BiopetFlagstat extends Logging {
return buffer.toString
}
def crossReport(fraction:Boolean = false): String = {
def crossReport(fraction: Boolean = false): String = {
val buffer = new StringBuilder
for (t <- 0 until names.size) // Header for table
buffer.append("\t#" + (t+1))
buffer.append("\t#" + (t + 1))