Java Code Examples for htsjdk.variant.variantcontext.VariantContext#getContig()

The following examples show how to use htsjdk.variant.variantcontext.VariantContext#getContig() . 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: VariantEval.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void addVariant(VariantContext vc, ReadsContext readsContext, ReferenceContext referenceContext, FeatureContext featureContext) {
    if (i == null || !vc.getContig().equals(i.getContig()) || vc.getStart() != i.getStart()) {
        callDoApply();

        i = new SimpleInterval(vc.getContig(), vc.getStart(), vc.getEnd());
        this.readsContext = readsContext;
        this.referenceContext = referenceContext;
        this.featureContext = featureContext;
    }
    else if (vc.getEnd() > i.getEnd()) {
        //expand region
        i = new SimpleInterval(i.getContig(), i.getStart(), vc.getEnd());

        this.readsContext = new ReadsContext(this.readsContext, i);
        this.referenceContext = new ReferenceContext(this.referenceContext, i);
        this.featureContext = new FeatureContext(this.featureContext, i);
    }
}
 
Example 2
Source File: FilterAlignmentArtifacts.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private AssemblyRegion makeAssemblyRegionFromVariantReads(final List<ReadsContext> readsContexts, final VariantContext vc) {
    final Set<String> variantReadNames = readsContexts.stream().flatMap(Utils::stream)
            .filter(read -> RealignmentEngine.supportsVariant(read, vc, indelStartTolerance))
            .map(GATKRead::getName)
            .collect(Collectors.toSet());

    final List<GATKRead> variantReads = readsContexts.stream().flatMap(Utils::stream)
            .filter(read -> variantReadNames.contains(read.getName()))
            .sorted(Comparator.comparingInt(GATKRead::getStart))
            .collect(Collectors.toList());

    final int firstReadStart = variantReads.stream().mapToInt(GATKRead::getStart).min().orElse(vc.getStart());
    final int lastReadEnd = variantReads.stream().mapToInt(GATKRead::getEnd).max().orElse(vc.getEnd());
    final SimpleInterval assemblyWindow = new SimpleInterval(vc.getContig(), Math.max(firstReadStart - ASSEMBLY_PADDING,1), lastReadEnd + ASSEMBLY_PADDING);

    final AssemblyRegion assemblyRegion = new AssemblyRegion(assemblyWindow, 0, bamHeader);
    assemblyRegion.addAll(variantReads);

    return assemblyRegion;
}
 
Example 3
Source File: ValidateVariants.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void validateVariantsOrder(final VariantContext vc) {
    // Check if the current VC belongs to the same contig as the previous one.
    // If not, reset the start position to -1.
    if (previousContig == null || !previousContig.equals(vc.getContig())) {
        previousContig = vc.getContig();
        previousStart = -1;
    }

    //if next VC refers to a previous genomic position, throw an error
    //Note that HaplotypeCaller can emit variants that start inside of a deletion on another haplotype,
    // making v2's start less than the deletion's end
    if (previousStart > -1 && vc.getStart() < previousStart) {
        final UserException e = new UserException(String.format("In a GVCF all records must ordered. Record: %s covers a position previously traversed.",
                vc.toStringWithoutGenotypes()));
        throwOrWarn(e);
    }
}
 
Example 4
Source File: StrelkaPostProcess.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@VisibleForTesting
static GenomePosition variantGenomePosition(@NotNull final VariantContext variant) {
    return new GenomePosition() {
        @Override
        @NotNull
        public String chromosome() {
            return variant.getContig();
        }

        @Override
        public long position() {
            return variant.getStart();
        }
    };
}
 
