private VariantContext getMatchingSnpEffRecord ( List<VariantContext> snpEffRecords, VariantContext vc ) { for ( VariantContext snpEffRecord : snpEffRecords ) { if ( snpEffRecord.hasSameAlternateAllelesAs(vc) && snpEffRecord.getReference().equals(vc.getReference()) ) { return snpEffRecord; } } return null; }
public String get(VariantContext vc) { StringBuilder x = new StringBuilder(); x.append(vc.getReference().getDisplayString()); return x.toString(); } });
/** * @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); }
/** * @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); }
public static boolean allelesAreSubset(VariantContext vc1, VariantContext vc2) { // if all alleles of vc1 are a contained in alleles of vc2, return true if (!vc1.getReference().equals(vc2.getReference())) return false; for (final Allele a :vc1.getAlternateAlleles()) { if (!vc2.getAlternateAlleles().contains(a)) return false; } return true; }
static private AlleleMapper resolveIncompatibleAlleles(final Allele refAllele, final VariantContext vc, final LinkedHashSet<Allele> allAlleles) { if ( refAllele.equals(vc.getReference()) ) return new AlleleMapper(vc); else { final Map<Allele, Allele> map = createAlleleMapping(refAllele, vc, allAlleles); map.put(vc.getReference(), refAllele); return new AlleleMapper(map); } }
getters.put("EVENTLENGTH", new Getter() { public String get(VariantContext vc) { int maxLength = 0; for ( final Allele a : vc.getAlternateAlleles() ) { final int length = a.length() - vc.getReference().length(); if( Math.abs(length) > Math.abs(maxLength) ) { maxLength = length; } } return Integer.toString(maxLength); }}); getters.put("QUAL", new Getter() { public String get(VariantContext vc) { return Double.toString(vc.getPhredScaledQual()); } });
private void calculatePairwiseTiTv(VariantContext vc) { for ( Allele alt : vc.getAlternateAlleles() ) { if ( GATKVariantContextUtils.isTransition(vc.getReference(), alt) ) nTi++; else nTv++; } }
/** * @return true if the alleles indicate a simple insertion (i.e., the reference allele is Null) */ public boolean isSimpleInsertion() { // can't just call !isSimpleDeletion() because of complex indels return isSimpleIndel() && getReference().length() == 1; }
/** * @return true if the alleles indicate a simple insertion (i.e., the reference allele is Null) */ public boolean isSimpleInsertion() { // can't just call !isSimpleDeletion() because of complex indels return isSimpleIndel() && getReference().length() == 1; }
@Override protected Map<String, Object> calculateAnnotationFromStratifiedContexts(final Map<String, AlignmentContext> stratifiedContexts, final VariantContext vc){ final int[][] tableNoFiltering = getSNPContingencyTable(stratifiedContexts, vc.getReference(), vc.getAlternateAlleles(), -1, MIN_COUNT); final int[][] tableFiltering = getSNPContingencyTable(stratifiedContexts, vc.getReference(), vc.getAlternateAlleles(), MIN_QUAL_FOR_FILTERED_TEST, MIN_COUNT); if (ENABLE_DEBUGGING) { StrandBiasTableUtils.printTable("unfiltered", tableNoFiltering); StrandBiasTableUtils.printTable("filtered", tableFiltering); } return pValueAnnotationForBestTable(tableFiltering, tableNoFiltering); }
/** * Create a unique identifier given the variant context * * @param vc the variant context * @return non-null String */ private static String createUniqueID(final VariantContext vc) { return String.format("%d_%s_%s", vc.getStart(), vc.getReference().getDisplayString(), vc.getAlternateAllele(0).getDisplayString()); // return base + "_0," + base + "_1"; }
private Double annotateWithPileup(final AlignmentContext stratifiedContext, final VariantContext vc) { final HashMap<Byte, MutableInt> alleleCounts = new HashMap<>(); for ( final Allele allele : vc.getAlleles() ) alleleCounts.put(allele.getBases()[0], new MutableInt(0)); for ( final byte base : stratifiedContext.getBasePileup().getBases() ) { if ( alleleCounts.containsKey(base) ) alleleCounts.get(base).increment(); } final int refCount = alleleCounts.get(vc.getReference().getBases()[0]).intValue(); final int altCount = alleleCounts.get(vc.getAlternateAllele(0).getBases()[0]).intValue(); return (refCount + altCount == 0) ? null : ((double) refCount) / (refCount + altCount); }
/** * @return true if the alleles indicate a simple indel, false otherwise. */ public boolean isSimpleIndel() { return getType() == Type.INDEL // allelic lengths differ && isBiallelic() // exactly 2 alleles && getReference().length() > 0 // ref is not null or symbolic && getAlternateAllele(0).length() > 0 // alt is not null or symbolic && getReference().getBases()[0] == getAlternateAllele(0).getBases()[0] // leading bases match for both alleles && (getReference().length() == 1 || getAlternateAllele(0).length() == 1); }
/** * @return true if the alleles indicate a simple indel, false otherwise. */ public boolean isSimpleIndel() { return getType() == Type.INDEL // allelic lengths differ && isBiallelic() // exactly 2 alleles && getReference().length() > 0 // ref is not null or symbolic && getAlternateAllele(0).length() > 0 // alt is not null or symbolic && getReference().getBases()[0] == getAlternateAllele(0).getBases()[0] // leading bases match for both alleles && (getReference().length() == 1 || getAlternateAllele(0).length() == 1); }
/** * Genotype-specific functions -- are the genotypes monomorphic w.r.t. to the alleles segregating at this * site? That is, is the number of alternate alleles among all fo the genotype == 0? * * @return true if it's monomorphic */ public boolean isMonomorphicInSamples() { if ( monomorphic == null ) monomorphic = ! isVariant() || (hasGenotypes() && getCalledChrCount(getReference()) == getCalledChrCount()); return monomorphic; }
/** * Genotype-specific functions -- are the genotypes monomorphic w.r.t. to the alleles segregating at this * site? That is, is the number of alternate alleles among all fo the genotype == 0? * * @return true if it's monomorphic */ public boolean isMonomorphicInSamples() { if ( monomorphic == null ) monomorphic = ! isVariant() || (hasGenotypes() && getCalledChrCount(getReference()) == getCalledChrCount()); return monomorphic; }
public static BaseUtils.BaseSubstitutionType getSNPSubstitutionType(VariantContext context) { if (!context.isSNP() || !context.isBiallelic()) throw new IllegalStateException("Requested SNP substitution type for bialleic non-SNP " + context); return BaseUtils.SNPSubstitutionType(context.getReference().getBases()[0], context.getAlternateAllele(0).getBases()[0]); }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }