Commit 2a838ba2 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Changes fraction of bins

parent c9ef89f2
...@@ -15,6 +15,8 @@ import scala.io.Source ...@@ -15,6 +15,8 @@ import scala.io.Source
import scala.sys.process.{ Process, ProcessLogger } import scala.sys.process.{ Process, ProcessLogger }
import htsjdk.samtools.util.Interval import htsjdk.samtools.util.Interval
import scala.util.Random
/** /**
* Created by pjvan_thof on 1/10/15. * Created by pjvan_thof on 1/10/15.
*/ */
...@@ -326,8 +328,9 @@ object VcfStats extends ToolCommand { ...@@ -326,8 +328,9 @@ object VcfStats extends ToolCommand {
logger.info("total: " + variantCounter + " rows processed, " + fraction + "% done") logger.info("total: " + variantCounter + " rows processed, " + fraction + "% done")
} }
val chrStats = for (intervals <- intervals.grouped(intervals.size / 10).toList.par) yield { // Triple for loop to not keep all bins in memory
val chunkStats = for (intervals <- intervals.grouped(10)) yield { val stats = (for (intervals <- Random.shuffle(intervals).grouped(intervals.size / 4).toList.par) yield {
val chunkStats = for (intervals <- intervals.grouped(25)) yield {
val binStats = for (interval <- intervals.par) yield { val binStats = for (interval <- intervals.par) yield {
val reader = new VCFFileReader(commandArgs.inputFile, true) val reader = new VCFFileReader(commandArgs.inputFile, true)
var chunkCounter = 0 var chunkCounter = 0
...@@ -335,7 +338,7 @@ object VcfStats extends ToolCommand { ...@@ -335,7 +338,7 @@ object VcfStats extends ToolCommand {
logger.info("Starting on: " + interval) logger.info("Starting on: " + interval)
for ( for (
record <- reader.query(interval.getSequence, interval.getStart, interval.getEnd) record <- reader.query(interval.getSequence, interval.getStart, interval.getEnd);
if record.getStart <= interval.getEnd if record.getStart <= interval.getEnd
) { ) {
mergeNestedStatsMap(stats.generalStats, checkGeneral(record, adInfoTags)) mergeNestedStatsMap(stats.generalStats, checkGeneral(record, adInfoTags))
...@@ -366,9 +369,7 @@ object VcfStats extends ToolCommand { ...@@ -366,9 +369,7 @@ object VcfStats extends ToolCommand {
binStats.toList.fold(createStats)(_ += _) binStats.toList.fold(createStats)(_ += _)
} }
chunkStats.toList.fold(createStats)(_ += _) chunkStats.toList.fold(createStats)(_ += _)
} }).toList.fold(createStats)(_ += _)
val stats = chrStats.toList.fold(createStats)(_ += _)
logger.info("Done reading vcf records") logger.info("Done reading vcf records")
...@@ -409,7 +410,7 @@ object VcfStats extends ToolCommand { ...@@ -409,7 +410,7 @@ object VcfStats extends ToolCommand {
} }
protected def writeWiggle(intervals: List[Interval], row: String, column: String, outputFile: File, genotype: Boolean): Unit = { protected def writeWiggle(intervals: List[Interval], row: String, column: String, outputFile: File, genotype: Boolean): Unit = {
val bla = intervals.groupBy(_.getSequence).map { case (k,v) => k -> v.sortBy(_.getStart) } val bla = intervals.groupBy(_.getSequence).map { case (k, v) => k -> v.sortBy(_.getStart) }
outputFile.getParentFile.mkdirs() outputFile.getParentFile.mkdirs()
val writer = new PrintWriter(outputFile) val writer = new PrintWriter(outputFile)
writer.println("track type=wiggle_0") writer.println("track type=wiggle_0")
......
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