Java Code Examples for htsjdk.variant.vcf.VCFHeader#addMetaDataLine()

The following examples show how to use htsjdk.variant.vcf.VCFHeader#addMetaDataLine() . 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: FilterFuncotations.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onTraversalStart() {
    final VCFHeader vcfHeader = getHeaderForVariants();

    final VCFInfoHeaderLine funcotationHeaderLine = vcfHeader.getInfoHeaderLine(VcfOutputRenderer.FUNCOTATOR_VCF_FIELD_NAME);
    if (funcotationHeaderLine != null) {
        funcotationKeys = FuncotatorUtils.extractFuncotatorKeysFromHeaderDescription(funcotationHeaderLine.getDescription());
        outputVcfWriter = createVCFWriter(outputFile);
        vcfHeader.addMetaDataLine(new VCFFilterHeaderLine(FilterFuncotationsConstants.NOT_CLINSIG_FILTER,
                FilterFuncotationsConstants.NOT_CLINSIG_FILTER_DESCRIPTION));
        vcfHeader.addMetaDataLine(new VCFInfoHeaderLine(FilterFuncotationsConstants.CLINSIG_INFO_KEY, 1,
                VCFHeaderLineType.String, FilterFuncotationsConstants.CLINSIG_INFO_KEY_DESCRIPTION));
        outputVcfWriter.writeHeader(vcfHeader);
    } else {
        throw new UserException.BadInput("Could not extract Funcotation keys from " +
                VcfOutputRenderer.FUNCOTATOR_VCF_FIELD_NAME + " field in input VCF header.");
    }

    registerFilters();
}
 
Example 2
Source File: StrelkaPostProcessApplication.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
public static VCFHeader generateOutputHeader(@NotNull final VCFHeader header, @NotNull final String sampleName) {
    final VCFHeader outputVCFHeader = new VCFHeader(header.getMetaDataInInputOrder(), Sets.newHashSet(sampleName));
    outputVCFHeader.addMetaDataLine(VCFStandardHeaderLines.getFormatLine("GT"));
    outputVCFHeader.addMetaDataLine(VCFStandardHeaderLines.getFormatLine("AD"));

    outputVCFHeader.addMetaDataLine(new VCFHeaderLine("StrelkaGATKCompatibility",
            "Added GT fields to strelka calls for gatk compatibility."));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine("MAPPABILITY", 1, VCFHeaderLineType.Float, "Mappability (percentage)"));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine("SOMATIC_PON_COUNT",
            1,
            VCFHeaderLineType.Integer,
            "Number of times the variant appears in the somatic PON"));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine("GERMLINE_PON_COUNT",
            1,
            VCFHeaderLineType.Integer,
            "Number of times the variant appears in the germline PON"));
    return outputVCFHeader;
}
 
Example 3
Source File: SageHotspotAnnotation.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
private static VCFHeader generateOutputHeader(@NotNull final VCFHeader template, @NotNull final VCFHeader hotspotVCF) {
    final VCFHeader outputVCFHeader = new VCFHeader(template.getMetaDataInInputOrder(), template.getGenotypeSamples());
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(HOTSPOT_FLAG, 0, VCFHeaderLineType.Flag, HOTSPOT_DESCRIPTION));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(NEAR_HOTSPOT_FLAG, 0, VCFHeaderLineType.Flag, NEAR_HOTSPOT_DESCRIPTION));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(RECOVERED_FLAG, 0, VCFHeaderLineType.Flag, RECOVERED_FLAG_DESCRIPTION));

    for (VCFInfoHeaderLine headerLine : hotspotVCF.getInfoHeaderLines()) {
        outputVCFHeader.addMetaDataLine(headerLine);
    }

    return outputVCFHeader;
}
 
