mirror of
https://github.com/lh3/minimap2.git
synced 2026-09-15 21:17:54 +08:00
Allow passing read name to mappy (#1260)
* Allow passing read name to mappy This adds the (optional) ability to pass the read name to the mappy `map` method. Without the read name, the call to `map` can sometimes give different output than the command line version of `minimap2` because of the way minimap uses the hash of the read name to break ties in ordering hits. This can affect which / if certain supplementary alignments are generated, and even which / if non-primary alignments are generated. * Pass name directly to mm_map_aux Get rid of additional function, and always accept the name parameter in the mm_map_aux function (can be nullptr if not available). --------- Co-authored-by: Rob Patro <rob@newton>
This commit is contained in:
@@ -163,7 +163,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
|
||||
@@ -185,11 +185,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
|
||||
|
||||
Reference in New Issue
Block a user