Class VCFHeader

    • Constructor Detail

      • VCFHeader

        public VCFHeader()
        Create an empty VCF header with no header lines and no samples
      • VCFHeader

        public VCFHeader​(Set<VCFHeaderLine> metaData)
        create a VCF header, given a list of meta data and auxiliary tags
        Parameters:
        metaData - the meta data associated with this header
      • VCFHeader

        public VCFHeader​(VCFHeader toCopy)
        Creates a deep copy of the given VCFHeader, duplicating all its metadata and sample names.
      • VCFHeader

        public VCFHeader​(Set<VCFHeaderLine> metaData,
                         Set<String> genotypeSampleNames)
        create a VCF header, given a list of meta data and auxiliary tags
        Parameters:
        metaData - the meta data associated with this header
        genotypeSampleNames - 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 null
        metaData - the meta data associated with this header
        genotypeSampleNames - the sample names
    • Method Detail

      • setVCFHeaderVersion

        public void setVCFHeaderVersion​(VCFHeaderVersion vcfHeaderVersion)
        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 if fromVersion is not compatible with a toVersion. 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 case toVersion can be any version
        toVersion - new version. Cannot be null.
        Throws:
        TribbleException - if fromVersion is not compatible with toVersion
      • getVCFHeaderVersion

        public VCFHeaderVersion getVCFHeaderVersion()
        Returns:
        the VCFHeaderVersion for this header. Can be null.
      • addMetaDataLine

        public void addMetaDataLine​(VCFHeaderLine headerLine)
        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

        public List<VCFContigHeaderLine> getContigLines()
        Returns:
        all of the VCF header lines of the ##contig form in order, or an empty list if none were present
      • getSequenceDictionary

        public SAMSequenceDictionary 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

        public void setSequenceDictionary​(SAMSequenceDictionary dictionary)
        Completely replaces the contig records in this header with those in the given SAMSequenceDictionary.
      • getFilterLines

        public List<VCFFilterHeaderLine> getFilterLines()
        Returns:
        all of the VCF FILTER lines in their original file order, or an empty list if none were present
      • getIDHeaderLines

        public List<VCFIDHeaderLine> getIDHeaderLines()
        Returns:
        all of the VCF ID-based header lines in their original file order, or an empty list if none were present
      • getHeaderFields

        public Set<VCFHeader.HEADER_FIELDS> 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

        public Set<VCFHeaderLine> getMetaDataInInputOrder()
        get the meta data, associated with this header, in sorted order
        Returns:
        a set of the meta data
      • getMetaDataInSortedOrder

        public Set<VCFHeaderLine> getMetaDataInSortedOrder()
      • getMetaDataLine

        public VCFHeaderLine getMetaDataLine​(String key)
        Get the VCFHeaderLine whose key equals key. Returns null if no such line exists
        Parameters:
        key -
        Returns:
      • getGenotypeSamples

        public List<String> 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

        public Collection<VCFInfoHeaderLine> getInfoHeaderLines()
        Returns the INFO HeaderLines in their original ordering
      • getInfoHeaderLine

        public VCFInfoHeaderLine getInfoHeaderLine​(String id)
        Parameters:
        id - the header key name
        Returns:
        the meta data line, or null if there is none
      • getFormatHeaderLine

        public VCFFormatHeaderLine getFormatHeaderLine​(String id)
        Parameters:
        id - the header key name
        Returns:
        the meta data line, or null if there is none
      • getFilterHeaderLine

        public VCFFilterHeaderLine getFilterHeaderLine​(String id)
        Parameters:
        id - the header key name
        Returns:
        the meta data line, or null if there is none
      • hasInfoLine

        public boolean hasInfoLine​(String id)
      • hasFormatLine

        public boolean hasFormatLine​(String id)
      • hasFilterLine

        public boolean hasFilterLine​(String id)
      • getOtherHeaderLine

        public VCFHeaderLine getOtherHeaderLine​(String key)
        Parameters:
        key - the header key name
        Returns:
        the meta data line, or null if there is none
      • getOtherHeaderLines

        public Collection<VCFHeaderLine> 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

        public ArrayList<String> 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.