Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Dec 18, 2024
1 parent a866b3f commit d53df42
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 71 deletions.
1 change: 0 additions & 1 deletion bwapy/libbwaaln.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ cdef class BwaAln:
"""The class to align reads with `bwa aln`."""

cdef BwaIndex _index
cdef unsigned char* _pacseq

def __init__(self, prefix: str | Path | None = None, index: BwaIndex | None = None):
if prefix is not None:
Expand Down
39 changes: 36 additions & 3 deletions bwapy/libbwamem.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# cython: language_level=3

from libc.stdint cimport uint8_t, int64_t, int32_t, uint64_t, int8_t
from libc.stdint cimport uint8_t, int64_t, int32_t, uint64_t, int8_t, uint32_t
from libc.stdio cimport FILE

cdef extern from "limits.h":
cdef int INT_MAX

cdef extern from "bwt.h":
ctypedef struct bwt_t:
int sa_intv
Expand All @@ -19,6 +22,13 @@ cdef extern from "bntseq.h":
bntann1_t *anns
FILE * fp_pac

unsigned char nst_nt4_table[256]

cdef extern from "kstring.h":
ctypedef struct kstring_t:
size_t l, m
char *s


cdef extern from "bwamem.h":
int MEM_F_PE
Expand Down Expand Up @@ -70,9 +80,32 @@ cdef extern from "bwamem.h":
int max_matesw # perform maximally max_matesw rounds of mate-SW for each end
int max_XA_hits, max_XA_hits_alt # if there are max_hits or fewer, output them all
int8_t mat[25] # scoring matrix mat[0] == 0 if unset
ctypedef struct mem_alnreg_t:
int score # best local SW score
int secondary # index of the parent hit shadowing the current hit; <0 if primary
int n_comp # number of sub-alignments chained together
int is_alt

ctypedef struct mem_alnreg_v:
pass
size_t n, m
mem_alnreg_t *a

ctypedef struct mem_aln_t:
int flag # extra flag
uint32_t is_rev # is_rev: whether on the reverse strand;
uint32_t is_alt
uint32_t mapq # mapq: mapping quality;
uint32_t NM # NM: edit distance
char *XA
int score, sub, alt_sc;

mem_opt_t *mem_opt_init()
mem_alnreg_v mem_align1(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq)
void bwa_fill_scmat(int a, int b, int8_t mat[25])
void bwa_fill_scmat(int a, int b, int8_t mat[25])
mem_aln_t mem_reg2aln(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq, const mem_alnreg_t *ar)

# from bwamem.c
cdef extern void mem_reorder_primary5(int T, mem_alnreg_v *a)

# from bwamem_extra.c
cdef extern char **mem_gen_alt(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, mem_alnreg_v *a, int l_query, const char *query);
16 changes: 14 additions & 2 deletions bwapy/libbwamem.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
from pathlib import Path
from typing import List

from pysam import AlignedSegment
from pysam import FastxRecord

from bwapy.libbwaindex import BwaIndex

class BwaMemOptions:
_ignore_alt: bool
def __init__(self) -> None: ...


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

class BwaMem:
_index: BwaIndex
def __init__(self, prefix: str | Path | None = None, index: BwaIndex | None = None) -> None: ...
def align(
self, opt: BwaMemOptions, queries: List[FastxRecord]
) -> List[List[AlignedSegment]]: ...
Loading

0 comments on commit d53df42

Please sign in to comment.