htsjdk.variant.vcf.VCFHeaderLineType Java Examples

The following examples show how to use htsjdk.variant.vcf.VCFHeaderLineType. 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: AnnotateVcfWithExpectedAlleleFraction.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onTraversalStart() {
    final VCFHeader inputHeader = getHeaderForVariants();
    final Set<VCFHeaderLine> headerLines = new HashSet<>(inputHeader.getMetaDataInSortedOrder());
    headerLines.add(new VCFInfoHeaderLine(EXPECTED_ALLELE_FRACTION_NAME, 1, VCFHeaderLineType.Float, "expected allele fraction in pooled bam"));
    final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
    headerLines.addAll(getDefaultToolVCFHeaderLines());
    vcfWriter = createVCFWriter(outputVcf);
    vcfWriter.writeHeader(vcfHeader);

    final List<MixingFraction> mixingFractionsList = MixingFraction.readMixingFractions(inputMixingFractions);
    final Map<String, Double> mixingfractionsMap = mixingFractionsList.stream()
            .collect(Collectors.toMap(MixingFraction::getSample, MixingFraction::getMixingFraction));
    mixingFractionsInSampleOrder = inputHeader.getSampleNamesInOrder().stream()
            .mapToDouble(mixingfractionsMap::get).toArray();
}
 
Example #2
Source File: ReblockGVCFIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testMQHeadersAreUpdated() throws Exception {
    final File output = createTempFile("reblockedgvcf", ".vcf");
    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("V", getToolTestDataDir() + "justHeader.g.vcf")
            .addOutput(output);
    runCommandLine(args);

    Pair<VCFHeader, List<VariantContext>> actual = VariantContextTestUtils.readEntireVCFIntoMemory(output.getAbsolutePath());
    VCFHeader header = actual.getLeft();
    List<VCFInfoHeaderLine> infoLines = new ArrayList<>(header.getInfoHeaderLines());
    //check all the headers in case there's one old and one updated
    for (final VCFInfoHeaderLine line : infoLines) {
        if (line.getID().equals(GATKVCFConstants.RAW_RMS_MAPPING_QUALITY_DEPRECATED)) {
            Assert.assertTrue(line.getType().equals(VCFHeaderLineType.Float));
            Assert.assertTrue(line.getDescription().contains("deprecated"));
        } else if (line.getID().equals(GATKVCFConstants.MAPPING_QUALITY_DEPTH_DEPRECATED)) {
            Assert.assertTrue(line.getDescription().contains("deprecated"));
        }
    }
}
 
Example #3
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 #4
Source File: VcfToVariant.java    From genomewarp with Apache License 2.0 6 votes vote down vote up
private static Value createTypedValue(VCFHeaderLineType type, Object value) {
  if (type == VCFHeaderLineType.Flag) {
    return Value.newBuilder().setBoolValue((Boolean) value).build();
  }

  // Booleans are given as Boolean objects. Strangely, Floats and Integers
  // are given as String objects by HTSJDK.
  if (!(value instanceof String)) {
    throw new IllegalStateException("Received non-Boolean, non-List type in non-String format. "
        + "This is most likely due to a change in htsjdk's library.");
  }

  String stringValue = (String) value;
  boolean isNumeric = stringValue.matches("[-+]?\\d+(\\.\\d+)?");

  if (type == VCFHeaderLineType.Integer && isNumeric) {
    return Value.newBuilder().setNumberValue(Integer.parseInt(stringValue)).build();
  }

  if (type == VCFHeaderLineType.Float && isNumeric) {
    return Value.newBuilder().setNumberValue(Double.parseDouble(stringValue)).build();
  }


  return Value.newBuilder().setStringValue(stringValue).build();
}
 
Example #5
Source File: AnnotateVcfWithExpectedAlleleFraction.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onTraversalStart() {
    final VCFHeader inputHeader = getHeaderForVariants();
    final Set<VCFHeaderLine> headerLines = new HashSet<>(inputHeader.getMetaDataInSortedOrder());
    headerLines.add(new VCFInfoHeaderLine(EXPECTED_ALLELE_FRACTION_NAME, 1, VCFHeaderLineType.Float, "expected allele fraction in pooled bam"));
    final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
    headerLines.addAll(getDefaultToolVCFHeaderLines());
    vcfWriter = createVCFWriter(outputVcf);
    vcfWriter.writeHeader(vcfHeader);

    final List<MixingFraction> mixingFractionsList = MixingFraction.readMixingFractions(inputMixingFractions);
    final Map<String, Double> mixingfractionsMap = mixingFractionsList.stream()
            .collect(Collectors.toMap(MixingFraction::getSample, MixingFraction::getMixingFraction));
    mixingFractionsInSampleOrder = inputHeader.getSampleNamesInOrder().stream()
            .mapToDouble(mixingfractionsMap::get).toArray();
}
 
