Class SAMFileHeader

All Implemented Interfaces:
HtsHeader, Serializable

public class SAMFileHeader extends AbstractSAMHeaderRecord implements HtsHeader
Header information from a SAM or BAM file.
See Also:
  • Field Details

  • Constructor Details

    • SAMFileHeader

      public SAMFileHeader()
    • SAMFileHeader

      public SAMFileHeader(SAMSequenceDictionary dict)
      Constructor that initializes the sequence dictionary with the provided one.
  • Method Details

    • getVersion

      public String getVersion()
    • getCreator

      public String getCreator()
    • getSequenceDictionary

      public SAMSequenceDictionary getSequenceDictionary()
    • getReadGroups

      public List<SAMReadGroupRecord> getReadGroups()
    • getSequence

      public SAMSequenceRecord getSequence(String name)
      Look up sequence record by name.
      Returns:
      sequence record if it's found by name, or null if sequence dictionary is empty or if the sequence is not found in the dictionary.
    • getReadGroup

      public SAMReadGroupRecord getReadGroup(String name)
      Look up read group record by name.
    • setSequenceDictionary

      public void setSequenceDictionary(SAMSequenceDictionary sequenceDictionary)
      Replace entire sequence dictionary. The given sequence dictionary is stored, not copied.
    • addSequence

      public void addSequence(SAMSequenceRecord sequenceRecord)
    • getSequence

      public SAMSequenceRecord getSequence(int sequenceIndex)
      Look up a sequence record by index. First sequence in the header is the 0th.
      Returns:
      The corresponding sequence record, or null if the index is out of range.
    • getSequenceIndex

      public int getSequenceIndex(String sequenceName)
      Returns:
      Sequence index for the given sequence name, or -1 if the name is not found.
    • setReadGroups

      public void setReadGroups(List<SAMReadGroupRecord> readGroups)
      Replace entire list of read groups. The given list is stored, not copied.
    • addReadGroup

      public void addReadGroup(SAMReadGroupRecord readGroup)
    • getProgramRecords

      public List<SAMProgramRecord> getProgramRecords()
    • addProgramRecord

      public void addProgramRecord(SAMProgramRecord programRecord)
    • getProgramRecord

      public SAMProgramRecord getProgramRecord(String pgId)
    • setProgramRecords

      public void setProgramRecords(List<SAMProgramRecord> programRecords)
      Replace entire list of program records
      Parameters:
      programRecords - This list is used directly, not copied.
    • createProgramRecord

      public SAMProgramRecord createProgramRecord()
      Returns:
      a new SAMProgramRecord with an ID guaranteed to not exist in this SAMFileHeader
    • getSortOrder

      public SAMFileHeader.SortOrder getSortOrder()
    • setSortOrder

      public void setSortOrder(SAMFileHeader.SortOrder so)
    • getGroupOrder

      public SAMFileHeader.GroupOrder getGroupOrder()
    • setGroupOrder

      public void setGroupOrder(SAMFileHeader.GroupOrder go)
    • setAttribute

      @Deprecated public void setAttribute(String key, Object value)
      Deprecated.
      Set the given value for the attribute named 'key'. Replaces an existing value, if any. If value is null, the attribute is removed. Otherwise, the value will be converted to a String with toString.
      Overrides:
      setAttribute in class AbstractSAMHeaderRecord
      Parameters:
      key - attribute name
      value - attribute value
    • setAttribute

      public void setAttribute(String key, String value)
      Set the given value for the attribute named 'key'. Replaces an existing value, if any. If value is null, the attribute is removed.
      Overrides:
      setAttribute in class AbstractSAMHeaderRecord
      Parameters:
      key - attribute name
      value - attribute value
    • getTextHeader

      @Deprecated public String getTextHeader()
      Deprecated.
      since May 1st 2019 - text version of header is no longer stored.
    • setTextHeader

      @Deprecated public void setTextHeader(String textHeader)
      Deprecated.
      since May 1st 2019 - text version of header is no longer stored.
    • getComments

      public List<String> getComments()
    • addComment

      public void addComment(String comment)
    • setComments

      public void setComments(Collection<String> comments)
      Replace existing comments with the contents of the given collection.
    • getValidationErrors

      public List<SAMValidationError> getValidationErrors()
    • addValidationError

      public void addValidationError(SAMValidationError error)
    • setValidationErrors

      public void setValidationErrors(Collection<SAMValidationError> errors)
      Replace list of validation errors with the elements of the given list.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public final SAMFileHeader clone()
      Overrides:
      clone in class Object
    • getSAMString

      public String getSAMString()
      Description copied from class: AbstractSAMHeaderRecord
      Returns the record in the SAM line-based text format. Fields are separated by '\t' characters. The String is NOT terminated by '\n'.
      Specified by:
      getSAMString in class AbstractSAMHeaderRecord