Skip to content

Commit

Permalink
UnknownSeq's count was ignoring the optional start/end values, and di…
Browse files Browse the repository at this point in the history
…dn't check for an invalid alphabet.
  • Loading branch information
peterc committed Mar 31, 2009
1 parent faf51f4 commit 3a206ec
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Bio/Seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,23 @@ def count(self, sub, start=0, end=sys.maxint):
1
"""
if len(sub) == 1 :
if str(sub) == self._character :
return self._length
sub_str = self._get_seq_str_and_check_alphabet(sub)
if len(sub_str) == 1 :
if str(sub_str) == self._character :
if start==0 and end >= self._length :
return self._length
else :
#This could be done more cleverly...
return str(self).count(sub_str, start, end)
else :
return 0
else :
if set(sub) == set(self._character) :
return self._length // len(sub)
if set(sub_str) == set(self._character) :
if start==0 and end >= self._length :
return self._length // len(sub_str)
else :
#This could be done more cleverly...
return str(self).count(sub_str, start, end)
else :
return 0

Expand Down

0 comments on commit 3a206ec

Please sign in to comment.