Example 5
Source File: PileupSummary.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PileupSummary(final VariantContext vc, final ReadPileup pileup) {
    contig = vc.getContig();
    position = vc.getStart();
    alleleFrequency = vc.getAttributeAsDouble(VCFConstants.ALLELE_FREQUENCY_KEY, 0);
    final byte altBase = vc.getAlternateAllele(0).getBases()[0];
    final byte refBase = vc.getReference().getBases()[0];
    final int[] baseCounts = pileup.getBaseCounts();
    altCount = baseCounts[BaseUtils.simpleBaseToBaseIndex(altBase)];
    refCount = baseCounts[BaseUtils.simpleBaseToBaseIndex(refBase)];
    totalCount = (int) MathUtils.sum(baseCounts);
    otherAltsCount = totalCount - altCount - refCount;
}
 
Example 6
Source File: CreateSomaticPanelOfNormals.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Object doWork() {
    final List<File> inputVcfs = new ArrayList<>(vcfs);
    final Collection<CloseableIterator<VariantContext>> iterators = new ArrayList<>(inputVcfs.size());
    final Collection<VCFHeader> headers = new HashSet<>(inputVcfs.size());
    final VCFHeader headerOfFirstVcf = new VCFFileReader(inputVcfs.get(0), false).getFileHeader();
    final SAMSequenceDictionary sequenceDictionary = headerOfFirstVcf.getSequenceDictionary();
    final VariantContextComparator comparator = headerOfFirstVcf.getVCFRecordComparator();


    for (final File vcf : inputVcfs) {
        final VCFFileReader reader = new VCFFileReader(vcf, false);
        iterators.add(reader.iterator());
        final VCFHeader header = reader.getFileHeader();
        Utils.validateArg(comparator.isCompatible(header.getContigLines()), () -> vcf.getAbsolutePath() + " has incompatible contigs.");
        headers.add(header);
    }

    final VariantContextWriter writer = GATKVariantContextUtils.createVCFWriter(outputVcf, sequenceDictionary, false, Options.INDEX_ON_THE_FLY);
    writer.writeHeader(new VCFHeader(VCFUtils.smartMergeHeaders(headers, false)));

    final MergingIterator<VariantContext> mergingIterator = new MergingIterator<>(comparator, iterators);
    SimpleInterval currentPosition = new SimpleInterval("FAKE", 1, 1);
    final List<VariantContext> variantsAtThisPosition = new ArrayList<>(20);
    while (mergingIterator.hasNext()) {
        final VariantContext vc = mergingIterator.next();
        if (!currentPosition.overlaps(vc)) {
            processVariantsAtSamePosition(variantsAtThisPosition, writer);
            variantsAtThisPosition.clear();
            currentPosition = new SimpleInterval(vc.getContig(), vc.getStart(), vc.getStart());
        }
        variantsAtThisPosition.add(vc);
    }
    mergingIterator.close();
    writer.close();

    return "SUCCESS";
}
 
Example 7
Source File: CombineGenotypingArrayVcfs.java    From picard with MIT License 5 votes vote down vote up
private static void checkThatAllelesMatch(final VariantContext vc1, final VariantContext vc2) {
    if (!vc1.getReference().equals(vc2.getReference())) {
        throw new PicardException("Mismatch in REF allele among input VCFs");
    }
    if (vc1.getAlternateAlleles().size() != vc2.getAlternateAlleles().size()) {
        throw new PicardException("Mismatch in ALT allele count among input VCFs");
    }
    for (int i = 0; i < vc1.getAlternateAlleles().size(); i++) {
        if (!vc1.getAlternateAllele(i).equals(vc2.getAlternateAllele(i))) {
            throw new PicardException("Mismatch in ALT allele among input VCFs for " + vc1.getContig() + "." + vc1.getStart());
        }
    }
}
 
