SAM (file format)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
SAM file format
Developed by
Type of formatBioinformatics
Extended fromTab-separated values
Websitesamtools.github.io/hts-specs/

Sequence Alignment Map (SAM) is a text-based format for storing biological sequences aligned to a reference sequence developed by Heng Li and Bob Handsaker et al.[1] It is widely used for storing data, such as nucleotide sequences, generated by next generation sequencing technologies. The format supports short and long reads (up to 128Mbp) produced by different sequencing platforms and is used to hold mapped data within the Genome Analysis Toolkit (GATK) and across the Broad Institute, the Wellcome Sanger Institute, and throughout the 1000 Genomes Project. Sequence Alignment/Map (SAM) format for alignment of nucleotide sequences (e.g. sequencing reads) to (a) reference sequence(s). May contain base-call and alignment qualities and other data.[2][3]

Format[edit]

The SAM format consists of a header and an alignment section.[1] The binary equivalent of a SAM file is a Binary Alignment Map (BAM) file, which stores the same data in a compressed binary representation.[3] SAM files can be analysed and edited with the software SAMtools.[1] The header section must be prior to the alignment section if it is present. Headings begin with the '@' symbol, which distinguishes them from the alignment section. Alignment sections have 11 mandatory fields, as well as a variable number of optional fields.[1]

Col Field Type Brief Description
1 QNAME String Query template NAME
2 FLAG Int bitwise FLAG
3 RNAME String References sequence NAME
4 POS Int 1- based leftmost mapping POSition
5 MAPQ Int MAPping Quality
6 CIGAR String CIGAR String
7 RNEXT String Ref. name of the mate/next read
8 PNEXT Int Position of the mate/next read
9 TLEN Int observed Template LENgth
10 SEQ String segment SEQuence
11 QUAL String ASCII of Phred-scaled base QUALity+33

Description[edit]

From the specification:[3]

  1. QNAME: Query template NAME. Reads/segments having identical QNAME are regarded to come from the same template. A QNAME ‘*’ indicates the information is unavailable. In a SAM file, a read may occupy multiple alignment lines, when its alignment is chimeric or when multiple mappings are given.
  2. FLAG: Combination of bitwise FLAGs
  3. RNAME: Reference sequence NAME of the alignment. If @SQ header lines are present, RNAME (if not ‘*’) must be present in one of the SQ-SN tag. An unmapped segment without coordinate has a ‘*’ at this field. However, an unmapped segment may also have an ordinary coordinate such that it can be placed at a desired position after sorting. If RNAME is ‘*’, no assumptions can be made about POS and CIGAR.
  4. POS: 1-based leftmost mapping POSition of the first matching base. The first base in a reference sequence has coordinate 1. POS is set as 0 for an unmapped read without coordinate. If POS is 0, no assumptions can be made about RNAME and CIGAR.
  5. MAPQ: MAPping Quality. It equals −10 log10 Pr{mapping position is wrong}, rounded to the nearest integer. A value 255 indicates that the mapping quality is not available.
  6. CIGAR: Concise Idiosyncratic Gapped Alignment Report (CIGAR) string.
  7. RNEXT: Reference sequence name of the primary alignment of the NEXT read in the template. For the last read, the next read is the first read in the template. If @SQ header lines are present, RNEXT (if not ‘*’ or ‘=’) must be present in one of the SQ-SN tag. This field is set as ‘*’ when the information is unavailable, and set as ‘=’ if RNEXT is identical RNAME. If not ‘=’ and the next read in the template has one primary mapping (see also bit 0x100 in FLAG), this field is identical to RNAME at the primary line of the next read. If RNEXT is ‘*’, no assumptions can be made on PNEXT and bit 0x20.
  8. PNEXT: Position of the primary alignment of the NEXT read in the template. Set as 0 when the information is unavailable. This field equals POS at the primary line of the next read. If PNEXT is 0, no assumptions can be made on RNEXT and bit 0x20.
  9. TLEN: signed observed Template LENgth. If all segments are mapped to the same reference, the unsigned observed template length equals the number of bases from the leftmost mapped base to the rightmost mapped base. The leftmost segment has a plus sign and the rightmost has a minus sign. The sign of segments in the middle is undefined. It is set as 0 for single-segment template or when the information is unavailable.
  10. SEQ: segment SEQuence. This field can be a ‘*’ when the sequence is not stored. If not a ‘*’, the length of the sequence must equal the sum of lengths of M/I/S/=/X operations in CIGAR. An ‘=’ denotes the base is identical to the reference base. No assumptions can be made on the letter cases.
  11. QUAL: ASCII of base QUALity plus 33 (same as the quality string in the Sanger FASTQ format). A base quality is the phred-scaled base error probability which equals −10 log10 Pr{base is wrong}. This field can be a ‘*’ when quality is not stored. If not a ‘*’, SEQ must not be a ‘*’ and the length of the quality string ought to equal the length of SEQ.


