### Question:
AlleleStatsCalculator { public VariantStatistics calculateStats(AlleleCountPosition position, Set<Integer> samples, Variant variant) { return calculateStats(position, samples, variant, null); } AlleleStatsCalculator(Collection<Integer> indxedSamples); boolean isCalculateHardyWeinberg(); void setCalculateHardyWeinberg(boolean calculateHardyWeinberg); VariantStatistics calculateStats(AlleleCountPosition position, Set<Integer> samples, Variant variant); VariantStatistics calculateStats(AlleleCountPosition position, Set<Integer> samples, Variant variant, Consumer<AlleleCountPosition> checkFilteredObject); static VariantHardyWeinbergStats calcHardyWeinberg(Map<Genotype, Integer> genotypesCount); static double calcHw(Map<String, Integer> gtCounts); void addGenotypeCount(VariantStatistics stats, int homRef, Set<Integer> noCalls, AlleleCountPosition currCount, Variant variant);  }### Answer:
@Test public void calculateStats() throws Exception { this.ref = HBaseAlleleCalculatorTest.getVariant("Y:123:A:G", "2", 2, "S2", "0", HBaseAlleleCalculatorTest.map("FILTER", "not-pass")); this.snv = HBaseAlleleCalculatorTest.getVariant("Y:123:A:G", "2", 1, "S1", "1", HBaseAlleleCalculatorTest.map("FILTER", "not-pass")); this.singleStudyConfiguration = new StudyConfiguration(2, "2"); this.singleStudyConfiguration.setIndexedFiles(new LinkedHashSet<>(Arrays.asList(1, 2))); this.singleStudyConfiguration.setSampleIds(HBaseAlleleCalculatorTest.mapObj("S2", 2, "S1", 1)); this.singleStudyConfiguration.setFileIds(HBaseAlleleCalculatorTest.mapObj("file1", 1, "file2", 2)); this.singleStudyConfiguration.setSamplesInFiles(HBaseAlleleCalculatorTest.mapObj( 2, new LinkedHashSet<>(Collections.singleton(2)), 1, new LinkedHashSet<>(Collections.singleton(1)))); Configuration conf = new Configuration(); VariantTableHelper.setInputTableName(conf, "input"); VariantTableHelper.setOutputTableName(conf, "output"); VariantTableHelper.setStudyId(conf, 2); this.variantTableHelper = new VariantTableHelper(conf); variantConverter = new HBaseAlleleCountsToVariantConverter(this.variantTableHelper, this.singleStudyConfiguration); this.variantConverter.setReturnSampleIds(Arrays.asList(1, 2)); this.calculator = new HBaseAlleleCalculator("2", HBaseAlleleCalculatorTest.mapObj("S2", 2, "S1", 1)); calculator.addVariant(snv); calculator.addVariant(ref); AlleleCountPosition validate = validate(new HashSet<Integer>(Arrays.asList(2)), snv, Collections.emptyMap(), HBaseAlleleCalculatorTest.mapObj(1, new HashSet<>(Arrays.asList(2)))); Variant variant = convertBack(this.snv, validate); System.out.println("snv = " + snv.getImpl()); equalsGT("S1", "1", variant); equalsGT("S2", "0", variant); AlleleStatsCalculator calculator = new AlleleStatsCalculator(Arrays.asList(1, 2)); VariantStats stats = calculator.calculateStats(validate, new HashSet<>(Arrays.asList(1, 2)), variant); System.out.println("stats = " + stats); assertEquals(1, stats.getRefAlleleCount().intValue()); assertEquals(1, stats.getAltAlleleCount().intValue()); }