public GenotypesContext calculatePosteriorGLs(final VariantContext vc){ final GenotypesContext genotypesContext = GenotypesContext.copy(vc.getGenotypes()); for (final Sample sample : trios) { Genotype mother = vc.getGenotype(sample.getMaternalID()); Genotype father = vc.getGenotype(sample.getPaternalID()); Genotype child = vc.getGenotype(sample.getID()); //Keep only trios and parent/child pairs if(mother == null && father == null || child == null) { logger.warn("Null genotypes in variant: "+vc.toStringDecodeGenotypes()); continue; } final ArrayList<Genotype> trioGenotypes = new ArrayList<>(3); updateFamilyGenotypes(vc, mother, father, child, trioGenotypes); //replace uses sample names to match genotypes, so order doesn't matter if (!trioGenotypes.isEmpty()) { genotypesContext.replace(trioGenotypes.get(0)); genotypesContext.replace(trioGenotypes.get(1)); genotypesContext.replace(trioGenotypes.get(2)); } } return genotypesContext; }
@Test(enabled = true, dataProvider = "GenotypesContextProvider") public void testReplace(GenotypesContextProvider cfg) { int n = cfg.makeContext().size(); for ( int i = 0; i < n; i++ ) { GenotypesContext gc = cfg.makeContext(); Genotype toReplace = gc.get(i); Genotype replacement = GenotypeBuilder.create(toReplace.getSampleName(), Arrays.asList(Aref, Aref)); gc.replace(replacement); ArrayList<Genotype> l = new ArrayList<Genotype>(cfg.initialSamples); l.set(i, replacement); Assert.assertEquals(replacement, gc.get(i)); testGenotypesContextContainsExpectedSamples(gc, l); } }
genotypesContext.replace(phasedChild); if(mother != null){ genotypesContext.replace(phasedMother); if(father != null){ genotypesContext.replace(phasedFather); updateTrioMetricsCounters(phasedMother,phasedFather,phasedChild,mvCount,metricsCounters); mvfLine = String.format("%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", genotypesContext.replace(phasedFather); updatePairMetricsCounters(phasedFather,phasedChild,mvCount,metricsCounters); if(!(phasedFather.getType()==father.getType() && phasedChild.getType()==child.getType()))