Example 4
Source File: NuMTFilterTool.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onTraversalStart() {
    final VCFHeader header = getHeaderForVariants();
    header.addMetaDataLine(GATKVCFHeaderLines.getFilterLine(GATKVCFConstants.POSSIBLE_NUMT_FILTER_NAME));
    vcfWriter = createVCFWriter(new File(outputVcf));
    vcfWriter.writeHeader(header);
    if (maxNuMTAutosomalCopies > 0 && medianAutosomalCoverage > 0) {
        maxAltDepthCutoff = getMaxAltDepthCutoff(maxNuMTAutosomalCopies, medianAutosomalCoverage);
    }
}
 
Example 5
Source File: MTLowHeteroplasmyFilterTool.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onTraversalStart() {
    final VCFHeader header = getHeaderForVariants();
    header.addMetaDataLine(GATKVCFHeaderLines.getFilterLine(GATKVCFConstants.LOW_HET_FILTER_NAME));
    vcfWriter = createVCFWriter(new File(outputVcf));
    vcfWriter.writeHeader(header);
}
 
Example 6
Source File: GVCFBlockCombiner.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void addRangesToHeader(VCFHeader header) {
    Utils.nonNull(header, "header cannot be null");

    header.addMetaDataLine(VCFStandardHeaderLines.getInfoLine(VCFConstants.END_KEY));
    header.addMetaDataLine(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.MIN_DP_FORMAT_KEY));

    for (final Range<Integer> partition : gqPartitions.asMapOfRanges().keySet()) {
        header.addMetaDataLine(rangeToVCFHeaderLine(partition));
    }
}
 
Example 7
Source File: InfiniumVcfFieldsTest.java    From picard with MIT License 5 votes vote down vote up
@Test(expectedExceptions = IllegalArgumentException.class)
public void testGetWronglyFormattedDateFromVcfOtherHeaderLine() {
    try (final VCFFileReader in = new VCFFileReader(TEST_VCF_FILE, false)) {
        final VCFHeader header = in.getFileHeader();
        final String badlyFormattedDateString = "04/18/2019";
        header.addMetaDataLine(new VCFHeaderLine("badDate", badlyFormattedDateString));
        InfiniumVcfFields.getDateFromVcfOtherHeaderLine(header, "badDate", autocallDateFormat);
    }
}
 
Example 8
Source File: MergePedIntoVcf.java    From picard with MIT License 5 votes vote down vote up
private void addAdditionalHeaderFields(VCFHeader header) {
    header.addMetaDataLine(new VCFHeaderLine(InfiniumVcfFields.ZCALL_VERSION, ZCALL_VERSION));
    header.addMetaDataLine(new VCFHeaderLine(InfiniumVcfFields.ZCALL_THRESHOLDS, ZCALL_THRESHOLDS_FILE.getName()));
    header.addMetaDataLine(new VCFInfoHeaderLine(InfiniumVcfFields.ZTHRESH_X, 1, VCFHeaderLineType.Float, "zCall X threshold"));
    header.addMetaDataLine(new VCFInfoHeaderLine(InfiniumVcfFields.ZTHRESH_Y, 1, VCFHeaderLineType.Float, "zCall Y threshold"));
    header.addMetaDataLine(new VCFFormatHeaderLine(InfiniumVcfFields.GTA, 1, VCFHeaderLineType.String, "Illumina Autocall Genotype"));
    header.addMetaDataLine(new VCFFormatHeaderLine(InfiniumVcfFields.GTZ, 1, VCFHeaderLineType.String, "zCall Genotype"));
}
 
