Commit 1efcf0c5 authored by Peter van 't Hof's avatar Peter van 't Hof

Merge stats.json files

parent df582f1a
......@@ -6,7 +6,7 @@ import java.net.URLClassLoader
import htsjdk.variant.variantcontext.{Genotype, VariantContext}
import htsjdk.variant.vcf.VCFFileReader
import nl.lumc.sasc.biopet.utils.intervals.{BedRecord, BedRecordList}
import nl.lumc.sasc.biopet.utils.{FastaUtils, ToolCommand, VcfUtils}
import nl.lumc.sasc.biopet.utils._
import org.apache.spark.{SparkConf, SparkContext}
import scala.collection.JavaConversions._
......@@ -108,6 +108,19 @@ object VcfStats extends ToolCommand {
Await.result(totalStats, Duration.Inf)
val completeStatsJson = regions
.flatMap(_.map(_.chr))
.foldLeft(ConfigUtils.fileToConfigMap(new File(cmdArgs.outputDir, "stats.json"))) {
case (map, contig) =>
val contigMap = ConfigUtils.fileToConfigMap(
new File(cmdArgs.outputDir,
"contigs" + File.separator + contig + File.separator + "stats.json"))
ConfigUtils.mergeMaps(map, contigMap)
}
IoUtils.writeLinesToFile(new File(cmdArgs.outputDir, "stats.json"),
ConfigUtils.mapToJson(completeStatsJson).nospaces :: Nil)
sc.stop
logger.info("Done")
}
......
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