Package htsjdk.variant.vcf
Class VCFHeader
java.lang.Object
htsjdk.variant.vcf.VCFHeader
- All Implemented Interfaces:
HtsHeader
,Serializable
A class to represent a VCF header
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate an empty VCF header with no header lines and no samplesCreates a deep copy of the given VCFHeader, duplicating all its metadata and sample names.VCFHeader
(VCFHeaderVersion vcfHeaderVersion, Set<VCFHeaderLine> metaData, Set<String> genotypeSampleNames) create a VCF header, given a target version, a list of meta data and auxiliary tagsVCFHeader
(Set<VCFHeaderLine> metaData) create a VCF header, given a list of meta data and auxiliary tagsVCFHeader
(Set<VCFHeaderLine> metaData, List<String> genotypeSampleNames) VCFHeader
(Set<VCFHeaderLine> metaData, Set<String> genotypeSampleNames) create a VCF header, given a list of meta data and auxiliary tags -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetaDataLine
(VCFHeaderLine headerLine) Adds a new line to the VCFHeader.int
Returns the FORMAT HeaderLines in their original orderingget the genotyping sample namesget the header fields in order they're presented in the input file (which is now required to be the order presented in the spec).Returns the INFO HeaderLines in their original orderingget the meta data, associated with this header, in sorted ordergetMetaDataLine
(String key) Get the VCFHeaderLine whose key equals key.int
getOtherHeaderLine
(String key) Returns the other HeaderLines in their original orderingGet the genotype sample names, sorted in ascending order.Returns the contigs in this VCF file as a SAMSequenceDictionary.boolean
hasFilterLine
(String id) boolean
hasFormatLine
(String id) boolean
do we have genotyping data?boolean
hasInfoLine
(String id) boolean
If true, and isWriteEngineHeaders also returns true, the command line will be written to the VCF.boolean
If true additional engine headers will be written to the VCF, otherwise only the walker headers will be output.boolean
were the input samples sorted originally?void
setSequenceDictionary
(SAMSequenceDictionary dictionary) Completely replaces the contig records in this header with those in the given SAMSequenceDictionary.void
setVCFHeaderVersion
(VCFHeaderVersion vcfHeaderVersion) Establish the header version for this header.void
setWriteCommandLine
(boolean writeCommandLine) If true, and isWriteEngineHeaders also returns true, the command line will be written to the VCF.void
setWriteEngineHeaders
(boolean writeEngineHeaders) If true additional engine headers will be written to the VCF, otherwise only the walker headers will be output.toString()
static void
validateVersionTransition
(VCFHeaderVersion fromVersion, VCFHeaderVersion toVersion) Throw iffromVersion
is not compatible with atoVersion
.
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
METADATA_INDICATOR
- See Also:
-
HEADER_INDICATOR
- See Also:
-
SOURCE_KEY
- See Also:
-
REFERENCE_KEY
- See Also:
-
CONTIG_KEY
- See Also:
-
INTERVALS_KEY
- See Also:
-
EXCLUDE_INTERVALS_KEY
- See Also:
-
INTERVAL_MERGING_KEY
- See Also:
-
INTERVAL_SET_RULE_KEY
- See Also:
-
INTERVAL_PADDING_KEY
- See Also:
-
-
Constructor Details
-
VCFHeader
public VCFHeader()Create an empty VCF header with no header lines and no samples -
VCFHeader
create a VCF header, given a list of meta data and auxiliary tags- Parameters:
metaData
- the meta data associated with this header
-
VCFHeader
Creates a deep copy of the given VCFHeader, duplicating all its metadata and sample names. -
VCFHeader
create a VCF header, given a list of meta data and auxiliary tags- Parameters:
metaData
- the meta data associated with this headergenotypeSampleNames
- the sample names
-
VCFHeader
public VCFHeader(VCFHeaderVersion vcfHeaderVersion, Set<VCFHeaderLine> metaData, Set<String> genotypeSampleNames) create a VCF header, given a target version, a list of meta data and auxiliary tags- Parameters:
vcfHeaderVersion
- the vcf header version for this header, can not be nullmetaData
- the meta data associated with this headergenotypeSampleNames
- the sample names
-
VCFHeader
-
-
Method Details
-
setVCFHeaderVersion
Establish the header version for this header. If the header version has already been established for this header, the new version will be subject to version transition validation.- Parameters:
vcfHeaderVersion
-- Throws:
TribbleException
- if the requested header version is not compatible with the existing version
-
validateVersionTransition
public static void validateVersionTransition(VCFHeaderVersion fromVersion, VCFHeaderVersion toVersion) Throw iffromVersion
is not compatible with atoVersion
. Generally, any version before version 4.2 can be up-converted to version 4.2, but not to version 4.3. Once a header is established as version 4.3, it cannot be up or down converted, and it must remain at version 4.3.- Parameters:
fromVersion
- current version. May be null, in which casetoVersion
can be any versiontoVersion
- new version. Cannot be null.- Throws:
TribbleException
- iffromVersion
is not compatible withtoVersion
-
getVCFHeaderVersion
- Returns:
- the VCFHeaderVersion for this header. Can be null.
-
addMetaDataLine
Adds a new line to the VCFHeader. If there is an existing header line of the same type with the same key, the new line is not added and the existing line is preserved.- Parameters:
headerLine
- header line to attempt to add
-
getContigLines
- Returns:
- all of the VCF header lines of the ##contig form in order, or an empty list if none were present
-
getSequenceDictionary
Returns the contigs in this VCF file as a SAMSequenceDictionary. Returns null if contigs lines are not present in the header. If contig lines are missing length tags, they will be created with length set to SAMSequenceRecord.UNKNOWN_SEQUENCE_LENGTH. Records with unknown length will match any record with the same name when evaluated by SAMSequenceRecord.isSameSequence. -
setSequenceDictionary
Completely replaces the contig records in this header with those in the given SAMSequenceDictionary. -
getVCFRecordComparator
-
getFilterLines
- Returns:
- all of the VCF FILTER lines in their original file order, or an empty list if none were present
-
getIDHeaderLines
- Returns:
- all of the VCF ID-based header lines in their original file order, or an empty list if none were present
-
getHeaderFields
get the header fields in order they're presented in the input file (which is now required to be the order presented in the spec).- Returns:
- a set of the header fields, in order
-
getMetaDataInInputOrder
get the meta data, associated with this header, in sorted order- Returns:
- a set of the meta data
-
getMetaDataInSortedOrder
-
getMetaDataLine
Get the VCFHeaderLine whose key equals key. Returns null if no such line exists- Parameters:
key
-- Returns:
-
getGenotypeSamples
get the genotyping sample names- Returns:
- a list of the genotype column names, which may be empty if hasGenotypingData() returns false
-
getNGenotypeSamples
public int getNGenotypeSamples() -
hasGenotypingData
public boolean hasGenotypingData()do we have genotyping data?- Returns:
- true if we have genotyping columns, false otherwise
-
samplesWereAlreadySorted
public boolean samplesWereAlreadySorted()were the input samples sorted originally?- Returns:
- true if the input samples were sorted originally, false otherwise
-
getColumnCount
public int getColumnCount()- Returns:
- the column count
-
getInfoHeaderLines
Returns the INFO HeaderLines in their original ordering -
getFormatHeaderLines
Returns the FORMAT HeaderLines in their original ordering -
getInfoHeaderLine
- Parameters:
id
- the header key name- Returns:
- the meta data line, or null if there is none
-
getFormatHeaderLine
- Parameters:
id
- the header key name- Returns:
- the meta data line, or null if there is none
-
getFilterHeaderLine
- Parameters:
id
- the header key name- Returns:
- the meta data line, or null if there is none
-
hasInfoLine
-
hasFormatLine
-
hasFilterLine
-
getOtherHeaderLine
- Parameters:
key
- the header key name- Returns:
- the meta data line, or null if there is none
-
getOtherHeaderLines
Returns the other HeaderLines in their original ordering -
isWriteEngineHeaders
public boolean isWriteEngineHeaders()If true additional engine headers will be written to the VCF, otherwise only the walker headers will be output.- Returns:
- true if additional engine headers will be written to the VCF
-
setWriteEngineHeaders
public void setWriteEngineHeaders(boolean writeEngineHeaders) If true additional engine headers will be written to the VCF, otherwise only the walker headers will be output.- Parameters:
writeEngineHeaders
- true if additional engine headers will be written to the VCF
-
isWriteCommandLine
public boolean isWriteCommandLine()If true, and isWriteEngineHeaders also returns true, the command line will be written to the VCF.- Returns:
- true if the command line will be written to the VCF
-
setWriteCommandLine
public void setWriteCommandLine(boolean writeCommandLine) If true, and isWriteEngineHeaders also returns true, the command line will be written to the VCF.- Parameters:
writeCommandLine
- true if the command line will be written to the VCF
-
getSampleNamesInOrder
Get the genotype sample names, sorted in ascending order. Note: this will not necessarily match the order in the VCF.- Returns:
- The sorted genotype samples. May be empty if hasGenotypingData() returns false.
-
getSampleNameToOffset
-
toString
-