Example 8
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static SimpleInterval getBasesChangedIntervalIgnoringLeadingVcfContextBase(final VariantContext variant,
                                                                                   final Allele altAllele) {

    // Adjust the variant interval for the overlap check, specifically to properly test for the indel cases:
    final SimpleInterval changedBasesInterval;
    if ( GATKVariantContextUtils.typeOfVariant(variant.getReference(), altAllele).equals(VariantContext.Type.INDEL) ) {

        final int adjustedStart;
        final int end;
        // Insertion:
        if ( variant.getReference().length() < altAllele.length() ) {
            // We use the variant start here because by inserting bases we're not making the actually changed
            // bases any closer to the boundaries of the exon.
            // That is, the inserted bases shouldn't count towards the extents of the variant in genomic space
            // with respect to the exon boundaries.
            adjustedStart = FuncotatorUtils.getIndelAdjustedAlleleChangeStartPosition(variant, altAllele);
            end = variant.getEnd() + (altAllele.length() - (adjustedStart - variant.getStart()));
        }
        // Deletion:
        else {
            // Because we're deleting bases from the reference allele, we need to adjust the start position of the
            // variant to reflect that the leading base(s) do(es) not matter.
            adjustedStart = FuncotatorUtils.getIndelAdjustedAlleleChangeStartPosition(variant, altAllele);

            // The original end position should be correct:
            end = variant.getEnd();
        }

        changedBasesInterval = new SimpleInterval( variant.getContig(), adjustedStart, end );
    }
    else {
        changedBasesInterval = new SimpleInterval(variant);
    }

    return changedBasesInterval;
}
 
Example 9
Source File: LiftoverVcfTest.java    From picard with MIT License 5 votes vote down vote up
@Test(dataProvider = "indelFlipData")
public void testFlipIndel(final VariantContext source, final ReferenceSequence reference, final VariantContext result) {

    final LiftOver liftOver = new LiftOver(CHAIN_FILE);
    final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd());
    final Interval target = liftOver.liftOver(originalLocus);
    if (target != null && !target.isNegativeStrand()) {
        throw new RuntimeException("not reversed");
    }

    final VariantContext flipped = LiftoverUtils.liftVariant(source, target, reference, false, false);

    VcfTestUtils.assertEquals(flipped, result);
}
 
Example 10
Source File: LiftoverVcfTest.java    From picard with MIT License 5 votes vote down vote up
@Test(dataProvider = "indelFlipDataWithOriginalAllele")
public void testFlipIndelWithOriginalAlleles(final VariantContext source, final ReferenceSequence reference, final VariantContext result) {

    final LiftOver liftOver = new LiftOver(CHAIN_FILE);
    final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd());
    final Interval target = liftOver.liftOver(originalLocus);
    if (target != null && !target.isNegativeStrand()) {
        throw new RuntimeException("not reversed");
    }

    final VariantContext flipped = LiftoverUtils.liftVariant(source, target, reference, false, true);

    VcfTestUtils.assertEquals(flipped, result);
}
 
Example 11
Source File: VCFRecordReader.java    From Hadoop-BAM with MIT License 5 votes vote down vote up
private boolean overlaps(VariantContext v) {
	if (intervals == null) {
		return true;
	}
	final Interval interval = new Interval(v.getContig(), v.getStart(), v.getEnd());
	return overlapDetector.overlapsAny(interval);
}
 