Example #6
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 #7
Source File: FuncotationMetadataUtils.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param fieldNames Never {@code null}
 * @return {@link FuncotationMetadata} with values populated indicating that we do not really know the metadata.
 * And type is a String.  Never {@code null}
 */
public static FuncotationMetadata createWithUnknownAttributes(final List<String> fieldNames) {
    Utils.nonNull(fieldNames);
    return VcfFuncotationMetadata.create(
            fieldNames.stream().map(f -> new VCFInfoHeaderLine(f, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, UNKNOWN_DESCRIPTION))
                    .collect(Collectors.toList())
    );
}
 
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: FindMendelianViolations.java    From picard with MIT License 5 votes vote down vote up
private void writeAllViolations(final MendelianViolationDetector.Result result) {
    if (VCF_DIR != null) {
        LOG.info(String.format("Writing family violation VCFs to %s/", VCF_DIR.getAbsolutePath()));

        final VariantContextComparator vcComparator = new VariantContextComparator(inputHeader.get().getContigLines());
        final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputHeader.get().getMetaDataInInputOrder());

        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.MENDELIAN_VIOLATION_KEY, 1, VCFHeaderLineType.String, "Type of mendelian violation."));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AC, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC"));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AF, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF"));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AN, 1, VCFHeaderLineType.Integer, "Original AN"));

        for (final PedFile.PedTrio trio : pedFile.get().values()) {
            final File outputFile = new File(VCF_DIR, IOUtil.makeFileNameSafe(trio.getFamilyId() + IOUtil.VCF_FILE_EXTENSION));
            LOG.info(String.format("Writing %s violation VCF to %s", trio.getFamilyId(), outputFile.getAbsolutePath()));

            final VariantContextWriter out = new VariantContextWriterBuilder()
                    .setOutputFile(outputFile)
                    .unsetOption(INDEX_ON_THE_FLY)
                    .build();

            final VCFHeader newHeader = new VCFHeader(headerLines, CollectionUtil.makeList(trio.getMaternalId(), trio.getPaternalId(), trio.getIndividualId()));
            final TreeSet<VariantContext> orderedViolations = new TreeSet<>(vcComparator);

            orderedViolations.addAll(result.violations().get(trio.getFamilyId()));
            out.writeHeader(newHeader);
            orderedViolations.forEach(out::add);

            out.close();
        }
    }
}
 
