mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences
https://pypi.python.org/pypi/pyfaidx
Other
459 stars 75 forks source link

complement() throws exception on empty sequences #81

Closed timodonnell closed 8 years ago

timodonnell commented 8 years ago

I'm happy to make a PR that addresses this if you like.

In [15]: pyfaidx.Sequence(seq="").complement
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-15-1fe22f7ee483> in <module>()
----> 1 pyfaidx.Sequence(seq="").complement

/Users/tim/venvs/analysis-venv-2.7/lib/python2.7/site-packages/pyfaidx/__init__.pyc in complement(self)
    160         TAGCAT
    161         """
--> 162         comp = self.__class__(self.name, complement(self.seq),
    163                               start=self.start, end=self.end)
    164         comp.comp = False if self.comp else True

/Users/tim/venvs/analysis-venv-2.7/lib/python2.7/site-packages/pyfaidx/__init__.pyc in complement(seq)
    761     else:
    762         matches = re.findall(dna_bases, seq)
--> 763         position = len(matches[0])
    764         raise ValueError("Sequence contains non-DNA character '{0}' at position {1:n}\n".format(seq[position], position + 1))
    765

IndexError: list index out of range
mdshw5 commented 8 years ago

Please do!

On Dec 8, 2015, at 12:26 PM, timodonnell notifications@github.com wrote:

I'm happy to make a PR that addresses this if you like.