pysam-developers/pysam logo

pysam-developers/pysam

Free

Pysam is a Python module for reading and manipulating SAM/BAM/VCF/BCF files. It's a lightweight wrapper of the htslib C-API, the same one that powers samtools, bcftools, and tabix.

FreeFree tier
Type
Open Source

About pysam-developers/pysam

Pysam is a Python package for reading, manipulating, and writing genomics data in SAM/BAM/CRAM and VCF/BCF formats. It is a lightweight wrapper of the HTSlib C-API, the same library that powers samtools, bcftools, and tabix. Designed for next-generation sequencing data, pysam enables efficient handling of large alignment files and variant calls. Installation is recommended via the bioconda channel for automatic dependency resolution, but it is also available on PyPI. The package is open source under the MIT license and includes a tabix interface for indexed file access. Documentation and community support are available via ReadTheDocs and the pysam user group.

Key Features

Read, manipulate, and write SAM/BAM/CRAM and VCF/BCF files
Lightweight Python wrapper of the HTSlib C-API
Includes an interface for tabix (indexed file access)
Installation via conda (bioconda) or pip
Open source under MIT license
Well-documented with ReadTheDocs and community support

Pros & Cons

Pros
  • Leverages the robust, widely-used HTSlib C-API (also used by samtools, bcftools)
  • Supports multiple genomic file formats (SAM, BAM, CRAM, VCF, BCF)
  • Easy installation via bioconda (resolves non-Python dependencies)
  • Comprehensive documentation and active user group
  • Free and open source with a permissive MIT license
Cons
  • Python-only; not available for other programming languages
  • Requires understanding of genomic data formats (SAM/BAM/VCF)
  • Compilation from source can be complex without conda

Best For

Processing next-generation sequencing alignment dataVariant calling and VCF/BCF file manipulationMerging, sorting, and querying BAM filesIntegrating genomic file operations into Python-based bioinformatics pipelinesIndexed access to genomic intervals with tabix

FAQ

What file formats does pysam support?
Pysam supports SAM, BAM, CRAM, VCF, and BCF file formats for reading and writing.
How do I install pysam?
The recommended method is via conda using the bioconda channel: conda install pysam. It is also available via pip: pip install pysam.
Is pysam free to use?
Yes, pysam is open source and distributed under the MIT license, allowing free use, modification, and distribution.
Does pysam work with tabix?
Yes, pysam includes an interface for tabix, enabling indexed access to genomic intervals.