Python bindings for bwa, the Burrows-Wheeler Aligner.
Pybwa provides native Python access to bwa's indexing and alignment algorithms, returning
pysam AlignedSegment objects for downstream analysis.
Visit us at Fulcrum Genomics to learn more about how we can power your Bioinformatics with pybwa and beyond.
bwa mem is the recommended algorithm for reads longer than ~70bp (Illumina, etc.).
from pybwa import BwaMem
mem = BwaMem(prefix="/path/to/genome.fasta")
for recs in mem.align(queries=["CTCAAGGTTGTTGCAAGGGGGTCTATGTGAACAAA"]):
for rec in recs:
print(rec)bwa aln is designed for short reads (<100bp, e.g. Illumina).
from pybwa import BwaAln
aln = BwaAln(prefix="/path/to/genome.fasta")
for rec in aln.align(queries=["GATTACA"]):
print(rec)Load a BwaIndex once and pass it to multiple aligners to avoid reloading:
from pybwa import BwaIndex, BwaAln, BwaMem
index = BwaIndex(prefix="/path/to/genome.fasta")
aln = BwaAln(index=index)
mem = BwaMem(index=index)Install with pip install pybwa or conda install -c bioconda pybwa.
Requires Python 3.10+
See the full documentation on pybwa.readthedocs.org.
Visit us at Fulcrum Genomics to learn more about how we can power your Bioinformatics with pybwa and beyond.