Also known as SAM, Sequence Alignment Map (SAM)
file format
Sequence Alignment/Map Format Specification The SAM/BAM Format Specification Working Group 12 Aug 2025 The master version of this document can be found at This printing is version b5341fb from that repository, last modified on the date shown above. 1 The SAM Format Specification SAM stands for Sequence Alignment/Map format. It is a TAB-delimited text format consisting of a header section, which is optional, and an alignment section. If present, the header must be prior to the alignments. Header lines start with ‘@’, while alignment lines do not. Each alignment line has 11 mandatory fields for essential alignment information such as mapping position, and variable number of optional fields for flexible or aligner specific information. This specification is for version 1.6 of the SAM and BAM formats. Each SAM and BAM file may optionally specify the version being used via the @HD VN tag. For full version history see Appendix B. SAM file contents are 7-bit US-ASCII, except for certain field values as individually specified which may contain other Unicode characters encoded in UTF-8. Alternatively and equivalently, SAM files are encoded in UTF-8 but non-ASCII characters are permitted only within certain field values as explicitly specified in the descriptions of those fields. 1 Where it makes a difference, SAM file contents should be read and written using the POSIX / C locale. For example, floating-point values in SAM always use ‘.’ for the decimal-point character. The regular expressions in this specification are written using the POSIX / IEEE Std 1003.1 extended syntax. 1.1 An example Suppose we have the following alignment with bases in lowercase clipped from the alignment. Read r001/1 and r001/2 constitute a read pair; r003 is a chimeric read; r004 represents a split alignment. Coor 12345678901234 5678901234567890123456789012345 ref AGCATGTTAGATAA GATAGCTGTGCTAGTAGGCAGTCAGCGCCAT +r001/1 TTAGATAAAGGATA CTG +r002 aaaAGATAA GGATA +r003 gcctaAGCTAA +r004 ATAGCT..............TCAGC -r003 ttagctTAGGC -r001/2 CAGCGGCAT 1 Hence in particular SAM files must not begin with a byte order mark (BOM) and lines of text are delimited by ASCII line terminator characters only. In addition to the local platform’s text file line termination conventions, implementations may wish to support lf and cr lf for interoperability with other platforms. 1 Phred scale Given a probability 0 < p≤ 1, the phred scale of p equals −10 log 10 p, rounded to the closest integer. 1.2.1 Character set restrictions Reference sequence names, CIGAR strings, and several other field types are used as values or parts of values of other fields in SAM and related formats such as VCF. To ensure that these other fields’ representations are unambiguous, these field types disallow particular delimiter characters. Query or read names may contain any printable ASCII characters in the range [!-~] apart from ‘@’, so that SAM alignment lines can be easily distinguished from header lines. (They are also limited in length.) Reference sequence names may contain any printable ASCII characters in the range [!-~] apart from backslashes, commas, quotation marks, and brackets—i.e., apart from ‘ , "‘’ () [] {} <>’—and may not start with ‘ ’ or ‘=’. 4 Thus they match the following regular expression: [0-9A-Za-z! $%&+./:;?@^ ~-][0-9A-Za-z! $%& +./:;=?@^ ~-] For clarity, elsewhere in this specification we write this set of allowed characters as a character class [:rname:] and extend the POSIX regular expression notation to use ∧ = to indicate the omission of ‘ ’ and ‘=’ from the character class. Thus this regular expression can be written more clearly as [:rname: ∧ =][:rname:] . 1.3 The header section Each header line begins with the character ‘@’ followed by one of the two-letter header record type codes defined in this section. In the header, each line is TAB-delimited and, apart from @CO lines, each data field follows a format ‘TAG:VALUE’ where TAG is a two-character string
Excerpt from a page describing this subject · 40,000 chars · not written by Vinony
via Wikidata · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).