pysam: htslib interface for python

Author:

Andreas Heger, John Marshall, Kevin Jacobs, and contributors

Date:

Nov 25, 2025

Version:

0.23.3

Pysam is a python module for reading, manipulating and writinggenomic data sets.

Pysam is a wrapper of thehtslib C-API and provides facilities toread and write SAM/BAM/VCF/BCF/BED/GFF/GTF/FASTA/FASTQ files as wellas access to the command line functionality of thesamtools andbcftools packages. The module supports compression and random accessthrough indexing.

This module provides a low-level wrapper around thehtslib C-API asusing cython and a high-level, pythonic API for convenient access tothe data within genomic file formats.

The current version wrapshtslib-1.22.1,samtools-1.22.1, andbcftools-1.22.

To install the latest release, type:

pipinstallpysam

See theInstallation notes for details.

This module is unrelated toNREL-PySAM, which wraps the National RenewableEnergy Laboratory’s System Advisor Model.

Contents

Indices and tables

Contents:

References

[Li.2009]

The Sequence Alignment/Map format and SAMtools.Li H, Handsaker B, Wysoker A, Fennell T, Ruan J, Homer N, Marth G, Abecasis G, Durbin R; 1000 Genome Project Data Processing Subgroup.Bioinformatics. 2009 Aug 15;25(16):2078-9.Epub 2009 Jun 8btp352.PMID:19505943.

[Bonfield.2021]

HTSlib: C library for reading/writing high-throughput sequencing data.Bonfield JK, Marshall J, Danecek P, Li H, Ohan V, Whitwham A, Keane T, Davies RM.GigaScience (2021) 10(2)giab007.PMID:33594436.

[Danecek.2021]

Twelve years of SAMtools and BCFtools.Danecek P, Bonfield JK, Liddle J, Marshall J, Ohan V, Pollard MO, Whitwham A, Keane T, McCarthy SA, Davies RM, Li H.GigaScience (2021) 10(2)giab008.PMID:33590861.

See also

Information about htslib

http://www.htslib.org

The samtools homepage

http://samtools.sourceforge.net

The cython C-extensions for python

https://cython.org/

The python language

https://www.python.org