Skip to content

Welcome to our weekly research support coffee hour on Zoom! Click here for more information.

SAMtools

SAMtools provides tools for using and manipulating SAM, BAM and CRAM formatted alignments. You can use SAMtools for example for format conversion, sorting, indexing and viewing alignments, and for basic variant-related processing.

License

Free to use and open source under the MIT/Expat License.

Available

  • Roihu-CPU: 1.21, 1.24, via the bio-apps module.

Usage

SAMtools is part of the bio-apps collection on Roihu. Load the bio-apps module tree and then the SAMtools module:

module load bio-apps/v202603
module load samtools/1.24

Check the available versions with:

module spider samtools

After loading, you can run SAMtools:

samtools --version

Heavier SAMtools jobs should be run as batch jobs. Below is an example batch script that converts a SAM file to BAM, then sorts and indexes it:

#!/bin/bash
#SBATCH --job-name=samtools
#SBATCH --output=output_%j.txt
#SBATCH --error=errors_%j.txt
#SBATCH --account=<project>
#SBATCH --partition=small
#SBATCH --time=04:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=4000M

module load bio-apps/v202603
module load samtools/1.24

# Convert SAM to BAM
samtools view -bS aln.sam > aln.bam

# Sort the BAM file
samtools sort aln.bam -o aln-sorted.bam

# Index the sorted BAM file
samtools index aln-sorted.bam

Replace <project> with your CSC project (for example project_2001234). Submit the job with:

sbatch batch_job_file.sh

See creating a batch job script for Roihu for more information about running batch jobs.

Support

CSC Service Desk

More information

Do you find this page useful?
Thank you for your feedback!
Thank you! Your feedback is appreciated.

Please let us know how we could improve this page by contacting us or by creating an issue in GitHub. You can also edit this page yourself and contribute your improvements by creating a pull request.