Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.
/ bwapy Public archive
forked from nanoporetech/bwapy

Python bindings to bwa mem

License

Notifications You must be signed in to change notification settings

readcoor/bwapy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bwapy

Build Status

Python bindings to bwa mem aligner; sufficient to load and index and perform alignments of sequences to the index to obtain basic statistics.

These python bindings are licensed under Mozilla Public License 2.0, bwa is licenced under GNU General Public License v3.0.

Documentation can be found at https://nanoporetech.github.io/bwapy/.

Installation

The git source repository contains bwa as a submodule. The repository should therefore be cloned using the recursive option.

The package setup.py script requires libbwa.a to have been built in the submodule directory before running. This can be performed via the libbwa.a target, which first makes some amendments to the bwa/Makefile. To build and install the package one should therefore run:

git clone --recursive https://github.com/nanoporetech/bwapy.git
cd bwapy
make bwa/libbwa.a 
python setup.py install

Performing Alignments

The BwaAligner class provides a pythonic interface to bwa mem aligner. It takes as input a bwa index fileset on construction and can then be used to find alignments of sequences given as strings:

from bwapy import BwaAligner
index = 'path/to/index' # the path given to bwa index
seq = 'ACGATCGCGATCGA'

aligner = BwaAligner(index)
alignments = aligner.align_seq(seq)
print('Found {} alignments.'.format(len(alignments))
for aln in alignments:
    print('  ', aln)

The alignments are returned as a named tuple, e.g.:

Alignment(rname='yeast', orient='+', pos=0, mapq=60, cigar='915M3D29M3D27M3D13M', NM=12)

Alignment parameters can be given as they are on the bwa mem command line:

from bwapy import BwaAligner
index = 'path/to/index'
options = '-x ont2d -A 1 -B 0'
aligner = BwaAligner(index, options=options)

Some options which do not make sense when aligning single sequences, have been disabled (notably options related to paired-end reads).

About

Python bindings to bwa mem

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 56.6%
  • C 37.5%
  • Makefile 5.9%