/** Makes a new VariantContext with only the desired samples. */ private static VariantContext subsetToSamplesWithOriginalAnnotations(final VariantContext ctx, final Set<String> samples) { final VariantContextBuilder builder = new VariantContextBuilder(ctx); final GenotypesContext newGenotypes = ctx.getGenotypes().subsetToSamples(samples); builder.alleles(ctx.getAlleles()); return builder.genotypes(newGenotypes).make(); } }
private void calculateGenotypeCounts() { if ( genotypeCounts == null ) { genotypeCounts = new int[GenotypeType.values().length]; for ( final Genotype g : getGenotypes() ) { genotypeCounts[g.getType().ordinal()]++; } } }
private final void fullyDecodeGenotypes(final VariantContextBuilder builder, final VCFHeader header) { final GenotypesContext gc = new GenotypesContext(); for ( final Genotype g : getGenotypes() ) { gc.add(fullyDecodeGenotypes(g, header)); } builder.genotypesNoValidation(gc); }
static private String anchorFromVc(final VariantContext vc) { final Genotype genotype = vc.getGenotype(0); if (genotype == null || !genotype.hasExtendedAttribute(VCFConstants.PHASE_SET_KEY)) { return SYNTHETIC_PHASESET_PREFIX + "_" + vc.getContig() + "_" + vc.getStart(); } else { return PHASESET_PREFIX + "_" + vc.getContig() + "_" + genotype.getExtendedAttribute(VCFConstants.PHASE_SET_KEY); } }
/** * @param other VariantContext whose alleles to compare against * @return true if this VariantContext has the same alleles (both ref and alts) as other, * regardless of ordering. Otherwise returns false. */ public boolean hasSameAllelesAs ( final VariantContext other ) { return hasSameAlternateAllelesAs(other) && other.getReference().equals(getReference(), false); }
/** * @return true if the alleles indicate a simple deletion (i.e., a single alt allele that is Null) */ public boolean isSimpleDeletion() { // can't just call !isSimpleInsertion() because of complex indels return isSimpleIndel() && getAlternateAllele(0).length() == 1; }
/** * @param sample the sample name * * @return the Genotype associated with the given sample in this context or null if the sample is not in this context */ public Genotype getGenotype(String sample) { return getGenotypes().get(sample); }
/** * Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing * @return null or a GenotypesLikelihood object for this sample's PL field */ public GenotypeLikelihoods getLikelihoods() { return hasLikelihoods() ? GenotypeLikelihoods.fromPLs(getPL()) : null; }
/** * @return The allele sharing the same bases as this byte[], or null if no such allele is present. */ public Allele getAllele(byte[] allele) { return Allele.getMatchingAllele(getAlleles(), allele); }
/** * Tells this builder that the resulting VariantContext should use a GenotypeContext containing genotypes * * Note that genotypes can be null -> meaning there are no genotypes * * @param genotypes */ public VariantContextBuilder genotypes(final Collection<Genotype> genotypes) { return genotypes(GenotypesContext.copy(genotypes)); }
/** * Genotype-specific functions -- how many het calls are there in the genotypes? * * @return number of het calls */ public int getHetCount() { calculateGenotypeCounts(); return genotypeCounts[GenotypeType.HET.ordinal()]; }
@Override protected synchronized void ensureSampleOrdering() { if ( ! loaded ) { decode(); // will load up all of the necessary data } else { super.ensureSampleOrdering(); } }
/** Makes a new VariantContext with only the desired samples. */ private static VariantContext subsetToSamplesWithOriginalAnnotations(final VariantContext ctx, final Set<String> samples) { final VariantContextBuilder builder = new VariantContextBuilder(ctx); final GenotypesContext newGenotypes = ctx.getGenotypes().subsetToSamples(samples); builder.alleles(ctx.getAlleles()); return builder.genotypes(newGenotypes).make(); } }
static private String anchorFromVc(final VariantContext vc) { final Genotype genotype = vc.getGenotype(0); if (genotype == null || !genotype.hasExtendedAttribute(VCFConstants.PHASE_SET_KEY)) { return SYNTHETIC_PHASESET_PREFIX + "_" + vc.getContig() + "_" + vc.getStart(); } else { return PHASESET_PREFIX + "_" + vc.getContig() + "_" + genotype.getExtendedAttribute(VCFConstants.PHASE_SET_KEY); } }
private void calculateGenotypeCounts() { if ( genotypeCounts == null ) { genotypeCounts = new int[GenotypeType.values().length]; for ( final Genotype g : getGenotypes() ) { genotypeCounts[g.getType().ordinal()]++; } } }
private final void fullyDecodeGenotypes(final VariantContextBuilder builder, final VCFHeader header) { final GenotypesContext gc = new GenotypesContext(); for ( final Genotype g : getGenotypes() ) { gc.add(fullyDecodeGenotypes(g, header)); } builder.genotypesNoValidation(gc); }
/** * Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing * @return null or a GenotypesLikelihood object for this sample's PL field */ public GenotypeLikelihoods getLikelihoods() { return hasLikelihoods() ? GenotypeLikelihoods.fromPLs(getPL()) : null; }
/** * @return The allele sharing the same bases as this byte[], or null if no such allele is present. */ public Allele getAllele(byte[] allele) { return Allele.getMatchingAllele(getAlleles(), allele); }
private void calculateGenotypeCounts() { if ( genotypeCounts == null ) { genotypeCounts = new int[GenotypeType.values().length]; for ( final Genotype g : getGenotypes() ) { genotypeCounts[g.getType().ordinal()]++; } } }
private final void fullyDecodeGenotypes(final VariantContextBuilder builder, final VCFHeader header) { final GenotypesContext gc = new GenotypesContext(); for ( final Genotype g : getGenotypes() ) { gc.add(fullyDecodeGenotypes(g, header)); } builder.genotypesNoValidation(gc); }