Package htsjdk.samtools
Class SAMFileHeader
- java.lang.Object
-
- htsjdk.samtools.AbstractSAMHeaderRecord
-
- htsjdk.samtools.SAMFileHeader
-
- All Implemented Interfaces:
Serializable
public class SAMFileHeader extends AbstractSAMHeaderRecord
Header information from a SAM or BAM file.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SAMFileHeader.GroupOrder
static class
SAMFileHeader.PgIdGenerator
Little class to generate program group IDsstatic class
SAMFileHeader.SortOrder
Ways in which a SAM or BAM may be sorted.
-
Field Summary
Fields Modifier and Type Field Description static Set<String>
ACCEPTABLE_VERSIONS
static String
CURRENT_VERSION
static String
GROUP_ORDER_TAG
static String
SORT_ORDER_TAG
static Set<String>
STANDARD_TAGS
These tags are of known type, so don't need a type field in the text representation.static String
VERSION_TAG
-
Fields inherited from class htsjdk.samtools.AbstractSAMHeaderRecord
serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description SAMFileHeader()
SAMFileHeader(SAMSequenceDictionary dict)
Constructor that initializes the sequence dictionary with the provided one.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addComment(String comment)
void
addProgramRecord(SAMProgramRecord programRecord)
void
addReadGroup(SAMReadGroupRecord readGroup)
void
addSequence(SAMSequenceRecord sequenceRecord)
void
addValidationError(SAMValidationError error)
SAMFileHeader
clone()
SAMProgramRecord
createProgramRecord()
boolean
equals(Object o)
List<String>
getComments()
String
getCreator()
SAMFileHeader.GroupOrder
getGroupOrder()
SAMProgramRecord
getProgramRecord(String pgId)
List<SAMProgramRecord>
getProgramRecords()
SAMReadGroupRecord
getReadGroup(String name)
Look up read group record by name.List<SAMReadGroupRecord>
getReadGroups()
String
getSAMString()
Returns the record in the SAM line-based text format.SAMSequenceRecord
getSequence(int sequenceIndex)
Look up a sequence record by index.SAMSequenceRecord
getSequence(String name)
Look up sequence record by name.SAMSequenceDictionary
getSequenceDictionary()
int
getSequenceIndex(String sequenceName)
SAMFileHeader.SortOrder
getSortOrder()
String
getTextHeader()
Deprecated.since May 1st 2019 - text version of header is no longer stored.List<SAMValidationError>
getValidationErrors()
String
getVersion()
int
hashCode()
void
setAttribute(String key, Object value)
Deprecated.Useinstead
void
setAttribute(String key, String value)
Set the given value for the attribute named 'key'.void
setComments(Collection<String> comments)
Replace existing comments with the contents of the given collection.void
setGroupOrder(SAMFileHeader.GroupOrder go)
void
setProgramRecords(List<SAMProgramRecord> programRecords)
Replace entire list of program recordsvoid
setReadGroups(List<SAMReadGroupRecord> readGroups)
Replace entire list of read groups.void
setSequenceDictionary(SAMSequenceDictionary sequenceDictionary)
Replace entire sequence dictionary.void
setSortOrder(SAMFileHeader.SortOrder so)
void
setTextHeader(String textHeader)
Deprecated.since May 1st 2019 - text version of header is no longer stored.void
setValidationErrors(Collection<SAMValidationError> errors)
Replace list of validation errors with the elements of the given list.-
Methods inherited from class htsjdk.samtools.AbstractSAMHeaderRecord
attributesEqual, attributesHashCode, getAttribute, getAttributes, getId, setAttribute, toString
-
-
-
-
Field Detail
-
VERSION_TAG
public static final String VERSION_TAG
- See Also:
- Constant Field Values
-
SORT_ORDER_TAG
public static final String SORT_ORDER_TAG
- See Also:
- Constant Field Values
-
GROUP_ORDER_TAG
public static final String GROUP_ORDER_TAG
- See Also:
- Constant Field Values
-
CURRENT_VERSION
public static final String CURRENT_VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SAMFileHeader
public SAMFileHeader()
-
SAMFileHeader
public SAMFileHeader(SAMSequenceDictionary dict)
Constructor that initializes the sequence dictionary with the provided one.
-
-
Method Detail
-
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.Useinstead
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 classAbstractSAMHeaderRecord
- Parameters:
key
- attribute namevalue
- 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 classAbstractSAMHeaderRecord
- Parameters:
key
- attribute namevalue
- 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.
-
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.
-
clone
public final SAMFileHeader clone()
-
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 classAbstractSAMHeaderRecord
-
-