use of htsjdk.variant.vcf.VCFHeaderLine in project gatk by broadinstitute.
the class VcfUtilsUnitTest method testUpdateContigsReferenceNameOnly.
@Test(dataProvider = "testData")
public void testUpdateContigsReferenceNameOnly(final Set<VCFHeaderLine> inHeaderLines, final SAMSequenceDictionary seqDict, final File referenceFile, final boolean refNameOnly, final String expectedRefName) {
Set<VCFHeaderLine> resultLines = VcfUtils.updateHeaderContigLines(inHeaderLines, referenceFile, seqDict, refNameOnly);
Assert.assertEquals(resultLines.size(), referenceFile == null ? 2 : 3);
for (VCFHeaderLine resultLine : resultLines) {
if (resultLine instanceof VCFContigHeaderLine) {
VCFContigHeaderLine headerLine = (VCFContigHeaderLine) resultLine;
SAMSequenceRecord samSeqRec = headerLine.getSAMSequenceRecord();
if (samSeqRec.getSequenceName().equals("contig1")) {
Assert.assertEquals(samSeqRec.getSequenceLength(), 100);
} else if (samSeqRec.getSequenceName().equals("contig2")) {
Assert.assertEquals(samSeqRec.getSequenceLength(), 200);
} else {
Assert.fail("Bad sequence name in header lines");
}
} else {
if (referenceFile != null) {
Assert.assertEquals(resultLine.getValue(), expectedRefName);
} else {
Assert.fail("Unexpected reference name in header lines");
}
}
}
}
use of htsjdk.variant.vcf.VCFHeaderLine in project gatk-protected by broadinstitute.
the class Concordance method onTraversalStart.
@Override
public void onTraversalStart() {
Set<VCFHeaderLine> defaultToolHeaderLines = getDefaultToolVCFHeaderLines();
for (final ConcordanceState state : ConcordanceState.values()) {
snpCounts.put(state, new MutableLong(0));
indelCounts.put(state, new MutableLong(0));
}
if (truePositivesAndFalseNegativesVcf != null) {
truePositivesAndFalseNegativesVcfWriter = createVCFWriter(truePositivesAndFalseNegativesVcf);
final VCFHeader truthHeader = getTruthHeader();
truthHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
defaultToolHeaderLines.forEach(truthHeader::addMetaDataLine);
truePositivesAndFalseNegativesVcfWriter.writeHeader(truthHeader);
}
if (truePositivesAndFalsePositivesVcf != null) {
truePositivesAndFalsePositivesVcfWriter = createVCFWriter(truePositivesAndFalsePositivesVcf);
final VCFHeader evalHeader = getEvalHeader();
defaultToolHeaderLines.forEach(evalHeader::addMetaDataLine);
evalHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
truePositivesAndFalsePositivesVcfWriter.writeHeader(evalHeader);
}
if (filteredTrueNegativesAndFalseNegativesVcf != null) {
filteredTrueNegativesAndFalseNegativesVcfWriter = createVCFWriter(filteredTrueNegativesAndFalseNegativesVcf);
final VCFHeader evalHeader = getEvalHeader();
evalHeader.addMetaDataLine(TRUTH_STATUS_HEADER_LINE);
defaultToolHeaderLines.forEach(evalHeader::addMetaDataLine);
filteredTrueNegativesAndFalseNegativesVcfWriter.writeHeader(evalHeader);
}
}
use of htsjdk.variant.vcf.VCFHeaderLine in project gatk-protected by broadinstitute.
the class HaplotypeCallerEngine method writeHeader.
/**
* Writes an appropriate VCF header, given our arguments, to the provided writer
*
* @param vcfWriter writer to which the header should be written
*/
public void writeHeader(final VariantContextWriter vcfWriter, final SAMSequenceDictionary sequenceDictionary, final Set<VCFHeaderLine> defaultToolHeaderLines) {
Utils.nonNull(vcfWriter);
final Set<VCFHeaderLine> headerInfo = new HashSet<>();
headerInfo.addAll(defaultToolHeaderLines);
headerInfo.addAll(genotypingEngine.getAppropriateVCFInfoHeaders());
// all annotation fields from VariantAnnotatorEngine
headerInfo.addAll(annotationEngine.getVCFAnnotationDescriptions());
// all callers need to add these standard annotation header lines
headerInfo.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.DOWNSAMPLED_KEY));
headerInfo.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.MLE_ALLELE_COUNT_KEY));
headerInfo.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.MLE_ALLELE_FREQUENCY_KEY));
// all callers need to add these standard FORMAT field header lines
VCFStandardHeaderLines.addStandardFormatLines(headerInfo, true, VCFConstants.GENOTYPE_KEY, VCFConstants.GENOTYPE_QUALITY_KEY, VCFConstants.DEPTH_KEY, VCFConstants.GENOTYPE_PL_KEY);
if (!hcArgs.doNotRunPhysicalPhasing) {
headerInfo.add(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.HAPLOTYPE_CALLER_PHASING_ID_KEY));
headerInfo.add(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.HAPLOTYPE_CALLER_PHASING_GT_KEY));
}
// FILTER fields are added unconditionally as it's not always 100% certain the circumstances
// where the filters are used. For example, in emitting all sites the lowQual field is used
headerInfo.add(GATKVCFHeaderLines.getFilterLine(GATKVCFConstants.LOW_QUAL_FILTER_NAME));
if (emitReferenceConfidence()) {
headerInfo.addAll(referenceConfidenceModel.getVCFHeaderLines());
}
final VCFHeader vcfHeader = new VCFHeader(headerInfo, sampleSet);
vcfHeader.setSequenceDictionary(sequenceDictionary);
vcfWriter.writeHeader(vcfHeader);
}
use of htsjdk.variant.vcf.VCFHeaderLine in project gatk-protected by broadinstitute.
the class AnnotateVcfWithExpectedAlleleFraction method onTraversalStart.
@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();
}
use of htsjdk.variant.vcf.VCFHeaderLine in project gatk-protected by broadinstitute.
the class FilterMutectCalls method onTraversalStart.
@Override
public void onTraversalStart() {
final VCFHeader inputHeader = getHeaderForVariants();
final Set<VCFHeaderLine> headerLines = new HashSet<>(inputHeader.getMetaDataInSortedOrder());
Mutect2FilteringEngine.M_2_FILTER_NAMES.stream().map(GATKVCFHeaderLines::getFilterLine).forEach(headerLines::add);
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.ARTIFACT_IN_NORMAL_FILTER_NAME, "artifact_in_normal"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_BASE_QUALITY_DIFFERENCE_FILTER_NAME, "ref - alt median base quality"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_MAPPING_QUALITY_DIFFERENCE_FILTER_NAME, "ref - alt median mapping quality"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_CLIPPING_DIFFERENCE_FILTER_NAME, "ref - alt median clipping"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_FRAGMENT_LENGTH_DIFFERENCE_FILTER_NAME, "abs(ref - alt) median fragment length"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.READ_POSITION_FILTER_NAME, "median distance of alt variants from end of reads"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.CONTAMINATION_FILTER_NAME, "contamination"));
headerLines.addAll(getDefaultToolVCFHeaderLines());
final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
vcfWriter = createVCFWriter(new File(outputVcf));
vcfWriter.writeHeader(vcfHeader);
}
Aggregations