Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for bwa aln -N #37

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pybwa/libbwaaln.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cdef extern from "bwtaln.h":
int BWA_MODE_GAPE
int BWA_MODE_COMPREAD
int BWA_MODE_LOGGAP
int BWA_MODE_NONSTOP

int __cigar_op(uint16_t __cigar)
int __cigar_len(uint16_t __cigar)
Expand Down
2 changes: 2 additions & 0 deletions pybwa/libbwaaln.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class BwaAlnOptions:
stop_at_max_best_hits: int | None = None,
max_hits: int | None = 3,
log_scaled_gap_penalty: bool | None = None,
find_all_hits: bool | None = None,
threads: int | None = None,
) -> None: ...
max_mismatches: int # -n <int>
Expand All @@ -38,6 +39,7 @@ class BwaAlnOptions:
stop_at_max_best_hits: int # -R <int>
max_hits: int # bwa samse -n <int>
log_scaled_gap_penalty: bool = True # -L
find_all_hits: bool = False # -N
with_md: bool = True # bwa samse -d
threads: int # -t <int>

Expand Down
21 changes: 18 additions & 3 deletions pybwa/libbwaaln.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ cdef class BwaAlnOptions:
gap_extension_penalty (int | None): :code:`-E <int>`
stop_at_max_best_hits (int | None): :code:`-R <int>`
max_hits (int | None): :code:`bwa samse -n <int>`
log_scaled_gap_penalty (in | None): :code:`-L`
log_scaled_gap_penalty (bool | None): :code:`-L`
find_all_hits (bool | None): :code:`-N`
with_md (bool): output the MD to each alignment in the XA tag, otherwise use :code:`"."`
threads (int): the number of threads to use
"""
Expand All @@ -56,6 +57,7 @@ cdef class BwaAlnOptions:
stop_at_max_best_hits: int | None = None,
max_hits: int | None = 3,
log_scaled_gap_penalty: bool | None = None,
find_all_hits: bool | None = None,
with_md: bool | None = False,
threads: int | None = None
):
Expand Down Expand Up @@ -83,6 +85,8 @@ cdef class BwaAlnOptions:
self.max_hits = max_hits
if log_scaled_gap_penalty is not None:
self.log_scaled_gap_penalty = 1 if log_scaled_gap_penalty else 0
if find_all_hits is not None:
self.find_all_hits = find_all_hits
if with_md is not None:
self.with_md = with_md
if threads is not None:
Expand Down Expand Up @@ -186,14 +190,25 @@ cdef class BwaAlnOptions:

property log_scaled_gap_penalty:
""":code:`bwa aln -L`"""
def __get__(self) -> int:
def __get__(self) -> bool:
return self._delegate.mode & BWA_MODE_LOGGAP > 0
def __set__(self, value: int):
def __set__(self, value: bool):
if value:
self._delegate.mode |= BWA_MODE_LOGGAP
else:
self._delegate.mode &= ~BWA_MODE_LOGGAP

property find_all_hits:
""":code:`bwa aln -N`"""
def __get__(self) -> bool:
return self._delegate.mode & BWA_MODE_NONSTOP > 0
def __set__(self, value: bool):
if value:
self._delegate.mode |= BWA_MODE_NONSTOP
self.stop_at_max_best_hits = 0x7fffffff
else:
self._delegate.mode &= ~BWA_MODE_NONSTOP

property with_md:
""":code:`bwa samse -d

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybwa"
version = "1.2.0"
version = "1.3.0"
description = "Python bindings for BWA"
authors = ["Nils Homer"]
license = "MIT"
Expand Down
Loading