
pysam
Pythonic access to SAM/BAM/CRAM/VCF via HTSlib
pysam gives you programmatic, high-performance access to sequencing data formats from Python, wrapping the same HTSlib used by SAMtools and BCFtools.
Example
1import pysam2with pysam.AlignmentFile("sorted.bam", "rb") as bam:3 for read in bam.fetch("chr1", 0, 100000):4 if not read.is_unmapped:5 print(read.query_name, read.reference_start)
Related tools

Open source

Open source

Open source