added mappy.Aligner.seq_names to return seq names

Resolves #312
This commit is contained in:
Heng Li 2019-01-29 12:53:20 -05:00
parent 8b05880f73
commit aaf3233818
2 changed files with 16 additions and 0 deletions

View File

@ -114,6 +114,12 @@ This method retrieves a (sub)sequence from the index and returns it as a Python
string. :code:`None` is returned if :code:`name` is not present in the index or
the start/end coordinates are invalid.
.. code:: python
mappy.Aligner.seq_names
This property gives the array of sequence names in the index.
Class mappy.Alignment
~~~~~~~~~~~~~~~~~~~~~

View File

@ -221,6 +221,16 @@ cdef class Aligner:
@property
def n_seq(self): return self._idx.n_seq
@property
def seq_names(self):
cdef char *p
sn = []
for i in range(self._idx.n_seq):
p = self._idx.seq[i].name
s = p if isinstance(p, str) else p.decode()
sn.append(s)
return sn
def fastx_read(fn, read_comment=False):
cdef cmappy.kseq_t *ks
ks = cmappy.mm_fastx_open(str.encode(fn))