Java Code Examples for htsjdk.variant.variantcontext.Allele#equals()

The following examples show how to use htsjdk.variant.variantcontext.Allele#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Determines the variant type based on the given reference allele and alternate allele.
 * @param refAllele The reference {@link Allele} for this variant.
 * @param altAllele The alternate {@link Allele} for this variant.
 * @return A {@link GencodeFuncotation.VariantType} representing the variation type between the given reference and alternate {@link Allele}.
 * Spanning deletions and no calls will get a type of {@link org.broadinstitute.hellbender.tools.funcotator.dataSources.gencode.GencodeFuncotation.VariantType#NA}
 */
@VisibleForTesting
static GencodeFuncotation.VariantType getVariantType( final Allele refAllele, final Allele altAllele ) {

    if ( altAllele.length() > refAllele.length() ) {
        return GencodeFuncotation.VariantType.INS;
    }
    else if (altAllele.equals(Allele.SPAN_DEL) || altAllele.equals(Allele.NO_CALL) || altAllele.isSymbolic() ) {
        return GencodeFuncotation.VariantType.NA;
    }
    else if (altAllele.length() < refAllele.length()) {
        return GencodeFuncotation.VariantType.DEL;
    }
    else {
        // We know they are the same length, now we just need to check one of them:
        switch (refAllele.length()) {
            case 1:  return GencodeFuncotation.VariantType.SNP;
            case 2:  return GencodeFuncotation.VariantType.DNP;
            case 3:  return GencodeFuncotation.VariantType.TNP;
            default: return GencodeFuncotation.VariantType.ONP;
        }
    }
}
 
Example 2
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Checks the given variant alt allele for whether it's a special case.
 * If so, will create the appropriate funcotation for that case.
 * @param variant {@link VariantContext} for the given {@code altAllele}.
 * @param altAllele The alternate {@link Allele} to be checked for special cases.
 * @param reference {@link ReferenceContext} supporting the given {@code variant}.
 * @param transcript {@link GencodeGtfTranscriptFeature} containing the given {@code variant}.
 * @return A {@link GencodeFuncotation} for the given special case alt allele, or {@code null} if the allele is not a special case.
 */
private GencodeFuncotation checkForAndCreateSpecialAlleleFuncotation(final VariantContext variant,
                                                                     final Allele altAllele,
                                                                     final ReferenceContext reference,
                                                                     final GencodeGtfTranscriptFeature transcript) {
    // If the alt allele is a spanning deletion or a symbolic allele, create an unknown funcotation:
    if (altAllele.isSymbolic() || altAllele.equals(Allele.SPAN_DEL) ) {
        return createFuncotationForSymbolicAltAllele(variant, altAllele, transcript, reference);
    }

    // If the reference allele or alternate allele contains any masked bases:
    if ( variant.getReference().getBaseString().contains(FuncotatorConstants.MASKED_ANY_BASE_STRING) || altAllele.getBaseString().contains(FuncotatorConstants.MASKED_ANY_BASE_STRING) ) {
        return createFuncotationForMaskedBases(variant, altAllele, transcript, reference);
    }

    return null;
}
 
Example 3
Source File: VariantEval.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private EvalCompMatchType doEvalAndCompMatch(final VariantContext eval, final VariantContext comp, boolean requireStrictAlleleMatch) {
    if ( comp.getType() == VariantContext.Type.NO_VARIATION || eval.getType() == VariantContext.Type.NO_VARIATION )
        // if either of these are NO_VARIATION they are LENIENT matches
        return EvalCompMatchType.LENIENT;

    if ( comp.getType() != eval.getType() )
        return EvalCompMatchType.NO_MATCH;

    // find the comp which matches both the reference allele and alternate allele from eval
    final Allele altEval = eval.getAlternateAlleles().size() == 0 ? null : eval.getAlternateAllele(0);
    final Allele altComp = comp.getAlternateAlleles().size() == 0 ? null : comp.getAlternateAllele(0);
    if ((altEval == null && altComp == null) || (altEval != null && altEval.equals(altComp) && eval.getReference().equals(comp.getReference())))
        return EvalCompMatchType.STRICT;
    else
        return requireStrictAlleleMatch ? EvalCompMatchType.NO_MATCH : EvalCompMatchType.LENIENT;
}
 
Example 4
Source File: StrandBiasUtils.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Add another read to the strand count table
 * @param bestAllele    the Allele best supported by {@param read}
 * @param read  read to add
 * @param ref   reference Allele
 * @param allAlts   the (subset of) alternate alleles for the associated variant
 * @param perAlleleValues updated to return the values including @{value read}
 */
private static void updateTable(final Allele bestAllele, final GATKRead read, final Allele ref, final List<Allele> allAlts, final ReducibleAnnotationData<List<Integer>> perAlleleValues) {

    final boolean matchesRef = bestAllele.equals(ref, true);
    final boolean matchesAnyAlt = allAlts.contains(bestAllele);

    //can happen if a read's most likely allele has been removed when --max_alternate_alleles is exceeded
    if (!( matchesRef || matchesAnyAlt )) {
        return;
    }

    final List<Integer> alleleStrandCounts;
    if (perAlleleValues.hasAttribute(bestAllele) && perAlleleValues.getAttribute(bestAllele) != null) {
        alleleStrandCounts = perAlleleValues.getAttribute(bestAllele);
    } else {
        alleleStrandCounts = new ArrayList<>();
        alleleStrandCounts.add(0,0);
        alleleStrandCounts.add(1,0);
    }

    final int strand = read.isReverseStrand() ? REVERSE : FORWARD;
    alleleStrandCounts.set(strand, alleleStrandCounts.get(strand) + 1);
    perAlleleValues.putAttribute(bestAllele, alleleStrandCounts);
}
 
Example 5
Source File: LiftoverUtils.java    From picard with MIT License 5 votes vote down vote up
private static Allele reverseComplement(final Allele oldAllele) {
    if (oldAllele.isSymbolic() || oldAllele.isNoCall() || oldAllele.equals(Allele.SPAN_DEL)) {
        return oldAllele;
    } else {
        return Allele.create(SequenceUtil.reverseComplement(oldAllele.getBaseString()), oldAllele.isReference());
    }
}
 
Example 6
Source File: HaplotypeCallerIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Helper method for testMaxAlternateAlleles
 *
 * @param vc VariantContext to check
 * @return number of alt alleles in vc, excluding NON_REF (if present)
 */
private int getNumAltAllelesExcludingNonRef( final VariantContext vc ) {
    final List<Allele> altAlleles = vc.getAlternateAlleles();
    int numAltAllelesExcludingNonRef = 0;

    for ( final Allele altAllele : altAlleles ) {
        if ( ! altAllele.equals(Allele.NON_REF_ALLELE) ) {
            ++numAltAllelesExcludingNonRef;
        }
    }

    return numAltAllelesExcludingNonRef;
}
 
Example 7
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a {@link GencodeFuncotation}s based on the given {@link Allele} with type
 * {@link GencodeFuncotation.VariantClassification#FIVE_PRIME_FLANK} or
 * {@link GencodeFuncotation.VariantClassification#THREE_PRIME_FLANK}
 *
 * @param variant The {@link VariantContext} associated with this annotation.
 * @param altAllele The alternate {@link Allele} to use for this {@link GencodeFuncotation}.
 * @param transcript {@link GencodeGtfTranscriptFeature} associated with this flank funcotation.
 * @param reference The {@link ReferenceContext} in which the given {@link Allele}s appear.
 * @param flankType {@link GencodeFuncotation.VariantClassification#FIVE_PRIME_FLANK} or
 *                  {@link GencodeFuncotation.VariantClassification#THREE_PRIME_FLANK}
 * @return A flank funcotation for the given allele
 */
private GencodeFuncotation createFlankFuncotation(final VariantContext variant, final Allele altAllele, final GencodeGtfTranscriptFeature transcript, final ReferenceContext reference, final GencodeFuncotation.VariantClassification flankType) {

    // Create a symbolic allele funcotation for the flank type, if appropriate:
    if (altAllele.isSymbolic() || altAllele.equals(Allele.SPAN_DEL) ) {
        return createFuncotationForSymbolicAltAllele(variant, altAllele, transcript, reference, flankType);
    }

    final GencodeFuncotationBuilder funcotationBuilder = new GencodeFuncotationBuilder();

    // NOTE: The reference context is ALWAYS from the + strand
    final StrandCorrectedReferenceBases referenceBases = FuncotatorUtils.createReferenceSnippet(variant.getReference(), altAllele, reference, Strand.POSITIVE, referenceWindow);
    final String referenceBasesString = referenceBases.getBaseString(Strand.POSITIVE);

    final double gcContent = calculateGcContent(variant.getReference(), altAllele, reference, gcContentWindowSizeBases);

    funcotationBuilder.setHugoSymbol(transcript.getGeneName())
            .setChromosome(variant.getContig())
            .setStart(variant.getStart())
            .setEnd(variant.getEnd())
            .setStrand(transcript.getGenomicStrand())
            .setVariantClassification(flankType)
            .setVariantType(getVariantType(variant.getReference(), altAllele))
            .setRefAllele(variant.getReference())
            .setTumorSeqAllele2(altAllele.getBaseString())
            .setGenomeChange(getGenomeChangeString(variant, altAllele))
            .setAnnotationTranscript(transcript.getTranscriptId())
            .setReferenceContext(referenceBasesString)
            .setGcContent(gcContent)
            .setNcbiBuild(ncbiBuildVersion)
            .setGeneTranscriptType(transcript.getTranscriptType());

    // Set our version:
    funcotationBuilder.setVersion(version);

    // Set our data source name:
    funcotationBuilder.setDataSourceName(getName());

    return funcotationBuilder.build();
}
 
Example 8
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a {@link GencodeFuncotation}s based on the given {@link Allele} with type
 * {@link GencodeFuncotation.VariantClassification#IGR}.
 * Reports reference bases as if they are on the {@link Strand#POSITIVE} strand.
 * @param variant The {@link VariantContext} associated with this annotation.
 * @param altAllele The alternate {@link Allele} to use for this {@link GencodeFuncotation}.
 * @param reference The {@link ReferenceContext} in which the given {@link Allele}s appear.
 * @return An IGR funcotation for the given allele.
 */
private GencodeFuncotation createIgrFuncotation(final VariantContext variant,
                                                final Allele altAllele,
                                                final ReferenceContext reference){

    final GencodeFuncotationBuilder funcotationBuilder = new GencodeFuncotationBuilder();

    // Get GC Content:
    funcotationBuilder.setGcContent( calculateGcContent( variant.getReference(), altAllele, reference, gcContentWindowSizeBases ) );

    final String alleleString = altAllele.getBaseString().isEmpty() ? altAllele.toString() : altAllele.getBaseString();

    funcotationBuilder.setVariantClassification( GencodeFuncotation.VariantClassification.IGR )
                      .setRefAllele( variant.getReference() )
                      .setTumorSeqAllele2( alleleString )
                      .setStart(variant.getStart())
                      .setEnd(variant.getEnd())
                      .setVariantType(getVariantType(variant.getReference(), altAllele))
                      .setChromosome(variant.getContig())
                      .setAnnotationTranscript(FuncotationMap.NO_TRANSCRIPT_AVAILABLE_KEY);

    if ( (!altAllele.isSymbolic()) && (!altAllele.equals(Allele.SPAN_DEL)) ) {
        funcotationBuilder.setGenomeChange(getGenomeChangeString(variant, altAllele));
    }

    funcotationBuilder.setNcbiBuild(ncbiBuildVersion);

    // Set our reference context in the the FuncotatonBuilder:
    funcotationBuilder.setReferenceContext(FuncotatorUtils.createReferenceSnippet(variant.getReference(), altAllele, reference, Strand.POSITIVE, referenceWindow).getBaseString());

    // Set our version:
    funcotationBuilder.setVersion(version);

    // Set our data source name:
    funcotationBuilder.setDataSourceName(getName());

    return funcotationBuilder.build();
}
 
Example 9
Source File: AS_FisherStrand.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Map<Allele,Double> calculateReducedData(AlleleSpecificAnnotationData<List<Integer>> combinedData) {
    final Map<Allele,Double> annotationMap = new HashMap<>();
    final Map<Allele,List<Integer>> perAlleleData = combinedData.getAttributeMap();
    final List<Integer> refStrandCounts = perAlleleData.get(combinedData.getRefAllele());
    for (final Allele a : perAlleleData.keySet()) {
        if(!a.equals(combinedData.getRefAllele(),true)) {
            final List<Integer> altStrandCounts = combinedData.getAttribute(a);
            final int[][] refAltTable = new int[][]{new int[]{refStrandCounts.get(0), refStrandCounts.get(1)}, new int[]{altStrandCounts.get(0), altStrandCounts.get(1)}};
            annotationMap.put(a, QualityUtils.phredScaleErrorRate(Math.max(FisherStrand.pValueForContingencyTable(refAltTable), MIN_PVALUE)));
        }
    }
    return annotationMap;
}
 
Example 10
Source File: AS_RankSumTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Map<Allele, Double> calculateReducedData(final Map<Allele, Histogram> perAlleleValues, final Allele ref) {
    final Map<Allele, Double> perAltRankSumResults = new HashMap<>();
    for (final Allele alt : perAlleleValues.keySet()) {
        if (!alt.equals(ref, false) && perAlleleValues.get(alt) != null) {
            perAltRankSumResults.put(alt, perAlleleValues.get(alt).median());
        }
    }
    return perAltRankSumResults;
}
 
Example 11
Source File: StrandBiasTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void updateTable(final int[] table, final Allele allele, final GATKRead read, final Allele ref, final List<Allele> allAlts) {
    final boolean matchesRef = allele.equals(ref, true);
    final boolean matchesAnyAlt = allAlts.contains(allele);

    if ( matchesRef || matchesAnyAlt ) {
        final int offset = matchesRef ? 0 : ARRAY_DIM;

        // a normal read with an actual strand
        final boolean isForward = !read.isReverseStrand();
        table[offset + (isForward ? 0 : 1)]++;
    }
}
 
Example 12
Source File: ApplyVQSR.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private VariantContext getMatchingRecalVC(final VariantContext target, final List<VariantContext> recalVCs, final Allele allele) {
    for( final VariantContext recalVC : recalVCs ) {
        if ( target.getEnd() == recalVC.getEnd() ) {
            if (!useASannotations)
                return recalVC;
            else if (allele.equals(recalVC.getAlternateAllele(0)))
                return recalVC;
        }
    }
    return null;
}
 
Example 13
Source File: GenotypeConcordanceTest.java    From picard with MIT License 5 votes vote down vote up
/**
 * Simple method to return a list of unique alleles.
 */
private List<Allele> makeUniqueListOfAlleles(final Allele... alleles) {
    final Set<Allele> uniqueAlleles = new HashSet<Allele>();
    for (final Allele allele : alleles) {
        if (!allele.equals(Allele.NO_CALL)) {
            uniqueAlleles.add(allele);
        }
    }
    if (!uniqueAlleles.contains(Aref)) uniqueAlleles.add(Aref);
    return new ArrayList<Allele>(uniqueAlleles);
}
 
Example 14
Source File: SelectVariants.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC, final Set<String> selectedSampleNames) {
    if (fullyDecode) {
        return; // TODO -- annotations are broken with fully decoded data
    }

    if (keepOriginalChrCounts) {
        final int[] indexOfOriginalAlleleForNewAllele;
        final List<Allele> newAlleles = builder.getAlleles();
        final int numOriginalAlleles = originalVC.getNAlleles();

        // if the alleles already match up, we can just copy the previous list of counts
        if (numOriginalAlleles == newAlleles.size()) {
            indexOfOriginalAlleleForNewAllele = null;
        }
        // otherwise we need to parse them and select out the correct ones
        else {
            indexOfOriginalAlleleForNewAllele = new int[newAlleles.size() - 1];
            Arrays.fill(indexOfOriginalAlleleForNewAllele, -1);

            // note that we don't care about the reference allele at position 0
            for (int newI = 1; newI < newAlleles.size(); newI++) {
                final Allele newAlt = newAlleles.get(newI);
                for (int oldI = 0; oldI < numOriginalAlleles - 1; oldI++) {
                    if (newAlt.equals(originalVC.getAlternateAllele(oldI), false)) {
                        indexOfOriginalAlleleForNewAllele[newI - 1] = oldI;
                        break;
                    }
                }
            }
        }

        if (originalVC.hasAttribute(VCFConstants.ALLELE_COUNT_KEY)) {
            builder.attribute(GATKVCFConstants.ORIGINAL_AC_KEY,
                    getReorderedAttributes(originalVC.getAttribute(VCFConstants.ALLELE_COUNT_KEY), indexOfOriginalAlleleForNewAllele));
        }
        if (originalVC.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY)) {
            builder.attribute(GATKVCFConstants.ORIGINAL_AF_KEY,
                    getReorderedAttributes(originalVC.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY), indexOfOriginalAlleleForNewAllele));
        }
        if (originalVC.hasAttribute(VCFConstants.ALLELE_NUMBER_KEY)) {
            builder.attribute(GATKVCFConstants.ORIGINAL_AN_KEY, originalVC.getAttribute(VCFConstants.ALLELE_NUMBER_KEY));
        }
    }

    VariantContextUtils.calculateChromosomeCounts(builder, false);

    if (keepOriginalDepth && originalVC.hasAttribute(VCFConstants.DEPTH_KEY)) {
        builder.attribute(GATKVCFConstants.ORIGINAL_DP_KEY, originalVC.getAttribute(VCFConstants.DEPTH_KEY));
    }

    boolean sawDP = false;
    int depth = 0;
    for (final String sample : selectedSampleNames ) {
        final Genotype g = originalVC.getGenotype(sample);
        if (!g.isFiltered()) {
            if (g.hasDP()) {
                depth += g.getDP();
                sawDP = true;
            }
        }
    }

    if (sawDP) {
        builder.attribute(VCFConstants.DEPTH_KEY, depth);
    }
}
 
Example 15
Source File: GATKVCFConstants.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static boolean isSpanningDeletion(final Allele allele){
    return allele.equals(Allele.SPAN_DEL) || allele.equals(SPANNING_DELETION_SYMBOLIC_ALLELE_DEPRECATED);
}
 
Example 16
Source File: GtcToVcf.java    From picard with MIT License 4 votes vote down vote up
private VariantContext makeVariantContext(Build37ExtendedIlluminaManifestRecord record, final InfiniumGTCRecord gtcRecord,
                                          final InfiniumEGTFile egtFile, final ProgressLogger progressLogger) {
    // If the record is not flagged as errant in the manifest we include it in the VCF
    Allele A = record.getAlleleA();
    Allele B = record.getAlleleB();
    Allele ref = record.getRefAllele();

    final String chr = record.getB37Chr();
    final Integer position = record.getB37Pos();
    final Integer endPosition = position + ref.length() - 1;
    Integer egtIndex = egtFile.rsNameToIndex.get(record.getName());
    if (egtIndex == null) {
        throw new PicardException("Found no record in cluster file for manifest entry '" + record.getName() + "'");
    }

    progressLogger.record(chr, position);

    // Create list of unique alleles
    final List<Allele> assayAlleles = new ArrayList<>();
    assayAlleles.add(ref);

    if (A.equals(B)) {
        throw new PicardException("Found same allele (" + A.getDisplayString() + ") for A and B ");
    }

    if (!ref.equals(A, true)) {
        assayAlleles.add(A);
    }

    if (!ref.equals(B, true)) {
        assayAlleles.add(B);
    }

    final String sampleName = FilenameUtils.removeExtension(INPUT.getName());
    final Genotype genotype = getGenotype(sampleName, gtcRecord, record, A, B);

    final VariantContextBuilder builder = new VariantContextBuilder();

    builder.source(record.getName());
    builder.chr(chr);
    builder.start(position);
    builder.stop(endPosition);
    builder.alleles(assayAlleles);
    builder.log10PError(VariantContext.NO_LOG10_PERROR);
    builder.id(record.getName());
    builder.genotypes(genotype);

    VariantContextUtils.calculateChromosomeCounts(builder, false);

    //custom info fields
    builder.attribute(InfiniumVcfFields.ALLELE_A, record.getAlleleA());
    builder.attribute(InfiniumVcfFields.ALLELE_B, record.getAlleleB());
    builder.attribute(InfiniumVcfFields.ILLUMINA_STRAND, record.getIlmnStrand());
    builder.attribute(InfiniumVcfFields.PROBE_A, record.getAlleleAProbeSeq());
    builder.attribute(InfiniumVcfFields.PROBE_B, record.getAlleleBProbeSeq());
    builder.attribute(InfiniumVcfFields.BEADSET_ID, record.getBeadSetId());
    builder.attribute(InfiniumVcfFields.ILLUMINA_CHR, record.getChr());
    builder.attribute(InfiniumVcfFields.ILLUMINA_POS, record.getPosition());
    builder.attribute(InfiniumVcfFields.ILLUMINA_BUILD, record.getGenomeBuild());
    builder.attribute(InfiniumVcfFields.SOURCE, record.getSource().replace(' ', '_'));
    builder.attribute(InfiniumVcfFields.GC_SCORE, formatFloatForVcf(egtFile.totalScore[egtIndex]));

    for (InfiniumVcfFields.GENOTYPE_VALUES gtValue : InfiniumVcfFields.GENOTYPE_VALUES.values()) {
        final int ordinalValue = gtValue.ordinal();
        builder.attribute(InfiniumVcfFields.N[ordinalValue], egtFile.n[egtIndex][ordinalValue]);
        builder.attribute(InfiniumVcfFields.DEV_R[ordinalValue], formatFloatForVcf(egtFile.devR[egtIndex][ordinalValue]));
        builder.attribute(InfiniumVcfFields.MEAN_R[ordinalValue], formatFloatForVcf(egtFile.meanR[egtIndex][ordinalValue]));
        builder.attribute(InfiniumVcfFields.DEV_THETA[ordinalValue], formatFloatForVcf(egtFile.devTheta[egtIndex][ordinalValue]));
        builder.attribute(InfiniumVcfFields.MEAN_THETA[ordinalValue], formatFloatForVcf(egtFile.meanTheta[egtIndex][ordinalValue]));

        final EuclideanValues genotypeEuclideanValues = polarToEuclidean(egtFile.meanR[egtIndex][ordinalValue], egtFile.devR[egtIndex][ordinalValue],
                egtFile.meanTheta[egtIndex][ordinalValue], egtFile.devTheta[egtIndex][ordinalValue]);
        builder.attribute(InfiniumVcfFields.DEV_X[ordinalValue], formatFloatForVcf(genotypeEuclideanValues.devX));
        builder.attribute(InfiniumVcfFields.MEAN_X[ordinalValue], formatFloatForVcf(genotypeEuclideanValues.meanX));
        builder.attribute(InfiniumVcfFields.DEV_Y[ordinalValue], formatFloatForVcf(genotypeEuclideanValues.devY));
        builder.attribute(InfiniumVcfFields.MEAN_Y[ordinalValue], formatFloatForVcf(genotypeEuclideanValues.meanY));
    }


    final String rsid = record.getRsId();
    if (StringUtils.isNotEmpty(rsid)) {
        builder.attribute(InfiniumVcfFields.RS_ID, rsid);
    }
    if (egtFile.totalScore[egtIndex] == 0.0) {
        builder.filter(InfiniumVcfFields.ZEROED_OUT_ASSAY);
        if (genotype.isCalled()) {
            if (DO_NOT_ALLOW_CALLS_ON_ZEROED_OUT_ASSAYS) {
                throw new PicardException("Found a call (genotype: " + genotype + ") on a zeroed out Assay!!");
            } else {
                log.warn("Found a call (genotype: " + genotype + ") on a zeroed out Assay. " +
                        "This could occur if you called genotypes on a different cluster file than used here.");
            }
        }
    }
    if (record.isDupe()) {
        builder.filter(InfiniumVcfFields.DUPE);
    }
    return builder.make();
}
 
Example 17
Source File: FuncotatorIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void testCanAnnotateSpanningDeletions() {
    final FuncotatorArgumentDefinitions.OutputFormatType outputFormatType = FuncotatorArgumentDefinitions.OutputFormatType.VCF;
    final File outputFile = getOutputFile(outputFormatType);

    final ArgumentsBuilder arguments = createBaselineArgumentsForFuncotator(
            SPANNING_DEL_VCF,
            outputFile,
            hg38Chr3Ref,
            DS_PIK3CA_DIR,
            FuncotatorTestConstants.REFERENCE_VERSION_HG38,
            outputFormatType,
            false);

    runCommandLine(arguments);

    final Pair<VCFHeader, List<VariantContext>> vcfInfo = VariantContextTestUtils.readEntireVCFIntoMemory(outputFile.getAbsolutePath());
    final List<VariantContext> variantContexts = vcfInfo.getRight();
    Assert.assertTrue(variantContexts.size() > 0);
    final VCFHeader vcfHeader = vcfInfo.getLeft();
    final VCFInfoHeaderLine funcotationHeaderLine = vcfHeader.getInfoHeaderLine(VcfOutputRenderer.FUNCOTATOR_VCF_FIELD_NAME);
    final String[] funcotationKeys = FuncotatorUtils.extractFuncotatorKeysFromHeaderDescription(funcotationHeaderLine.getDescription());

    final int NUM_VARIANTS = 10;
    Assert.assertEquals(variantContexts.size(), NUM_VARIANTS);
    Assert.assertEquals(variantContexts.stream().filter(v -> v.hasAllele(Allele.SPAN_DEL)).count(), NUM_VARIANTS);

    for (final VariantContext vc : variantContexts) {
        final Map<Allele, FuncotationMap> alleleToFuncotationMap = FuncotatorUtils.createAlleleToFuncotationMapFromFuncotationVcfAttribute(funcotationKeys,
                vc, "Gencode_28_annotationTranscript", "TEST");

        // Make sure that all spanning deletions are funcotated with could not determine and that the others are something else.
        for (final Allele allele : alleleToFuncotationMap.keySet()) {
            final List<String> txIds = alleleToFuncotationMap.get(allele).getTranscriptList();
            for (final String txId : txIds) {
                if (allele.equals(Allele.SPAN_DEL)) {
                    Assert.assertEquals(alleleToFuncotationMap.get(allele).get(txId).get(0).getField("Gencode_28_variantClassification"), GencodeFuncotation.VariantClassification.COULD_NOT_DETERMINE.toString());
                    Assert.assertEquals(alleleToFuncotationMap.get(allele).get(txId).get(0).getField("Gencode_28_variantType"), GencodeFuncotation.VariantType.NA.toString());
                } else {
                    Assert.assertNotEquals(alleleToFuncotationMap.get(allele).get(txId).get(0).getField("Gencode_28_variantClassification"), GencodeFuncotation.VariantClassification.COULD_NOT_DETERMINE.toString());
                }
            }
        }
    }
}