Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Nov 16, 2024
2 parents 46750de + 7d8bbb7 commit 1d346d5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion misc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ minimap2 -c test/MT-human.fa test/MT-orang.fa \
| paftools.js liftover -l10000 - <(echo -e "MT_orang\t2000\t5000") # liftOver
# no test data for the following examples
paftools.js junceval -e anno.gtf splice.sam > out.txt # compare splice junctions to annotations
paftools.js splice2bed anno.gtf > anno.bed # convert GTF/GFF3 to BED12
paftools.js splice2bed splice.sam > splice.bed # convert PAF/SAM to BED12
paftools.js gff2bed anno.gtf > anno.bed # convert GTF/GFF3 to BED12
```

## Table of Contents
Expand Down
6 changes: 3 additions & 3 deletions python/cmappy.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ static inline void mm_reset_timer(void)
}

extern unsigned char seq_comp_table[256];
static inline mm_reg1_t *mm_map_aux(const mm_idx_t *mi, const char *seq1, const char *seq2, int *n_regs, mm_tbuf_t *b, const mm_mapopt_t *opt)
static inline mm_reg1_t *mm_map_aux(const mm_idx_t *mi, const char* seqname, const char *seq1, const char *seq2, int *n_regs, mm_tbuf_t *b, const mm_mapopt_t *opt)
{
mm_reg1_t *r;

Py_BEGIN_ALLOW_THREADS
if (seq2 == 0) {
r = mm_map(mi, strlen(seq1), seq1, n_regs, b, opt, NULL);
r = mm_map(mi, strlen(seq1), seq1, n_regs, b, opt, seqname);
} else {
int _n_regs[2];
mm_reg1_t *regs[2];
Expand All @@ -94,7 +94,7 @@ static inline mm_reg1_t *mm_map_aux(const mm_idx_t *mi, const char *seq1, const
seq[1][i] = seq_comp_table[t];
}
if (len[1]&1) seq[1][len[1]>>1] = seq_comp_table[(uint8_t)seq[1][len[1]>>1]];
mm_map_frag(mi, 2, len, (const char**)seq, _n_regs, regs, b, opt, NULL);
mm_map_frag(mi, 2, len, (const char**)seq, _n_regs, regs, b, opt, seqname);
for (i = 0; i < _n_regs[1]; ++i)
regs[1][i].rev = !regs[1][i].rev;
*n_regs = _n_regs[0] + _n_regs[1];
Expand Down
2 changes: 1 addition & 1 deletion python/cmappy.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cdef extern from "cmappy.h":

void mm_reg2hitpy(const mm_idx_t *mi, mm_reg1_t *r, mm_hitpy_t *h)
void mm_free_reg1(mm_reg1_t *r)
mm_reg1_t *mm_map_aux(const mm_idx_t *mi, const char *seq1, const char *seq2, int *n_regs, mm_tbuf_t *b, const mm_mapopt_t *opt)
mm_reg1_t *mm_map_aux(const mm_idx_t *mi, const char* seqname, const char *seq1, const char *seq2, int *n_regs, mm_tbuf_t *b, const mm_mapopt_t *opt)
char *mappy_fetch_seq(const mm_idx_t *mi, const char *name, int st, int en, int *l)
mm_idx_t *mappy_idx_seq(int w, int k, int is_hpc, int bucket_bits, const char *seq, int l)

Expand Down
19 changes: 15 additions & 4 deletions python/mappy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ cdef class Aligner:
cdef cmappy.mm_idxopt_t idx_opt
cdef cmappy.mm_mapopt_t map_opt

def __cinit__(self, fn_idx_in=None, preset=None, k=None, w=None, min_cnt=None, min_chain_score=None, min_dp_score=None, bw=None, bw_long=None, best_n=None, n_threads=3, fn_idx_out=None, max_frag_len=None, extra_flags=None, seq=None, scoring=None):
def __cinit__(self, fn_idx_in=None, preset=None, k=None, w=None, min_cnt=None, min_chain_score=None, min_dp_score=None, bw=None, bw_long=None, best_n=None, n_threads=3, fn_idx_out=None, max_frag_len=None, extra_flags=None, seq=None, scoring=None, sc_ambi=None, max_chain_skip=None):
self._idx = NULL
cmappy.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options
if preset is not None:
Expand All @@ -138,6 +138,8 @@ cdef class Aligner:
self.map_opt.q2, self.map_opt.e2 = scoring[4], scoring[5]
if len(scoring) >= 7:
self.map_opt.sc_ambi = scoring[6]
if sc_ambi is not None: self.map_opt.sc_ambi = sc_ambi
if max_chain_skip is not None: self.map_opt.max_chain_skip = max_chain_skip

cdef cmappy.mm_idx_reader_t *r;

Expand All @@ -163,7 +165,7 @@ cdef class Aligner:
def __bool__(self):
return (self._idx != NULL)

def map(self, seq, seq2=None, buf=None, cs=False, MD=False, max_frag_len=None, extra_flags=None):
def map(self, seq, seq2=None, name=None, buf=None, cs=False, MD=False, max_frag_len=None, extra_flags=None):
cdef cmappy.mm_reg1_t *regs
cdef cmappy.mm_hitpy_t h
cdef ThreadBuffer b
Expand All @@ -185,11 +187,20 @@ cdef class Aligner:
km = cmappy.mm_tbuf_get_km(b._b)

_seq = seq if isinstance(seq, bytes) else seq.encode()
if name is not None:
_name = name if isinstance(name, bytes) else name.encode()

if seq2 is None:
regs = cmappy.mm_map_aux(self._idx, _seq, NULL, &n_regs, b._b, &map_opt)
if name is None:
regs = cmappy.mm_map_aux(self._idx, NULL, _seq, NULL, &n_regs, b._b, &map_opt)
else:
regs = cmappy.mm_map_aux(self._idx, _name, _seq, NULL, &n_regs, b._b, &map_opt)
else:
_seq2 = seq2 if isinstance(seq2, bytes) else seq2.encode()
regs = cmappy.mm_map_aux(self._idx, _seq, _seq2, &n_regs, b._b, &map_opt)
if name is None:
regs = cmappy.mm_map_aux(self._idx, NULL, _seq, _seq2, &n_regs, b._b, &map_opt)
else:
regs = cmappy.mm_map_aux(self._idx, _name, _seq, _seq2, &n_regs, b._b, &map_opt)

try:
i = 0
Expand Down

0 comments on commit 1d346d5

Please sign in to comment.