diff --git a/python/README.rst b/python/README.rst index 482c735..3d0fae8 100644 --- a/python/README.rst +++ b/python/README.rst @@ -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 ~~~~~~~~~~~~~~~~~~~~~ diff --git a/python/mappy.pyx b/python/mappy.pyx index 8d55fca..7b0667f 100644 --- a/python/mappy.pyx +++ b/python/mappy.pyx @@ -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))