SAMtools

Flexible generic format for storing nucleotide sequence alignment

Introduction

SAM (Sequence Alignment/Map) is a flexible generic format for storing nucleotide sequence alignment. SAM tools provide efficient utilities on manipulating alignments in the SAM format.

Example

Note that SAM does NOT require the loading of a module. Log in to a Spear or HPC node, create a folder, and download the example files into it.

mkdir ~/SAM-test
cd ~/SAM-test
wget https://github.com/samtools/samtools/blob/develop/examples/ex1.fa
wget https://github.com/samtools/samtools/blob/develop/examples/ex1.sam.gz

Some example commands using the above data are shown below.

Index the reference FASTA

samtools faidx ex1.fa

SAM -> BAM

samtools import ex1.fa.fai ex1.sam.gz ex1.bam

Index BAM

samtools index ex1.bam

View Alignment

samtools tview ex1.bam ex1.fa

Pileup and consensus

samtools pileup -cf ex1.fa ex1.bam
samtools pileup -cf ex1.fa -t ex1.fa.fai ex1.sam.gz

For a more detailed example, a primer is available here.