static boolean alleleSegregationIsKnown(Genotype gt1, Genotype gt2) { if (gt1.getPloidy() != gt2.getPloidy()) return false; /* If gt2 is phased or hom, then could even be MERGED with gt1 [This is standard]. HOWEVER, EVEN if this is not the case, but gt1.isHom(), it is trivially known that each of gt2's alleles segregate with the single allele type present in gt1. */ return (gt2.isPhased() || gt2.isHom() || gt1.isHom()); }
static PhaseAndQuality calcPhaseForMergedGenotypes(Genotype gt1, Genotype gt2) { if (gt2.isPhased() || gt2.isHom()) return new PhaseAndQuality(gt1); // maintain the phase of gt1 if (!gt1.isHom()) throw new ReviewedStingException( "alleleSegregationIsKnown(gt1, gt2) implies: gt2.genotypesArePhased() || gt2.isHom() || gt1.isHom()"); /* We're dealing with: gt1.isHom(), gt2.isHet(), !gt2.genotypesArePhased(); so, the merged (het) Genotype is not phased relative to the previous Genotype For example, if we're merging the third Genotype with the second one: 0/1 1|1 0/1 Then, we want to output: 0/1 1/2 */ return new PhaseAndQuality(gt2); // maintain the phase of gt2 [since !gt2.genotypesArePhased()] }