Optional fields[edit]

From the specification:[3]

The type may be one of A (character), B (general array), f (real number), H (hexadecimal array), i (integer), or Z (string).

Tag Type Description
AM i The smallest template-independent mapping quality in the template
AS i Alignment score generated by aligner
BC Z Barcode sequence identifying the sample
BQ Z Offset to base alignment quality (BAQ)
BZ Z Phred quality of the unique molecular barcode bases in the OX tag
CB Z Cell identifier
CC Z Reference name of the next hit
CG B,I BAM only: CIGAR in BAM's binary encoding if (and only if) it consists of >65535 operators
CM i Edit distance between the color sequence and the color reference (see also NM)
CO Z Free-text comments
CP i Leftmost coordinate of the next hit
CQ Z Color read base qualities
CR Z Cellular barcode sequence bases (uncorrected)
CS Z Color read sequence
CT Z Complete read annotation tag, used for consensus annotation dummy features
CY Z Phred quality of the cellular barcode sequence in the CR tag
E2 Z The 2nd most likely base calls
FI i The index of segment in the template
FS Z Segment suffix
FZ B,S Flow signal intensities
GC ? Reserved for backwards compatibility reasons
GQ ? Reserved for backwards compatibility reasons
GS ? Reserved for backwards compatibility reasons
H0 i Number of perfect hits
H1 i Number of 1-difference hits (see also NM)
H2 i Number of 2-difference hits
HI i Query hit index
IH i Query hit total count
LB Z Library
MC Z CIGAR string for mate/next segment
MD Z String for mismatching positions
MF ? Reserved for backwards compatibility reasons
MI Z Molecular identifier; a string that uniquely identifies the molecule from which the record was derived
MQ i Mapping quality of the mate/next segment
NH i Number of reported alignments that contain the query in the current record
NM i Edit distance to the reference
OA Z Original alignment
OC Z Original CIGAR (deprecated; use OA instead)
OP i Original mapping position (deprecated; use OA instead)
OQ Z Original base quality
OX Z Original unique molecular barcode bases
PG Z Program
PQ i Phred likelihood of the template
PT Z Read annotations for parts of the padded read sequence
PU Z Platform unit
Q2 Z Phred quality of the mate/next segment sequence in the R2 tag
QT Z Phred quality of the sample barcode sequence in the BC tag
QX Z Quality score of the unique molecular identifier in the RX tag
R2 Z Sequence of the mate/next segment in the template
RG Z Read group
RT ? Reserved for backwards compatibility reasons
RX Z Sequence bases of the (possibly corrected) unique molecular identifier
S2 ? Reserved for backwards compatibility reasons
SA Z Other canonical alignments in a chimeric alignment
SM i Template-independent mapping quality
SQ ? Reserved for backwards compatibility reasons
TC i The number of segments in the template
U2 Z Phred probability of the 2nd call being wrong conditional on the best being wrong
UQ i Phred likelihood of the segment, conditional on the mapping being correct
X? ? Reserved for end users
Y? ? Reserved for end users
Z? ? Reserved for end users

See also[edit]

  • The FASTA format, used to represent genome sequences.
  • The FASTQ format, used to represent DNA sequencer reads along with quality scores.
  • The GVF format (Genome Variation Format), an extension based on the GFF3 format.

References[edit]

  1. ^ a b c d e Li, H.; Handsaker, B.; Wysoker, A.; Fennell, T.; Ruan, J.; Homer, N.; Marth, G.; Abecasis, G.; Durbin, R. (2009). "The Sequence Alignment/Map format and SAMtools" (PDF). Bioinformatics. 25 (16): 2078–2079. doi:10.1093/bioinformatics/btp352. ISSN 1367-4803. PMC 2723002. PMID 19505943.
  2. ^ "EDAM bioinformatics operations, data types, formats, identifiers and topics - SAM - Classes | NCBO BioPortal". purl.bioontology.org. Retrieved 2017-01-31.
  3. ^ a b c d "SAM/BAM Format Specification" (PDF). samtools.github.io.