@Override public Map<String, Object> annotate( final RefMetaDataTracker tracker, final AnnotatorCompatible walker, final ReferenceContext ref, final Map<String, AlignmentContext> stratifiedContexts, final VariantContext vc, final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) { final GenotypesContext genotypes = vc.getGenotypes(); if (genotypes == null || genotypes.size() < MIN_SAMPLES) { if (!warningLogged) { logger.warn("Too few genotypes"); warningLogged = true; } return null; } int refCount = 0; int hetCount = 0; int homCount = 0; for (final Genotype g : genotypes) { if (g.isNoCall()) continue; // TODO - fix me: // Right now we just ignore genotypes that are not confident, but this throws off // our HW ratios. More analysis is needed to determine the right thing to do when // the genotyper cannot decide whether a given sample is het or hom var. if (g.getLog10PError() > MIN_LOG10_PERROR) continue; if (g.isHomRef()) refCount++; else if (g.isHet()) hetCount++; else homCount++; } if (refCount + hetCount + homCount == 0) return null; double pvalue = HardyWeinbergCalculation.hwCalculate(refCount, hetCount, homCount); // System.out.println(refCount + " " + hetCount + " " + homCount + " " + pvalue); Map<String, Object> map = new HashMap<>(); map.put(getKeyNames().get(0), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue))); return map; }