Example #10
Source File: GATKRegistrator.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Make sure that all FuncotationMap (which incl. all Funcotation concrete classes and members) classes are registered
 *  to support {@link org.broadinstitute.hellbender.tools.funcotator.FuncotationMap#create(FuncotationMap)}
 *
 * @param kryo Kryo instance to update in-place.  Never {@code null}
 */
@VisibleForTesting
public static void registerFuncotationMapDependencies(final Kryo kryo) {
    Utils.nonNull(kryo);
    Registration registration = kryo.register(TableFuncotation.class);
    registration.setInstantiator(new ObjectInstantiator<TableFuncotation>() {
        public TableFuncotation newInstance() {
            return TableFuncotation.create(new LinkedHashMap<>(), Allele.UNSPECIFIED_ALTERNATE_ALLELE, "TEMP", null);
        }
    });
    registration = kryo.register(VcfFuncotationMetadata.class);
    registration.setInstantiator(new ObjectInstantiator<VcfFuncotationMetadata>() {
        public VcfFuncotationMetadata newInstance() {
            return VcfFuncotationMetadata.create(new ArrayList<>());
        }
    });
    registration = kryo.register(VCFInfoHeaderLine.class);
    registration.setInstantiator(new ObjectInstantiator<VCFInfoHeaderLine>() {
        public VCFInfoHeaderLine newInstance() {
            return new VCFInfoHeaderLine("TMP", 2, VCFHeaderLineType.String, "");
        }
    });
    registration = kryo.register(Allele.class);
    registration.setInstantiator(new ObjectInstantiator<Allele>() {
        public Allele newInstance() {
            return Allele.create("TCGA");
        }
    });
}
 
Example #11
Source File: FuncotateSegments.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private FuncotationMetadata createMetadata() {
    return VcfFuncotationMetadata.create(
            Arrays.asList(
                    new VCFInfoHeaderLine("Segment_Mean",1, VCFHeaderLineType.Float, "Mean for the segment.  Units will be the same as the input file."),
                    new VCFInfoHeaderLine("Num_Probes",1, VCFHeaderLineType.Integer, "Number of probes/targets/bins overlapping the segment."),
                    new VCFInfoHeaderLine("Segment_Call",1, VCFHeaderLineType.String, "Segment call (whether the segment is amplified, deleted, etc)."),
                    new VCFInfoHeaderLine("Sample",1, VCFHeaderLineType.String, "Sample name for the segment."),
                    new VCFInfoHeaderLine("build",1, VCFHeaderLineType.String, "Genome build (e.g. 'hg19' or 'hg38').")
            )
    );
}
 
Example #12
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 #13
Source File: CustomMafFuncotationCreator.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static FuncotationMetadata createCustomMafCountFieldsMetadata() {
    return VcfFuncotationMetadata.create(Arrays.asList(
            new VCFInfoHeaderLine(COUNT_FIELD_NAMES.get(0), VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Number of alternate reads in the tumor."),
            new VCFInfoHeaderLine(COUNT_FIELD_NAMES.get(1), VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Number of reference reads in the tumor."),
            new VCFInfoHeaderLine(COUNT_FIELD_NAMES.get(2), VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Number of alternate reads in the normal."),
            new VCFInfoHeaderLine(COUNT_FIELD_NAMES.get(3), VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Number of reference reads in the normal."),
            new VCFInfoHeaderLine(COUNT_FIELD_NAMES.get(4), VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Allele fractions of alternate alleles in the tumor.")
    ));
}
 
Example #14
Source File: GencodeFuncotationFactory.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Return the metadata for segment annotations.
 *
 * @return Never {@code null}
 */
private FuncotationMetadata createSegmentFuncotationMetadata() {
    return VcfFuncotationMetadata.create(
            Arrays.asList(
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + GENES_SUFFIX,1, VCFHeaderLineType.String, "The genes overlapping the segment.  Blank if none."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + START_GENE_SUFFIX,1, VCFHeaderLineType.String, "The genes overlapping the start of the segment.  Blank if none."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + END_GENE_SUFFIX,1, VCFHeaderLineType.String, "The genes overlapping the end of the segment.  Blank if none."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + START_EXON_SUFFIX,1, VCFHeaderLineType.String, "The genes overlapping the start of the segment.  Blank if none."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + END_EXON_SUFFIX,1, VCFHeaderLineType.String, "The genes overlapping the end of the segment.  Blank if none."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + "_alt_allele",1, VCFHeaderLineType.String, "Always blank.  Included for legacy reasons."),
                    new VCFInfoHeaderLine(getName() + "_" + getVersion() + "_ref_allele",1, VCFHeaderLineType.String, "Always blank.  Included for legacy reasons.")
            )
    );
}
 
Example #15
Source File: SimpleTsvOutputRendererUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static FuncotationMetadata createDummySegmentFuncotationMetadata() {
    return VcfFuncotationMetadata.create(
            Arrays.asList(
                    new VCFInfoHeaderLine("Gencode_19_genes", 1, VCFHeaderLineType.String, "The genes overlapping the segment."),
                    new VCFInfoHeaderLine("foo1", 1, VCFHeaderLineType.String, "foo1"),
                    new VCFInfoHeaderLine("foobar2", 1, VCFHeaderLineType.String, "foobar2 (an alias relative to the config file)"),
                    new VCFInfoHeaderLine("TEST3", 1, VCFHeaderLineType.String, "Note that this has no spaces"),
                    new VCFInfoHeaderLine("foo3!!", 1, VCFHeaderLineType.String, "special character....")
            )
    );
}
 
Example #16
Source File: SimpleTsvOutputRendererUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private FuncotationMap createSimpleFuncotationMap() {
    return FuncotationMap.createNoTranscriptInfo(
            Collections.singletonList(
                    TableFuncotation.create(Collections.singletonList(FUNCOTATION_FIELD_1), Collections.singletonList("value1"),
                            AnnotatedIntervalToSegmentVariantContextConverter.COPY_NEUTRAL_ALLELE,
                            "TEST",
                            VcfFuncotationMetadata.create(
                                    Collections.singletonList(
                                            new VCFInfoHeaderLine(FUNCOTATION_FIELD_1, 1, VCFHeaderLineType.String, "Unknown")))
                    )));
}
 
Example #17
Source File: GenomicsDBImportIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static File createInputVCF(final String sampleName) {
    final String contig = "chr20";
    final SAMSequenceDictionary dict = new SAMSequenceDictionary(
            Collections.singletonList(new SAMSequenceRecord(contig, 64444167)));

    final VCFFormatHeaderLine formatField = new VCFFormatHeaderLine(SAMPLE_NAME_KEY, 1, VCFHeaderLineType.String,
                                                                    "the name of the sample this genotype came from");
    final Set<VCFHeaderLine> headerLines = new HashSet<>();
    headerLines.add(formatField);
    headerLines.add(new VCFFormatHeaderLine(ANOTHER_ATTRIBUTE_KEY, 1, VCFHeaderLineType.Integer, "Another value"));
    headerLines.add(VCFStandardHeaderLines.getFormatLine("GT"));

    final File out = createTempFile(sampleName +"_", ".vcf");
    try (final VariantContextWriter writer = GATKVariantContextUtils.createVCFWriter(out.toPath(), dict, false,
                                                                                     Options.INDEX_ON_THE_FLY)) {
        final VCFHeader vcfHeader = new VCFHeader(headerLines, Collections.singleton(sampleName));
        vcfHeader.setSequenceDictionary(dict);
        writer.writeHeader(vcfHeader);
        final Allele Aref = Allele.create("A", true);
        final Allele C = Allele.create("C");
        final List<Allele> alleles = Arrays.asList(Aref, C);
        final VariantContext variant = new VariantContextBuilder("invented", contig, INTERVAL.get(0).getStart(), INTERVAL.get(0).getStart(), alleles)
                .genotypes(new GenotypeBuilder(sampleName, alleles).attribute(SAMPLE_NAME_KEY, sampleName)
                                   .attribute(ANOTHER_ATTRIBUTE_KEY, 10).make())
                .make();
        writer.add(variant);
        return out;
    }
}
 
Example #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
Source File: VcfToVariant.java    From genomewarp with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static Map<String, ListValue> getInfo(VariantContext vc, VCFHeader header) {
  Map<String, ListValue> toReturn = new HashMap<>();

  for (Map.Entry<String, Object> entry : vc.getAttributes().entrySet()) {
    String currKey = entry.getKey();
    VCFInfoHeaderLine metaData = header.getInfoHeaderLine(currKey);

    // All info fields must have a corresponding header field.
    if (metaData == null) {
      logger.log(Level.WARNING, String.format("Could not find matching VCF header field, "
          + "skipping info field %s", currKey));
      continue;
    }

    Object currObject = entry.getValue();
    ListValue.Builder listValueBuilder = ListValue.newBuilder();

    VCFHeaderLineType type = metaData.getType();
    if (!(currObject instanceof List)) {
      toReturn.put(currKey,
          listValueBuilder.addValues(createTypedValue(type, currObject)).build());
      continue;
    }

    List<Object> currObjectList = (List<Object>) currObject;
    for (Object currObj : currObjectList) {
      listValueBuilder.addValues(createTypedValue(type, currObj));
    }
    toReturn.put(currKey, listValueBuilder.build());
  }

  return toReturn;
}
 
Example #27
Source File: VariantToVcf.java    From genomewarp with Apache License 2.0 5 votes vote down vote up
private static Object getNumberValue(double numValue, VCFHeaderLineType type) {
  if (String.valueOf(numValue).matches("[-+]?\\d+(\\.\\d+)?")) {
    switch (type) {
        case Integer: return String.format("%d", (int) numValue);
        case Float: return String.format("%s", numValue);
        default: break;
    }
  }
  return String.valueOf(numValue);
}
 
Example #28
Source File: VariantToVcf.java    From genomewarp with Apache License 2.0 5 votes vote down vote up
private static Object parseObject(String key, Value in, VCFHeaderLineType type) {
  // Case on type
  switch (in.getKindCase()) {
      case NULL_VALUE: throw new IllegalStateException(String.format("field %s contained "
          + "a null value", key));
      case NUMBER_VALUE: return getNumberValue(in.getNumberValue(), type);
      case STRING_VALUE: return in.getStringValue();
      case BOOL_VALUE: return (Boolean) in.getBoolValue();
      default: throw new IllegalStateException(String.format("field %s contained a %s type, which"
          + " is not supported by VariantToVcf", key, getKind(in.getKindCase())));
  }
}
 
Example #29
Source File: BaseQualityHistogram.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public List<VCFInfoHeaderLine> getDescriptions() {
    return Arrays.asList(new VCFInfoHeaderLine(KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Integer,
            "Base quality counts for each allele represented sparsely as alternating entries of qualities and counts for each allele." +
            "For example [10,1,0,20,0,1] means one ref base with quality 10 and one alt base with quality 20."));
}
 
Example #30
Source File: PerAlleleAnnotation.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public List<VCFInfoHeaderLine> getDescriptions() {
    return Arrays.asList(new VCFInfoHeaderLine(getVcfKey(), includeRefAllele() ? VCFHeaderLineCount.R : VCFHeaderLineCount.A, VCFHeaderLineType.Integer, getDescription()));
}