SampleStats.scala 1.61 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
/**
2 3 4 5 6 7 8 9 10 11 12 13 14
  * Biopet is built on top of GATK Queue for building bioinformatic
  * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
  * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
  * should also be able to execute Biopet tools and pipelines.
  *
  * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
  *
  * Contact us at: sasc@lumc.nl
  *
  * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
  * license; For commercial users or users who do not want to follow the AGPL
  * license, please contact us to obtain a separate license.
  */
15 16 17 18 19
package nl.lumc.sasc.biopet.tools.vcfstats

import scala.collection.mutable

/**
20 21 22 23 24
  * class to store all sample relative stats
  *
  * @param genotypeStats Stores all genotype relative stats
  * @param sampleToSample Stores sample to sample compare stats
  */
25
case class SampleStats(genotypeStats: mutable.Map[String, mutable.Map[Any, Int]] = mutable.Map(),
Peter van 't Hof's avatar
Peter van 't Hof committed
26
                       sampleToSample: Array[SampleToSampleStats] = Array()) {
27

28 29
  /** Add an other class */
  def +=(other: SampleStats): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
30 31 32 33
    require(other.sampleToSample.size == this.sampleToSample.size)
    val zipped = this.sampleToSample.zip(other.sampleToSample).zipWithIndex
    for (((s1, s2), i) <- zipped) {
      s1 += s2
34
    }
35 36
    for ((field, fieldMap) <- other.genotypeStats) {
      val thisField = this.genotypeStats.get(field)
Peter van 't Hof's avatar
Peter van 't Hof committed
37
      if (thisField.isDefined) Stats.mergeStatsMap(thisField.get, fieldMap)
38
      else this.genotypeStats += field -> fieldMap
39 40 41
    }
  }
}