Skip to content

Commit

Permalink
added mappy.Aligner.seq_names to return seq names
Browse files Browse the repository at this point in the history
Resolves lh3#312
  • Loading branch information
lh3 committed Jan 29, 2019
1 parent 8b05880 commit aaf3233
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~

Expand Down
10 changes: 10 additions & 0 deletions python/mappy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit aaf3233

Please sign in to comment.