Read alignment and variants · Software
samtools
A command-line toolsuite for reading, writing, sorting, indexing, and viewing SAM, BAM, and CRAM alignment files.
What samtools is
Samtools is a suite of programs designed for interacting with high-throughput sequencing data. It specifically handles sequence alignment files, enabling researchers to read, write, edit, sort, index, view, and summarise data stored in SAM, BAM, and CRAM formats.
Originally released over a decade ago and maintained by contributors including Petr Danecek, James K. Bonfield, Heng Li, and colleagues, the software has evolved into a dedicated tool within a tripartite ecosystem alongside HTSlib and BCFtools. It addresses core data-processing requirements across genomic pipelines, including whole-genome and whole-exome sequencing workflows.
How it works
Samtools operates on high-throughput sequencing alignment formats (SAM, BAM, and CRAM) by relying on HTSlib, a shared C library used for reading and writing high-throughput sequencing data. It provides specialised utilities such as mpileup, format converters, and manipulation utilities to sort alignments, compute summary statistics, and query alignment files.
Key facts
- Version
- 1.20
- Supported formats
- SAM, BAM, CRAM
- Underlying library
- HTSlib
- Primary application
- Read alignment manipulation and summary
What you can use it for
- Alignment format conversion and viewing
- Converting between SAM, BAM, and CRAM alignment representations, as well as viewing and inspecting file contents.
- Sorting and indexing alignments
- Sorting sequencing read alignments and generating coordinate indexes to allow rapid querying and retrieval.
- Generating alignment pileups
- Producing mpileup summaries across aligned sequencing reads to support downstream genomic and variant analyses.
Run it here
samtools is preinstalled on the machine behind every research conversation. Ask the agent in plain language, or give it the exact command — it runs it, reads the output and explains it.
Try asking
“Sort and index my BAM file with samtools and report the mapping statistics.”
Strengths and limits
Good at
- Provides native support for reading, writing, and editing SAM, BAM, and CRAM formats.
- Integrates directly with HTSlib for standard-compliant sequence data processing.
- Offers utility across multiple genomic workflows, including whole-genome and whole-exome sequencing pipelines.
Watch out for
- Focuses strictly on sequence alignment manipulation; variant calling and VCF/BCF handling are delegated to BCFtools.
- Requires HTSlib source or library trees to compile and build from source.
Questions
Can I run samtools online without installing it?
samtools is preinstalled on the machine behind every research conversation. Ask the agent in plain language, or give it the exact command — it runs it, reads the output and explains it.
What licence is samtools under?
samtools is published under its authors' own licence; the project page at https://www.htslib.org/ states it.
What alignment formats does samtools support?
Samtools directly reads, writes, edits, indexes, and views SAM, BAM, and CRAM files.
Does samtools perform variant calling directly?
While samtools provides tools like mpileup for processing alignments, variant calling and VCF/BCF processing tasks are split off into the companion package BCFtools.
What is the relationship between samtools and HTSlib?
Samtools uses HTSlib internally as its C library for reading and writing high-throughput sequencing data.
How to cite it
Petr Danecek, James K Bonfield, Jennifer Liddle, John Marshall, Valeriu Ohan, Martin O Pollard, Andrew Whitwham, Thomas Keane, Shane A McCarthy, Robert M Davies, Heng Li, Twelve years of SAMtools and BCFtools, GigaScience, Volume 10, Issue 2, February 2021, giab008, https://doi.org/10.1093/gigascience/giab008
Written from samtools's own README and project page. Statements citing a figure that does not appear there are removed before publication. Licence and running details come from our registry.