Commit e70a3c2e authored by pjvan_thof's avatar pjvan_thof

Fixed path in stats.json

parent 3b61a8de
...@@ -17,11 +17,10 @@ package nl.lumc.sasc.biopet.tools.vcfstats ...@@ -17,11 +17,10 @@ package nl.lumc.sasc.biopet.tools.vcfstats
import java.io.{File, FileOutputStream, IOException, PrintWriter} import java.io.{File, FileOutputStream, IOException, PrintWriter}
import nl.lumc.sasc.biopet.tools.vcfstats.Stats.plotHeatmap import nl.lumc.sasc.biopet.tools.vcfstats.Stats.plotHeatmap
import nl.lumc.sasc.biopet.tools.vcfstats.VcfStats.{getClass, logger, sampleDistributions} import nl.lumc.sasc.biopet.tools.vcfstats.VcfStats.logger
import scala.collection.mutable
import nl.lumc.sasc.biopet.utils.{ConfigUtils, sortAnyAny} import nl.lumc.sasc.biopet.utils.{ConfigUtils, sortAnyAny}
import scala.collection.mutable
import scala.sys.process.{Process, ProcessLogger} import scala.sys.process.{Process, ProcessLogger}
/** /**
...@@ -161,26 +160,32 @@ case class Stats(generalStats: mutable.Map[String, mutable.Map[Any, Int]] = muta ...@@ -161,26 +160,32 @@ case class Stats(generalStats: mutable.Map[String, mutable.Map[Any, Int]] = muta
def writeAllOutput(outputDir: File, def writeAllOutput(outputDir: File,
samples: List[String], samples: List[String],
genotypeFields: List[String] = Nil, genotypeFields: List[String],
infoFields: List[String] = Nil, infoFields: List[String],
sampleDistributions: List[String] = Nil): Unit = { sampleDistributions: List[String],
contig: Option[String]): Unit = {
outputDir.mkdirs() outputDir.mkdirs()
this.writeToFile(new File(outputDir, "stats.json"), this.writeToFile(new File(outputDir, "stats.json"),
samples, samples,
genotypeFields, genotypeFields,
infoFields, infoFields,
sampleDistributions) sampleDistributions,
contig)
writeOverlap(outputDir, samples) writeOverlap(outputDir, samples)
} }
def writeToFile(outputFile: File, def writeToFile(outputFile: File,
samples: List[String], samples: List[String],
genotypeFields: List[String] = Nil, genotypeFields: List[String],
infoFields: List[String] = Nil, infoFields: List[String],
sampleDistributions: List[String] = Nil): Unit = { sampleDistributions: List[String],
contig: Option[String]): Unit = {
val allWriter = new PrintWriter(outputFile) val allWriter = new PrintWriter(outputFile)
val json = ConfigUtils.mapToJson( val map = this.getStatsAsMap(samples, genotypeFields, infoFields, sampleDistributions)
this.getStatsAsMap(samples, genotypeFields, infoFields, sampleDistributions)) val json = contig match {
case Some(c) => ConfigUtils.mapToJson(Map("contigs" -> Map(c -> map)))
case _ => ConfigUtils.mapToJson(Map("total" -> map))
}
allWriter.println(json.nospaces) allWriter.println(json.nospaces)
allWriter.close() allWriter.close()
} }
......
...@@ -89,7 +89,8 @@ object VcfStats extends ToolCommand { ...@@ -89,7 +89,8 @@ object VcfStats extends ToolCommand {
samples, samples,
adGenotypeTags, adGenotypeTags,
adInfoTags, adInfoTags,
sampleDistributions)) sampleDistributions,
None))
regionStats regionStats
.flatMap(_._2) .flatMap(_._2)
...@@ -100,7 +101,8 @@ object VcfStats extends ToolCommand { ...@@ -100,7 +101,8 @@ object VcfStats extends ToolCommand {
samples, samples,
adGenotypeTags, adGenotypeTags,
adInfoTags, adInfoTags,
sampleDistributions) sampleDistributions,
Some(k))
} }
regionStats.unpersist() regionStats.unpersist()
...@@ -159,7 +161,8 @@ object VcfStats extends ToolCommand { ...@@ -159,7 +161,8 @@ object VcfStats extends ToolCommand {
samples, samples,
adGenotypeTags, adGenotypeTags,
adInfoTags, adInfoTags,
sampleDistributions) sampleDistributions,
Some(bedRecord.chr))
None None
} }
} else Future.successful(Some(bedRecord.chr -> stats)) } else Future.successful(Some(bedRecord.chr -> stats))
......
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