public boolean equals(Object o) { if ( !(o instanceof VCFHeaderLine) ) return false; return mKey.equals(((VCFHeaderLine)o).getKey()) && mValue.equals(((VCFHeaderLine)o).getValue()); }
private boolean isValidSnpEffVersionAndCommandLine( final VCFHeaderLine snpEffVersionLine, final VCFHeaderLine snpEffCommandLine ){ if ( snpEffVersionLine == null || snpEffVersionLine.getValue() == null || snpEffVersionLine.getValue().trim().length() == 0 ) { logger.warn(String.format("Could not find a %s entry in the VCF header for the SnpEff input file, " + "and so could not verify that the file was generated by a supported version of SnpEff (%s)", SNPEFF_VCF_HEADER_VERSION_LINE_KEY, supportedSnpEffVersionsString())); return false; } if ( snpEffCommandLine == null || snpEffCommandLine.getValue() == null || snpEffCommandLine.getValue().trim().length() == 0 ) { logger.warn(String.format("Could not find a %s entry in the VCF header for the SnpEff input file, " + "which should be added by all supported versions of SnpEff (%s)", SNPEFF_VCF_HEADER_COMMAND_LINE_KEY, supportedSnpEffVersionsString())); return false; } String snpEffVersionString = snpEffVersionLine.getValue().replaceAll("\"", "").split(" ")[0]; if ( ! isSupportedSnpEffVersion(snpEffVersionString, snpEffCommandLine.getValue()) ) { logger.warn(String.format("The version of SnpEff used to generate the SnpEff input file (%s) " + "is not currently supported by the GATK, and was not run in GATK " + "compatibility mode. Supported versions are: %s", snpEffVersionString, supportedSnpEffVersionsString())); return false; } return true; }
public DBSNPInfo build(VCFHeader vcfHeader) { String fileDate = vcfHeader.getMetaDataLine("fileDate").getValue(); String source = vcfHeader.getMetaDataLine("source").getValue(); int dbSNPBuildID = Integer.parseInt(vcfHeader.getMetaDataLine("dbSNP_BUILD_ID").getValue()); String reference = vcfHeader.getMetaDataLine("reference").getValue(); String phasing = vcfHeader.getMetaDataLine("phasing").getValue(); return new DBSNPInfo(fileDate, source, dbSNPBuildID, reference, phasing); }
public static VCFHeaderVersion getVCFHeaderVersion(VCFHeader vcfHeader){ Iterator<VCFHeaderLine> iter = vcfHeader.getMetaDataInInputOrder().iterator(); while(iter.hasNext()){ VCFHeaderLine hl = iter.next(); if(hl.getKey().equals("fileformat")){ return VCFHeaderVersion.toHeaderVersion(hl.getValue()); } } return null; }
@Override public VcfHeader convert(VCFHeader header) { VcfHeader avroVcfHeader = new VcfHeader(); LinkedHashMap<String, List<Object>> meta = new LinkedHashMap<>(); avroVcfHeader.setMeta(meta); for (VCFHeaderLine line : header.getMetaDataInInputOrder()) { if (line.getKey().equalsIgnoreCase("fileFormat")) { avroVcfHeader.setFileFormat(line.getValue()); continue; } Object value; if (line.getValue().isEmpty()) { value = VCFHeaderLineTranslator.parseLine(VCFHeaderVersion.VCF4_2, line.toString(), null); } else { value = line.getValue(); } if (!meta.containsKey(line.getKey())) { meta.put(line.getKey(), new LinkedList<>()); } meta.get(line.getKey()).add(value); } return avroVcfHeader; }
newLines.add(new VCFHeaderLine(line.getKey(), ARGS.refTargetFASTA)); } else if (line.getKey().equals("source")) { newLines.add(new VCFHeaderLine(line.getKey(), line.getValue() + "_and_" + GENOME_WARP_VERSION)); hasSource = true; } else if (line.getKey().equals("fileformat")) { version = VCFHeaderVersion.toHeaderVersion(line.getValue()); if (version == null) { throw new IllegalArgumentException("malformed version: " + line.getValue());
private VariantSetMetadata convertHeaderLine(VCFHeaderLine hl) { VariantSetMetadata vsm = new VariantSetMetadata(); vsm.setKey(hl.getKey()); vsm.setValue(hl.getValue()); return vsm; }
@Override public void setHeader(VCFHeader header) { VCFHeaderVersion version = null; // Normally AbstractVCFCodec parses the header and thereby sets the // version field. It gets used later on so we need to set it. for (final VCFHeaderLine line : header.getMetaDataInInputOrder()) { if (VCFHeaderVersion.isFormatString(line.getKey())) { version = VCFHeaderVersion.toHeaderVersion(line.getValue()); break; } } codec.setHeaderAndVersion(header, version); }
@Override public void setHeader(VCFHeader header) { VCFHeaderVersion version = null; // Normally AbstractVCFCodec parses the header and thereby sets the // version field. It gets used later on so we need to set it. for (final VCFHeaderLine line : header.getMetaDataInInputOrder()) { if (VCFHeaderVersion.isFormatString(line.getKey())) { version = VCFHeaderVersion.toHeaderVersion(line.getValue()); break; } } codec.setHeaderAndVersion(header, version); }
@Override public void setHeader(VCFHeader header) { VCFHeaderVersion version = null; // Normally AbstractVCFCodec parses the header and thereby sets the // version field. It gets used later on so we need to set it. for (final VCFHeaderLine line : header.getMetaDataInInputOrder()) { if (VCFHeaderVersion.isFormatString(line.getKey())) { version = VCFHeaderVersion.toHeaderVersion(line.getValue()); break; } } codec.setHeaderAndVersion(header, version); }
Assert.assertTrue(line1.toString().contains(field), "Couldn't find field " + field + " in " + line1.getValue()); Assert.assertTrue(line1.toString().contains("ID=" + testEngine1.getWalkerName()));
for (VCFHeaderLine line : header.getMetaDataInInputOrder()) { if (line.getKey().equalsIgnoreCase("fileFormat")) { avroHeader.setVersion(line.getValue()); continue; if (line.getValue().isEmpty()) { if ( line instanceof VCFCompoundHeaderLine) { VCFCompoundHeaderLine vcfLine = (VCFCompoundHeaderLine) line; simpleLines.add(new VariantFileHeaderSimpleLine(line.getKey(), line.getValue()));
/** * A test to ensure that if we add a line to a VCFHeader it will persist through * a round-trip write/read cycle via VariantContextWriter/VCFFileReader */ @Test public void testModifyHeader() { final File originalVCF = new File("src/test/resources/htsjdk/variant/HiSeq.10000.vcf"); final VCFFileReader reader = new VCFFileReader(originalVCF, false); final VCFHeader header = reader.getFileHeader(); reader.close(); header.addMetaDataLine(new VCFHeaderLine("FOOBAR", "foovalue")); final File outputVCF = createTempFile("testModifyHeader", IOUtil.VCF_FILE_EXTENSION); final VariantContextWriter writer = new VariantContextWriterBuilder().setOutputFile(outputVCF).setOptions(EnumSet.of(Options.ALLOW_MISSING_FIELDS_IN_HEADER)).build(); writer.writeHeader(header); writer.close(); final VCFFileReader roundtripReader = new VCFFileReader(outputVCF, false); final VCFHeader roundtripHeader = roundtripReader.getFileHeader(); roundtripReader.close(); Assert.assertNotNull(roundtripHeader.getOtherHeaderLine("FOOBAR"), "Could not find FOOBAR header line after a write/read cycle"); Assert.assertEquals(roundtripHeader.getOtherHeaderLine("FOOBAR").getValue(), "foovalue", "Wrong value for FOOBAR header line after a write/read cycle"); }