Example 12
Source File: ExternalDBFilters.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
private void writeFilterRecord(final VariantContext variant, final SnpEffAnnotation snpEff,
        final String gene, CodingEffect codingEffect, final String clinvarSignificance, final String clinvarSigInfo)
{
    final String transcriptId = stripTranscriptVersion(snpEff.transcript());
    final String chromosome = variant.getContig();
    long position = variant.getStart();
    String ref = variant.getReference().getBaseString();
    String alt = variant.getAlleles().get(1).getBaseString();

    ref = ref.replaceAll("\\*", "");
    alt = alt.replaceAll("\\*", "");

    final String effects = snpEff.effects();
    final String clinvarDisease = variant.getCommonInfo().getAttributeAsString(CLINVAR_DISEASE_NAME, "");
    final String clinvarEffects = variant.getCommonInfo().getAttributeAsString(CLINVAR_MC, "");
    final String rsDbSnpId = variant.getCommonInfo().getAttributeAsString(CLINVAR_RS_DB_SNP_ID, "");

    final String hgvsp = snpEff.hgvsProtein();
    final String hgvsc = snpEff.hgvsCoding();

    if(LOGGER.isDebugEnabled())
    {
        // now extract other required Clinvar info
        LOGGER.debug("var({}:{}) ref({}) alt({}) effect({}) gene({} trans={}) clinvar({}, {}, {})",
                variant.getContig(), position, ref, alt, snpEff.effects(), gene, transcriptId,
                clinvarSignificance,  clinvarDisease, clinvarEffects);
    }

    try
    {
        mFilterWriter.write(String.format("%s,%s,%s,%d,%s,%s,%s,%s",
                gene, snpEff.transcript(), chromosome, position, ref, alt, codingEffect, effects));

        mFilterWriter.write(String.format(",%s,%s,%s",
                hgvsp, hgvsc, rsDbSnpId));

        mFilterWriter.write(String.format(",%s,%s,%s,%s",
                clinvarSignificance, clinvarSigInfo, clinvarDisease, clinvarEffects));

        mFilterWriter.newLine();
    }
    catch(IOException e)
    {
        LOGGER.error("Error writing filter output: {}", e.toString());
    }
}
 
Example 13
Source File: SageHotspotAnnotation.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
private static String simpleString(@NotNull final VariantContext context) {
    return "[" + context.getContig() + ":" + context.getStart() + " Type:" + context.getType() + " Alleles:" + ParsingUtils.sortList(
            context.getAlleles()) + "]";
}
 
Example 14
Source File: KataegisWindow.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
KataegisWindow(final VariantContext context) {
    this.contig = context.getContig();
    this.start = context.getStart();
    this.end = this.start;
    this.count = 0;
}
 
Example 15
Source File: VariantContextVariantAdapter.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static GATKVariant sparkVariantAdapter(VariantContext vc) {
    return new MinimalVariant(new SimpleInterval(vc.getContig(),vc.getStart(),vc.getEnd()), vc.isSNP(), vc.isIndel());
}
 
Example 16
Source File: CosmicFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected List<Funcotation> createFuncotationsOnVariant(final VariantContext variant, final ReferenceContext referenceContext, final List<Feature> featureList, final List<GencodeFuncotation> gencodeFuncotations) {

    final List<Funcotation> outputFuncotations = new ArrayList<>();

    // Keep count of each overlapping mutation here:
    final Map<String, Integer> proteinChangeCounts = new LinkedHashMap<>();

    // If we have gencodeFuncotations we go through them and get the gene name
    // Then query our DB for matches on the gene name.
    // Then grab Genome position / Protein position and see if we overlap.
    // If any do, we create our CosmicFuncotation
    for ( final GencodeFuncotation gencodeFuncotation : gencodeFuncotations ) {
        final String geneName = gencodeFuncotation.getHugoSymbol();

        final SimpleInterval genomePosition = new SimpleInterval(variant.getContig(), variant.getStart(), variant.getEnd());

        final SimpleInterval proteinPosition;
        if ( gencodeFuncotation.getProteinChange() != null ) {
            proteinPosition = parseProteinString(gencodeFuncotation.getProteinChange());
        }
        else {
            proteinPosition = null;
        }

        try {
            try ( final Statement statement = dbConnection.createStatement() ) {
                try ( final ResultSet resultSet = statement.executeQuery(RESULT_QUERY_TEMPLATE + "\"" + geneName + "\";") ) {
                    // iterate through our results:
                    while ( resultSet.next() ) {

                        // Get the genome position:
                        final SimpleInterval cosmicGenomePosition = getGenomePositionFromResults(resultSet);

                        // Try to match on genome position first:
                        if ( cosmicGenomePosition != null ) {
                            if ( genomePosition.overlaps(cosmicGenomePosition) ) {
                                // If we overlap the records, we get the protein change and add it to the map:
                                updateProteinChangeCountMap(proteinChangeCounts, resultSet);
                                continue;
                            }
                        }

                        // Get the protein position:
                        final SimpleInterval cosmicProteinPosition = getProteinPositionFromResults(resultSet);

                        // Now try to match on protein position:
                        if ( proteinPosition != null ) {
                            // If we overlap the records, we update the counter:
                            if ( proteinPosition.overlaps(cosmicProteinPosition) ) {
                                updateProteinChangeCountMap(proteinChangeCounts, resultSet);
                            }
                        }
                        // NOTE: We can't annotate if the protein position is null.
                    }
                }
            }
        }
        catch (final SQLException ex) {
            throw new GATKException("Unable to query the database for geneName: " + geneName, ex);
        }
    }

    // Add our counts to all alternate alleles in this variant:
    for ( final Allele altAllele : variant.getAlternateAlleles() ) {
        outputFuncotations.add(
                TableFuncotation.create(
                        new ArrayList<>(supportedFields),
                        Collections.singletonList(proteinChangeCounts.entrySet().stream()
                                .map(entry -> entry.getKey() + '('+ entry.getValue() + ')')
                                .collect(Collectors.joining("|"))),
                        altAllele,
                        name, null
                )
        );
    }

    return outputFuncotations;
}
 