Example 9
Source File: PonVCF.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
PonVCF(final String output, int sampleSize) {
    writer = new VariantContextWriterBuilder().setOutputFile(output)
            .modifyOption(Options.INDEX_ON_THE_FLY, false)
            .modifyOption(Options.USE_ASYNC_IO, false)
            .modifyOption(Options.DO_NOT_WRITE_GENOTYPES, true)
            .build();

    final VCFHeader header = new VCFHeader();
    header.addMetaDataLine(new VCFInfoHeaderLine(PON_COUNT, 1, VCFHeaderLineType.Integer, "how many samples had the variant"));
    header.addMetaDataLine(new VCFInfoHeaderLine(PON_TOTAL, 1, VCFHeaderLineType.Integer, "total depth"));
    header.addMetaDataLine(new VCFInfoHeaderLine(PON_MAX, 1, VCFHeaderLineType.Integer, "max depth"));
    header.addMetaDataLine(new VCFHeaderLine("PonInputSampleCount", String.valueOf(sampleSize)));
    writer.writeHeader(header);
}
 
Example 10
Source File: SagePostProcessVCF.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public void writeHeader(@NotNull final VCFHeader header) {
    header.addMetaDataLine(new VCFInfoHeaderLine(SNPEFF_WORST,
            5,
            VCFHeaderLineType.String,
            "SnpEff worst transcript summary [Gene, Transcript, Effect, CodingEffect, GenesAffected]"));
    header.addMetaDataLine(new VCFInfoHeaderLine(SNPEFF_CANONICAL,
            6,
            VCFHeaderLineType.String,
            "SnpEff canonical transcript summary [Gene, Transcript, Effect, CodingEffect, HgvsCodingImpact, HgvsProteinImpact]"));
    writer.writeHeader(header);
}
 
Example 11
Source File: StructuralVariantHeader.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
public static VCFHeader generateHeader(@NotNull final String purpleVersion, @NotNull final VCFHeader template) {
    final VCFHeader outputVCFHeader = new VCFHeader(template.getMetaDataInInputOrder(), template.getGenotypeSamples());
    outputVCFHeader.addMetaDataLine(new VCFHeaderLine("purpleVersion", purpleVersion));

    outputVCFHeader.addMetaDataLine(VCFStandardHeaderLines.getFormatLine("GT"));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(StructuralVariantFactory.RECOVERED,
            0,
            VCFHeaderLineType.Flag,
            RECOVERED_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(StructuralVariantFactory.INFERRED, 0, VCFHeaderLineType.Flag, INFERRED_DESC));
    outputVCFHeader.addMetaDataLine(new VCFFilterHeaderLine(INFERRED, INFERRED_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(StructuralVariantFactory.IMPRECISE,
            0,
            VCFHeaderLineType.Flag,
            IMPRECISE_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(CIPOS, 2, VCFHeaderLineType.Integer, CIPOS_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(SVTYPE, 1, VCFHeaderLineType.String, SVTYPE_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_AF_INFO, UNBOUNDED, VCFHeaderLineType.Float, PURPLE_AF_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_CN_INFO, UNBOUNDED, VCFHeaderLineType.Float, PURPLE_CN_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(RECOVERY_METHOD, 1, VCFHeaderLineType.String, RECOVERY_METHOD_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(RECOVERY_FILTER, UNBOUNDED, VCFHeaderLineType.String, RECOVERY_FILTER_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_JUNCTION_COPY_NUMBER_INFO, 1, VCFHeaderLineType.Float,
            PURPLE_JUNCTION_COPY_NUMBER_DESC));
    outputVCFHeader.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_CN_CHANGE_INFO,
            UNBOUNDED,
            VCFHeaderLineType.Float,
            PURPLE_CN_CHANGE_DESC));
    return outputVCFHeader;
}
 
Example 12
Source File: KataegisEnrichment.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public VCFHeader enrichHeader(@NotNull final VCFHeader template) {
    template.addMetaDataLine(new VCFInfoHeaderLine(KATAEGIS_FLAG, 1, VCFHeaderLineType.String, KATAEGIS_FLAG_DESCRIPTION));

    return template;
}
 
Example 13
Source File: SubclonalLikelihoodEnrichment.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public VCFHeader enrichHeader(@NotNull final VCFHeader template) {
    template.addMetaDataLine(new VCFInfoHeaderLine(SUBCLONAL_LIKELIHOOD_FLAG,
            1,
            VCFHeaderLineType.Float, SUBCLONAL_LIKELIHOOD_FLAG_DESCRIPTION));

    return template;
}
 
Example 14
Source File: StructuralRefContextEnrichment.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public VCFHeader enrichHeader(@NotNull final VCFHeader template) {
    template.addMetaDataLine(new VCFInfoHeaderLine(REF_CONTEXT_FLAG, 1, VCFHeaderLineType.String, REF_CONTEXT_DESCRIPTION));

    return template;
}
 
Example 15
Source File: VariantHotspotEnrichment.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public VCFHeader enrichHeader(@NotNull final VCFHeader template) {
    template.addMetaDataLine(new VCFInfoHeaderLine(HOTSPOT_FLAG, 0, VCFHeaderLineType.Flag, HOTSPOT_DESCRIPTION));
    template.addMetaDataLine(new VCFInfoHeaderLine(NEAR_HOTSPOT_FLAG, 0, VCFHeaderLineType.Flag, NEAR_HOTSPOT_DESCRIPTION));
    return template;
}
 
Example 16
Source File: SomaticVariantHeader.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
public static VCFHeader generateHeader(@NotNull final String purpleVersion, @NotNull final VCFHeader template) {
    template.addMetaDataLine(new VCFHeaderLine("purpleVersion", purpleVersion));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_AF_INFO, 1, VCFHeaderLineType.Float, PURPLE_AF_DESC));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_CN_INFO, 1, VCFHeaderLineType.Float, PURPLE_CN_DESC));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_VARIANT_CN_INFO, 1, VCFHeaderLineType.Float, PURPLE_PLOIDY_DESC));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_MINOR_ALLELE_CN_INFO, 1,  VCFHeaderLineType.Float, PURPLE_MINOR_ALLELE_PLOIDY_DESC));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_GERMLINE_INFO, 1, VCFHeaderLineType.String, PURPLE_GERMLINE_DESC));
    template.addMetaDataLine(new VCFInfoHeaderLine(PURPLE_BIALLELIC_FLAG, 0, VCFHeaderLineType.Flag, PURPLE_BIALLELIC_DESC));

    return template;
}
 
