Skip to content

Commit

Permalink
refactoring bwa options
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Dec 19, 2024
1 parent 0fc456f commit 541a9fd
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 72 deletions.
3 changes: 1 addition & 2 deletions bwapy/libbwaaln.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ cdef class BwaAlnOptions:

def __init__(self):
self._max_hits = 3
self._cinit()

cdef _cinit(self):
def __cinit__(self):
self._delegate = gap_init_opt()

def __dealloc__(self):
Expand Down
4 changes: 2 additions & 2 deletions bwapy/libbwaindex.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cdef class BwaIndex:
"""Contains the index and nucleotide sequence for Bwa"""
cdef bwaidx_t *_delegate
cdef public object header
cdef _cinit(self, prefix, mode)
cdef bwt_t *bwt(self)
cdef bntseq_t *bns(self)
cdef uint8_t *pac(self)
cdef uint8_t *pac(self)
cdef _load_index(self, prefix, mode)
7 changes: 3 additions & 4 deletions bwapy/libbwaindex.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ cdef class BwaIndex:
random base)
"""
cdef int mode

mode = 0
if bwt:
mode |= BWA_IDX_BWT
if bns:
mode |= BWA_IDX_BNS
if pac:
mode |= BWA_IDX_PAC
self._cinit(f"{prefix}", mode)

cdef _cinit(self, prefix, mode):
cdef char *local_prefix
self._load_index(f"{prefix}", mode)

cdef _load_index(self, prefix, mode):
prefix = bwa_idx_infer_prefix(force_bytes(prefix))
if not prefix:
# FIXME: better error message
Expand Down
8 changes: 5 additions & 3 deletions bwapy/libbwamem.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import enum
from pathlib import Path
from typing import List
from typing import Self

from pysam import AlignedSegment
from pysam import FastxRecord
Expand All @@ -18,9 +17,8 @@ class BwaMemMode(enum.Enum):
INTRACTG = enum.auto()

class BwaMemOptions:
_ignore_alt: bool
def __init__(self, finalize: bool = False) -> None: ...
def finalize(self) -> Self: ...
_ignore_alt: bool
min_seed_len: int
mode: BwaMemMode
band_width: int
Expand Down Expand Up @@ -52,6 +50,10 @@ class BwaMemOptions:
gap_extension_penalty: int | tuple[int, int]
clipping_penalty: int | tuple[int, int]

class BwaMemOptionsBuilder(BwaMemOptions):
def __init__(self, options: BwaMemOptions | None = None) -> None: ...
def build(self) -> BwaMemOptions: ...

class BwaMem:
_index: BwaIndex
def __init__(self, prefix: str | Path | None = None, index: BwaIndex | None = None) -> None: ...
Expand Down
Loading

0 comments on commit 541a9fd

Please sign in to comment.