Example 17
Source File: AbstractVcfMergingClpTester.java    From picard with MIT License 4 votes vote down vote up
static String getContigPosition(final VariantContext context) {
	return context.getContig() + "-" + Integer.toString(context.getStart());
}
 
Example 18
Source File: CreateSnpIntervalFromVcf.java    From Drop-seq with MIT License 4 votes vote down vote up
public IntervalList processData(final File vcfFile, final File sdFile, final Set<String> sample, int GQThreshold, final boolean hetSNPsOnly) {

		final VCFFileReader reader = new VCFFileReader(vcfFile, false);
		if (!VCFUtils.GQInHeader(reader)) {
			GQThreshold=-1;
			log.info("Genotype Quality [GQ] not found in header.  Disabling GQ_THRESHOLD parameter");
		}
		
		final VCFHeader inputVcfHeader = new VCFHeader(reader.getFileHeader().getMetaDataInInputOrder());
		SAMSequenceDictionary sequenceDictionary = inputVcfHeader.getSequenceDictionary();
		Set<String> sampleListFinal = sample;
		if (sample==null || sample.isEmpty()) {
			ArrayList<String> s = reader.getFileHeader().getSampleNamesInOrder();
			sampleListFinal=new TreeSet<String>(s);
		}

		if (sdFile != null)
			sequenceDictionary = getSequenceDictionary(sdFile);

		final ProgressLogger progress = new ProgressLogger(this.log, 500000);

		final SAMFileHeader samHeader = new SAMFileHeader();
		samHeader.setSequenceDictionary(sequenceDictionary);
		IntervalList result = new IntervalList(samHeader);

		// Go through the input, find sites we want to keep.
		final PeekableIterator<VariantContext> iterator = new PeekableIterator<>(reader.iterator());

		validateRequestedSamples (iterator, sampleListFinal);

		while (iterator.hasNext()) {
			final VariantContext site = iterator.next();
			progress.record(site.getContig(), site.getStart());
			// for now drop any filtered site.
			if (site.isFiltered())
				continue;
			// move onto the next record if the site is not a SNP or the samples aren't all heterozygous.
			if (!site.isSNP())
				continue;
			if (!sitePassesFilters(site, sampleListFinal, GQThreshold, hetSNPsOnly))
				continue;
			Interval varInt = new Interval(site.getContig(), site.getStart(),
					site.getEnd(), true, site.getID());

			// final Interval site = findHeterozygousSites(full, SAMPLE);
			result.add(varInt);

		}

		CloserUtil.close(iterator);
		CloserUtil.close(reader);
		return (result);
	}
 
Example 19
Source File: HaplotypeMap.java    From picard with MIT License 4 votes vote down vote up
/**
 * Constructs a HaplotypeMap from the provided file.
 */

