Skip to content

Samtools

Flexible generic format for storing nucleotide sequence alignments


Samtools requires an environment module

In order to use Samtools, you must first load the appropriate environment module:

module load gnu

SAM (Sequence Alignment/Map) provides efficient utilities on manipulating alignments in the SAM format.

Using Samtools on RCC Resources#

Connect to the HPC and run the following commands to create a folder and download the SAM example files into it:

1
2
3
4
5
$ module load gnu
$ 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