/** * @return true if the context has associated genotypes */ public boolean hasGenotypes() { return ! genotypes.isEmpty(); }
@Override public boolean isEmpty() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know if the genotypes context is empty return loaded ? super.isEmpty() : nUnparsedGenotypes == 0; }
@Override public boolean isEmpty() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know if the genotypes context is empty return loaded ? super.isEmpty() : nUnparsedGenotypes == 0; }
@Override public boolean isEmpty() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know if the genotypes context is empty return loaded ? super.isEmpty() : nUnparsedGenotypes == 0; }
/** * @return true if the context has associated genotypes */ public boolean hasGenotypes() { return ! genotypes.isEmpty(); }
/** * @return true if the context has associated genotypes */ public boolean hasGenotypes() { return ! genotypes.isEmpty(); }
/** * Subset the Variant Context to the specific set of alleles passed in (pruning the PLs appropriately) * * @param vc variant context with genotype likelihoods * @param allelesToUse which alleles from the vc are okay to use; *** must be in the same relative order as those in the original VC *** * @param assignGenotypes assignment strategy for the (subsetted) PLs * @return a new non-null GenotypesContext with subsetted alleles */ public static GenotypesContext subsetAlleles(final VariantContext vc, final List<Allele> allelesToUse, final GenotypeAssignmentMethod assignGenotypes) { if ( vc == null ) throw new IllegalArgumentException("the VariantContext cannot be null"); if ( allelesToUse == null ) throw new IllegalArgumentException("the alleles to use cannot be null"); if ( allelesToUse.isEmpty() ) throw new IllegalArgumentException("must have alleles to use"); if ( allelesToUse.get(0).isNonReference() ) throw new IllegalArgumentException("First allele must be the reference allele"); if ( allelesToUse.size() == 1 ) throw new IllegalArgumentException("Cannot subset to only 1 alt allele"); // optimization: if no input genotypes, just exit if (vc.getGenotypes().isEmpty()) return GenotypesContext.create(); // find the likelihoods indexes to use from the used alternate alleles final List<List<Integer>> likelihoodIndexesToUse = determineLikelihoodIndexesToUse(vc, allelesToUse); // find the strand allele count indexes to use from the used alternate alleles final List<Integer> sacIndexesToUse = determineSACIndexesToUse(vc, allelesToUse); // create the new genotypes return createGenotypesWithSubsettedLikelihoods(vc.getGenotypes(), vc, allelesToUse, likelihoodIndexesToUse, sacIndexesToUse, assignGenotypes); }
if ( genotypes == null || genotypes.isEmpty() ) return null;
public enum GenotypeAssignmentMethod { /** * set all of the genotype GT values to NO_CALL */ SET_TO_NO_CALL, /** * set all of the genotype GT values to NO_CALL and remove annotations */ SET_TO_NO_CALL_NO_ANNOTATIONS, /** * Use the subsetted PLs to greedily assigned genotypes */ USE_PLS_TO_ASSIGN, /** * Try to match the original GT calls, if at all possible * * Suppose I have 3 alleles: A/B/C and the following samples: * * original_GT best_match to A/B best_match to A/C * S1 => A/A A/A A/A * S2 => A/B A/B A/A * S3 => B/B B/B A/A * S4 => B/C A/B A/C * S5 => C/C A/A C/C * * Basically, all alleles not in the subset map to ref. It means that het-alt genotypes
if (genotypes == null || genotypes.isEmpty()) return null;
if (!variantContext.getGenotypes().isEmpty()) { htsjdk.variant.variantcontext.Genotype gt = variantContext.getGenotypes().get(0);
if (oldGTs.isEmpty()) return oldGTs;
private final void testGenotypesContextContainsExpectedSamples(GenotypesContext gc, List<Genotype> expectedSamples) { Assert.assertEquals(gc.isEmpty(), expectedSamples.isEmpty()); Assert.assertEquals(gc.size(), expectedSamples.size());
Assert.assertEquals(modified.getGenotypes(), gc); modified = new VariantContextBuilder(cfg.vc).noGenotypes().make(); Assert.assertTrue(modified.getGenotypes().isEmpty());