private void fromVcf(final File file) {
    try ( final VCFFileReader reader = new VCFFileReader(file, false)) {

        final SAMSequenceDictionary dict = reader.getFileHeader().getSequenceDictionary();

        if (dict == null || dict.getSequences().isEmpty()) {
            throw new IllegalStateException("Haplotype map VCF file must contain header: " + file.getAbsolutePath());
        }

        initialize(new SAMFileHeader(dict));

        final Map<String, HaplotypeBlock> anchorToHaplotype = new HashMap<>();

        for (final VariantContext vc : reader) {

            if (vc.getNSamples() > 1) {
                throw new IllegalStateException("Haplotype map VCF file must contain at most one sample: " + file.getAbsolutePath());
            }

            final Genotype gc = vc.getGenotype(0); // may be null
            final boolean hasGc = gc != null;

            if (vc.getAlternateAlleles().size() != 1) {
                throw new IllegalStateException("Haplotype map VCF file must contain exactly one alternate allele per site: " + vc.toString());
            }

            if (!vc.isSNP()) {
                throw new IllegalStateException("Haplotype map VCF file must contain only SNPs: " + vc.toString());
            }

            if (!vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY)) {
                throw new IllegalStateException("Haplotype map VCF Variants must have an '"+ VCFConstants.ALLELE_FREQUENCY_KEY + "' INFO field: " + vc.toString());
            }


            if (hasGc && gc.isPhased() && !gc.hasExtendedAttribute(VCFConstants.PHASE_SET_KEY)) {
                throw new IllegalStateException("Haplotype map VCF Variants' genotypes that are phased must have a PhaseSet (" + VCFConstants.PHASE_SET_KEY+")" + vc.toString());
            }

            if (hasGc && gc.isPhased() && !gc.isHet()) {
                throw new IllegalStateException("Haplotype map VCF Variants' genotypes that are phased must be HET" + vc.toString());
            }

            // Then parse them out
            final String chrom = vc.getContig();
            final int pos = vc.getStart();
            final String name = vc.getID();

            final byte ref = vc.getReference().getBases()[0];
            final byte var = vc.getAlternateAllele(0).getBases()[0];

            final double temp_maf = vc.getAttributeAsDouble(VCFConstants.ALLELE_FREQUENCY_KEY, 0D);
            final boolean swapped = hasGc && !gc.getAllele(0).equals(vc.getReference());

            final byte major, minor;
            final double maf;

            if (swapped) {
                major = var;
                minor = ref;
                maf = 1 - temp_maf;
            } else {
                major = ref;
                minor = var;
                maf = temp_maf;
            }

            final String anchor = anchorFromVc(vc);

            // If it's the anchor snp, start the haplotype
            if (!anchorToHaplotype.containsKey(anchor)) {
                final HaplotypeBlock newBlock = new HaplotypeBlock(maf);
                anchorToHaplotype.put(anchor, newBlock);
            }
            final HaplotypeBlock block = anchorToHaplotype.get(anchor);
            block.addSnp(new Snp(name, chrom, pos, major, minor, maf, null));
        }

        // And add them all now that they are all ready.
        fromHaplotypes(anchorToHaplotype.values());
    }
}
 