Example 17
Source File: AnnotateStrelkaWithAllelicDepth.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
private VCFHeader generateOutputHeader(@NotNull final VCFHeader template) {
    final VCFHeader outputVCFHeader = new VCFHeader(template.getMetaDataInInputOrder(), template.getGenotypeSamples());
    outputVCFHeader.addMetaDataLine(VCFStandardHeaderLines.getFormatLine("AD"));
    return outputVCFHeader;
}
 
Example 18
Source File: SageMetaData.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
public static VCFHeader addSageMetaData(@NotNull final VCFHeader header) {
    header.addMetaDataLine(new VCFInfoHeaderLine(TIER, 1, VCFHeaderLineType.String, TIER_DESCRIPTION));
    header.addMetaDataLine(new VCFInfoHeaderLine(PHASED_INFRAME_INDEL, 1, VCFHeaderLineType.Integer, PHASED_INFRAME_INDEL_DESCRIPTION));
    return header;
}
 
Example 19
Source File: CopyNumberTriStateAllele.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Adds the alternative allele ALT meta-data lines to a vcf-header.
 * @param header the header to add the lines to.
 * @throws IllegalArgumentException if {@code header} is {@code null}.
 */
public static void addHeaderLinesTo(final VCFHeader header) {
    Utils.nonNull(header);
    header.addMetaDataLine(new VCFSimpleHeaderLine(ALT_KEY, DEL.getBaseString(), Utils.nonNull(DEL_VCF_DESCRIPTION)));
    header.addMetaDataLine(new VCFSimpleHeaderLine(ALT_KEY, DUP.getBaseString(), Utils.nonNull(DUP_VCF_DESCRIPTION)));
}