use of htsjdk.variant.vcf.VCFHeader in project gatk by broadinstitute.
the class UpdateVCFSequenceDictionaryIntegrationTest method testGoodUpdateSequenceDictionary.
@Test(dataProvider = "UpdateGoodSequenceDictionaryData")
private void testGoodUpdateSequenceDictionary(final File inputVariantsFile, final File inputSourceFile, final File inputReferenceFile, final boolean replace) throws FileNotFoundException {
final SAMSequenceDictionary resultingDictionary = updateSequenceDictionary(inputVariantsFile, inputSourceFile, inputReferenceFile, replace);
// get the original sequence dictionary from the source for comparison
SAMSequenceDictionary sourceDictionary = SAMSequenceDictionaryExtractor.extractDictionary(inputSourceFile == null ? inputReferenceFile : inputSourceFile);
// Some sequence dictionary sources will contain optional attributes (i.e., if the source is a .dict file,
// or if only a reference is presented to the tool using -R, which will in turn cause the framework to retrieve
// the dictionary from the .dict file accompanying the reference, the dictionary will likely include md5 and
// UR attributes). However, htsjdk doesn't propagate these attributes to the VCF header properly
// (https://github.com/samtools/htsjdk/issues/730), and many are stripped out. In order to ensure the
// roundtrip comparison succeeds, roundtrip it through a VCF header to match what htsjdk will have written out.
VCFHeader sourceVCFHeader = new VCFHeader();
sourceVCFHeader.setSequenceDictionary(sourceDictionary);
sourceDictionary = sourceVCFHeader.getSequenceDictionary();
Assert.assertEquals(sourceDictionary, resultingDictionary);
}
use of htsjdk.variant.vcf.VCFHeader in project gatk by broadinstitute.
the class GVCFWriterUnitTest method testHeaderWriting.
@Test
public void testHeaderWriting() {
final MockWriter mockWriter = new MockWriter();
final GVCFWriter writer = new GVCFWriter(mockWriter, standardPartition, HomoSapiensConstants.DEFAULT_PLOIDY);
writer.writeHeader(new VCFHeader());
Assert.assertTrue(mockWriter.headerWritten);
}
use of htsjdk.variant.vcf.VCFHeader 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.VCFHeader in project gatk by broadinstitute.
the class MultiVariantWalkerIntegrationTest method testGetCompatibleHeader.
@Test
public void testGetCompatibleHeader() throws Exception {
final TestMultiVariantWalker tool = new TestMultiVariantWalker();
final List<String> args = new ArrayList<>();
File testFile1 = new File(getTestDataDir(), "interleavedVariants_1.vcf");
args.add("--variant");
args.add(testFile1.getAbsolutePath());
File testFile2 = new File(getTestDataDir(), "interleavedVariants_2.vcf");
args.add("--variant");
args.add(testFile2.getAbsolutePath());
tool.instanceMain(args.toArray(new String[args.size()]));
VCFHeader header = tool.getHeaderForVariants();
Assert.assertEquals(header.getSequenceDictionary().getSequences().size(), 4);
}
use of htsjdk.variant.vcf.VCFHeader in project gatk by broadinstitute.
the class SVVCFWriter method getVcfHeader.
private static VCFHeader getVcfHeader(final SAMSequenceDictionary referenceSequenceDictionary) {
final VCFHeader header = new VCFHeader(new HashSet<>(GATKSVVCFHeaderLines.vcfHeaderLines.values()));
header.setSequenceDictionary(referenceSequenceDictionary);
header.addMetaDataLine(VCFStandardHeaderLines.getInfoLine(VCFConstants.END_KEY));
return header;
}
Aggregations