Commit 16fafb4e authored by Peter van 't Hof's avatar Peter van 't Hof

Format fixes

parent 065bf160
......@@ -16,13 +16,13 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.File
import nl.lumc.sasc.biopet.core.annotations.{AnnotationRefFlat, RibosomalRefFlat}
import nl.lumc.sasc.biopet.core.annotations.{ AnnotationRefFlat, RibosomalRefFlat }
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{BiopetFifoPipe, PipelineCommand, Reference, SampleLibraryTag}
import nl.lumc.sasc.biopet.extensions.bedtools.{BedtoolsCoverage, BedtoolsIntersect, BedtoolsSort}
import nl.lumc.sasc.biopet.core.{ BiopetFifoPipe, PipelineCommand, Reference, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.bedtools.{ BedtoolsCoverage, BedtoolsIntersect, BedtoolsSort }
import nl.lumc.sasc.biopet.extensions.picard._
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsFlagstat
import nl.lumc.sasc.biopet.extensions.tools.{BamStats, BiopetFlagstat}
import nl.lumc.sasc.biopet.extensions.tools.{ BamStats, BiopetFlagstat }
import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.intervals.BedCheck
......
......@@ -183,8 +183,9 @@ object BammetricsReport extends ReportBuilder {
)
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel)
.map { case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
.map {
case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "insert_size"), "insert_size")
......@@ -219,8 +220,9 @@ object BammetricsReport extends ReportBuilder {
)
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel)
.map { case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
.map {
case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "coverage"), "coverage")
......@@ -255,8 +257,9 @@ object BammetricsReport extends ReportBuilder {
)
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel)
.map { case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
.map {
case (sample, lib) =>
getTableFromSummary(summary, paths(lib.map(l => s"$sample-$l").getOrElse(sample)), Some(sample), lib)
}
writeTableToTsv(tsvFile, mergeTables(tables.toArray, "normalized_position"), "normalized_position")
......@@ -281,10 +284,11 @@ object BammetricsReport extends ReportBuilder {
paths: Map[String, List[String]],
sampleId: Option[String] = None,
libId: Option[String] = None): Map[String, Array[Any]] = {
val pathValues: Map[String, Array[Any]] = paths.map { case (key, path) =>
val value = summary.getValueAsArray(sampleId, libId, path:_*)
require(value.isDefined, s"Sample: $sampleId, library: $libId on path: '${path.mkString(",")}' does not exist in summary")
key -> value.get
val pathValues: Map[String, Array[Any]] = paths.map {
case (key, path) =>
val value = summary.getValueAsArray(sampleId, libId, path: _*)
require(value.isDefined, s"Sample: $sampleId, library: $libId on path: '${path.mkString(",")}' does not exist in summary")
key -> value.get
}
require(pathValues.map(_._2.size).toList.distinct == 1, s"Arrays in summary does not have the same number of values, $paths")
pathValues
......@@ -303,8 +307,9 @@ object BammetricsReport extends ReportBuilder {
val keys = table.keys.filterNot(_ == firstColumn).toList.sorted
val writer = new PrintWriter(tsvFile)
writer.println((firstColumn :: keys).mkString("\t"))
table(firstColumn).zipWithIndex.foreach { case (c, i) =>
writer.println((c :: keys.map(x => table(x)(i))).mkString("\t"))
table(firstColumn).zipWithIndex.foreach {
case (c, i) =>
writer.println((c :: keys.map(x => table(x)(i))).mkString("\t"))
}
writer.close()
}
......
......@@ -3,7 +3,7 @@ package nl.lumc.sasc.biopet.extensions.tools
import java.io.File
import nl.lumc.sasc.biopet.core.summary.Summarizable
import nl.lumc.sasc.biopet.core.{Reference, ToolCommandFunction}
import nl.lumc.sasc.biopet.core.{ Reference, ToolCommandFunction }
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.Input
......@@ -12,8 +12,8 @@ import scala.collection.JavaConversions._
import scala.io.Source
/**
* Created by pjvanthof on 18/11/2016.
*/
* Created by pjvanthof on 18/11/2016.
*/
class BamStats(val root: Configurable) extends ToolCommandFunction with Reference with Summarizable {
def toolObject = nl.lumc.sasc.biopet.tools.bamstats.BamStats
......@@ -35,7 +35,7 @@ class BamStats(val root: Configurable) extends ToolCommandFunction with Referenc
def getOutputFile(name: String, contig: Option[String] = None): File = {
contig match {
case Some(contig) => new File(outputDir, "contigs" + File.separator + contig + File.separator + name)
case _ => new File(outputDir, name)
case _ => new File(outputDir, name)
}
}
......@@ -57,7 +57,6 @@ class BamStats(val root: Configurable) extends ToolCommandFunction with Referenc
optional("--binSize", binSize) +
optional("--threadBinSize", threadBinSize)
def summaryFiles: Map[String, File] = Map()
def summaryStats: Map[String, Any] = Map(
......
......@@ -80,7 +80,7 @@ class Summary(file: File) {
/** Get value on nested path with prefix depending is sampleId and/or libId is None or not */
def getValueAsArray(sampleId: Option[String], libId: Option[String], path: String*): Option[Array[Any]] = {
this.getValue(sampleId, libId, path:_*).map(ConfigUtils.any2list(_).toArray)
this.getValue(sampleId, libId, path: _*).map(ConfigUtils.any2list(_).toArray)
}
/**
......
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