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.

Installation

Conda

conda install -c bioconda samtools

Manual

For the manual installation, you can find the instructions here.

Usage

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

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

Reference

  • Hania Kranas