Skip to content

SAMtools

SAMtools implements various utilities for post-processing alignments in the SAM format, such as indexing, variant caller and alignment viewer, and thus provides universal tools for processing read alignments.

SAMtools is available as a module on Apocrita.

Usage

To run the default installed version of SAMtools, simply load the samtools module:

module load samtools

then run one of the SAMtools commands such as:

samtools view -b -S -o genome_reads_aligned.bam genome_reads_aligned.sam

Core Usage

To ensure that SAMtools uses the correct number of cores, the -@ ${NSLOTS} option should be used on commands that support it.

Example job

Serial job

Here is an example job running on 4 cores and 8GB of memory:

#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 4
#$ -l h_rt=1:0:0
#$ -l h_vmem=2G

module load samtools

samtools view -@ ${NSLOTS} -b -S -o genome_reads_aligned.bam \
    genome_reads_aligned.sam

samtools sort -@ ${NSLOTS} genome_reads_aligned.bam \
    > genome_reads_aligned.sorted.bam

samtools index genome_reads_aligned.sorted.bam

samtools mpileup -g -f ref_genome_1K.fna genome_reads_aligned.sorted.bam \
    > genome_variants.bcf

References