Example 20
Source File: CustomMafFuncotationCreatorUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * As a side effect, this also tests (https://github.com/broadinstitute/gatk/issues/4972)
 */
@Test(dataProvider = "provideDbSnpVariants")
public void testCreateDbSnpCustomFields(final VariantContext variant, final int gtNumHits, final String gtDbSnpValStatusField) {

    final Path sourceFilePath = IOUtils.getPath(FuncotatorTestConstants.DBSNP_HG19_SNIPPET_FILE_PATH);
    final DataSourceFuncotationFactory vcfFuncotationFactory =
            new VcfFuncotationFactory(DBSNP_DS_NAME,
                    "snippetTest",
                    sourceFilePath,
                    new LinkedHashMap<>(),
                    new FeatureInput<VariantContext>(sourceFilePath.toString(), DBSNP_DS_NAME, new HashMap<>())
            );

    /* dbSNP records of relevance.
    1	10177	rs367896724	A	AC	.	.	RS=367896724;RSPOS=10177;dbSNPBuildID=138;SSR=0;SAO=0;VP=0x050000020005170026000200;GENEINFO=DDX11L1:100287102;WGT=1;VC=DIV;R5;ASP;VLD;G5A;G5;KGPhase3;CAF=0.5747,0.4253;COMMON=1
    1	10352	rs555500075	T	TA	.	.	RS=555500075;RSPOS=10352;dbSNPBuildID=142;SSR=0;SAO=0;VP=0x050000020005170026000200;GENEINFO=DDX11L1:100287102;WGT=1;VC=DIV;R5;ASP;VLD;G5A;G5;KGPhase3;CAF=0.5625,0.4375;COMMON=1
    1	10352	rs145072688	T	TA	.	.	RS=145072688;RSPOS=10353;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;GENEINFO=DDX11L1:100287102;WGT=1;VC=DIV;R5;ASP;CAF=0.5625,0.4375;COMMON=1
     */
    // Create features from the file:
    final List<Feature> vcfFeatures;
    try (final VCFFileReader vcfReader = new VCFFileReader(IOUtils.getPath(FuncotatorTestConstants.DBSNP_HG19_SNIPPET_FILE_PATH))) {
        vcfFeatures = vcfReader.query(variant.getContig(), variant.getStart(), variant.getEnd()).stream().collect(Collectors.toList());
    }

    Assert.assertEquals(vcfFeatures.size(), gtNumHits);

    final Map<String, List<Feature>> vcfFuncotationSourceMap = ImmutableMap.of(DBSNP_DS_NAME, vcfFeatures);
    final ReferenceContext referenceContext = new ReferenceContext(ReferenceDataSource.of(Paths.get(HG19_CHR1_1M_FASTA)),
            new SimpleInterval(variant.getContig(),
            variant.getStart(), variant.getEnd()));

    final FeatureContext featureContext = FuncotatorTestUtils.createFeatureContext(Collections.singletonList(vcfFuncotationFactory),
            "TEST_CREATE_DB_SNP_CUSTOM_FIELDS",
            new SimpleInterval(variant.getContig(), variant.getStart(), variant.getEnd()),
            0, 0, 0, null);

    final List<Funcotation> funcotations = vcfFuncotationFactory.createFuncotations(variant, referenceContext, featureContext);
    Assert.assertTrue(funcotations.size() > 0);
    for (final Funcotation f : funcotations) {
        Assert.assertEquals(StringUtils.split(f.getField(DBSNP_DS_NAME + "_VLD"), "|").length, vcfFuncotationSourceMap.get(DBSNP_DS_NAME).size());
    }

    final List<Funcotation> customDbSnpFuncotations = CustomMafFuncotationCreator.createCustomMafDbSnpFields(funcotations);
    Assert.assertEquals(customDbSnpFuncotations.stream().map(f -> f.getField(MAF_DBSNP_VAL_STATUS_FIELD)).collect(Collectors.toList()),
            Collections.singletonList(gtDbSnpValStatusField));

    // Now add some dummy (non-DbSNP) funcotations and make sure that we are not getting any additional custom dbsnp maf fields.
    final List<String> dummyFieldNames = Arrays.asList("foo_field", "bar_field");
    final Funcotation dummyFuncotation = TableFuncotation.create(dummyFieldNames, Arrays.asList("1", "2"), Allele.create("AA"), "DUMMY", FuncotationMetadataUtils.createWithUnknownAttributes(dummyFieldNames));
    funcotations.add(dummyFuncotation);

    final List<Funcotation> customDbSnpFuncotationsWithoutDummies = CustomMafFuncotationCreator.createCustomMafDbSnpFields(funcotations);
    Assert.assertEquals(customDbSnpFuncotationsWithoutDummies, customDbSnpFuncotations);
}