Skip to content
Snippets Groups Projects
Commit 0c2b2242 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Switch to case classes

parent a4a4697f
No related branches found
No related tags found
No related merge requests found
...@@ -61,14 +61,13 @@ object VcfStats extends ToolCommand { ...@@ -61,14 +61,13 @@ object VcfStats extends ToolCommand {
*/ */
} }
/** Class to store sample to sample compare stats */ /**
class SampleToSampleStats { * Class to store sample to sample compare stats
/** Number of genotypes match with other sample */ * @param genotypeOverlap Number of genotypes match with other sample
var genotypeOverlap: Int = 0 * @param alleleOverlap Number of alleles also found in other sample
*/
/** Number of alleles also found in other sample */ case class SampleToSampleStats(var genotypeOverlap: Int = 0,
var alleleOverlap: Int = 0 var alleleOverlap: Int = 0) {
/** Add an other class */ /** Add an other class */
def +=(other: SampleToSampleStats) { def +=(other: SampleToSampleStats) {
this.genotypeOverlap += other.genotypeOverlap this.genotypeOverlap += other.genotypeOverlap
...@@ -76,14 +75,13 @@ object VcfStats extends ToolCommand { ...@@ -76,14 +75,13 @@ object VcfStats extends ToolCommand {
} }
} }
/** class to store all sample relative stats */ /**
class SampleStats { * class to store all sample relative stats
/** Stores all genotype relative stats */ * @param genotypeStats Stores all genotype relative stats
val genotypeStats: mutable.Map[String, mutable.Map[Any, Int]] = mutable.Map() * @param sampleToSample Stores sample to sample compare stats
*/
/** Stores sample to sample compare stats */ case class SampleStats(val genotypeStats: mutable.Map[String, mutable.Map[Any, Int]] = mutable.Map(),
val sampleToSample: mutable.Map[String, SampleToSampleStats] = mutable.Map() val sampleToSample: mutable.Map[String, SampleToSampleStats] = mutable.Map()) {
/** Add an other class */ /** Add an other class */
def +=(other: SampleStats): Unit = { def +=(other: SampleStats): Unit = {
for ((key, value) <- other.sampleToSample) { for ((key, value) <- other.sampleToSample) {
...@@ -98,13 +96,13 @@ object VcfStats extends ToolCommand { ...@@ -98,13 +96,13 @@ object VcfStats extends ToolCommand {
} }
} }
class Stats { /**
/** Stores are general stats */ * General stats class to store vcf stats
val generalStats: mutable.Map[String, mutable.Map[Any, Int]] = mutable.Map() * @param generalStats Stores are general stats
* @param samplesStats Stores all sample/genotype specific stats
/** Stores all sample/genotype specific stats */ */
val samplesStats: mutable.Map[String, SampleStats] = mutable.Map() case class Stats(val generalStats: mutable.Map[String, mutable.Map[Any, Int]] = mutable.Map(),
val samplesStats: mutable.Map[String, SampleStats] = mutable.Map()) {
/** Add an other class */ /** Add an other class */
def +=(other: Stats): Stats = { def +=(other: Stats): Stats = {
for ((key, value) <- other.samplesStats) { for ((key, value) <- other.samplesStats) {
...@@ -207,8 +205,9 @@ object VcfStats extends ToolCommand { ...@@ -207,8 +205,9 @@ object VcfStats extends ToolCommand {
val stats = createStats val stats = createStats
logger.info("Starting on: " + interval) logger.info("Starting on: " + interval)
for (record <- reader.query(interval.getSequence, interval.getStart, interval.getEnd) for (
if record.getStart <= interval.getEnd) { record <- reader.query(interval.getSequence, interval.getStart, interval.getEnd) if record.getStart <= interval.getEnd
) {
mergeNestedStatsMap(stats.generalStats, checkGeneral(record)) mergeNestedStatsMap(stats.generalStats, checkGeneral(record))
for (sample1 <- samples) yield { for (sample1 <- samples) yield {
val genotype = record.getGenotype(sample1) val genotype = record.getGenotype(sample1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment