SAM

From Genome Analysis Wiki
Revision as of 11:15, 29 July 2010 by Mktrost (talk | contribs)
Jump to: navigation, search

What is SAM

The SAM Format is a text format for storing aligned reads in a series of tab delimited ASCII columns.

Most often it is generated as a human readable projection of its sister BAM format, which can store data in a compact, indexed, binary representation.

The current definition of the format is at [BAM/SAM Specification].


What Information is in SAM & BAM

SAM files and BAM files contain the same information, but in a different format. Refer to the specs to see a format description.

Both SAM & BAM files contain a header section and an alignment section. The header section may contain information about the entire file and additional information for alignments. The alignments then associate themselves with specific header information.

What Information Does SAM/BAM Have for an Alignment

Each Alignment has:

  • query name, QNAME (SAM)/read_name (BAM). It is used to group/identify alignments that are together, like paired alignments or a read that appears in multiple alignments.
  • FLAG

Not all alignments contain The rest of the alignment fields may be set to default values if the information is unknown.

  • reference sequence name, RNAME, often contains the Chromosome name.
  • leftmost position of where this alignment maps to the reference, POS. For SAM, the reference starts at 1, so this value is 1-based, while for BAM the reference starts at 0,so this value is 0-based. Beware to always use the correct base when referencing positions.
  • mapping quality, MAPQ, which contains the "phred-scaled posterior probability that the mapping position" is wrong. (from SAM-1.pdf)
  • CIGAR
  • the reference sequence name of the next alignment in this group, MRNM or RNEXT. In paired alignments, it is the mate's reference sequence name. (A group is alignments with the same query name.)
  • leftmost position of where the next alignment in this group maps to the reference, MPOS or PNEXT. For SAM, the reference starts at 1, so this value is 1-based, while for BAM the reference starts at 0,so this value is 0-based. Beware to always use the correct base when referencing positions.
  • length of this group from the leftmost position to the rightmost position, ISIZE or TLEN
  • the sequence for this alignment, SEQ
  • the quality for this alignment, QUAL
  • Additional optional information is also contained within the alignment, TAGS. A bunch of different information can be stored here and they appear as key/value pairs. See the spec for a detailed list of commonly used tags and what they mean.

What is a CIGAR?

You may have heard the term CIGAR, but wondered what it means. Hopefully this section will help clarify it.

Example SAM