You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a 'Fasta' index is created with 'strict_bounds=True', then attempts to extract 0-length sequences fail. This might be an odd case, but it can happen in limiting cases of algorithms that want to treat the sequence as a standard Python sequence. The following tests demonstrate the error:
Error
Traceback (most recent call last):
File "/Users/hauge/dev/tools/pyfaidx/tests/test_feature_sequence_as_raw.py", line 57, in test_zero_length_subsequence
result = fasta['gi|557361099|gb|KF435150.1|'][100:100]
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 581, in __getitem__
return self._fa.get_seq(self.name, start + 1, stop)[::step]
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 715, in get_seq
return self.faidx.fetch(name, start, end)
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 447, in fetch
seq = self.from_file(name, start, end)
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 493, in from_file
"invalid.\n".format(start, end))
pyfaidx.FetchError: Requested coordinates start=101 end=100 are invalid.
If the logic in 'from_file' is fixed to allow a zero-length sequence, the second will still fail when it tries to construct a 'Sequence':
Error
Traceback (most recent call last):
File "/Users/hauge/dev/tools/pyfaidx/tests/test_feature_sequence_as_raw.py", line 57, in test_zero_length_subsequence
result = fasta['gi|557361099|gb|KF435150.1|'][100:100]
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 583, in __getitem__
return self._fa.get_seq(self.name, start + 1, stop)[::step]
File "/Users/hauge/dev/tools/pyfaidx/pyfaidx/__init__.py", line 118, in __getitem__
raise ValueError("Coordinates start=%s and end=%s imply a diffent length than sequence (length %s)." % (self.start, self.end, len(self.seq)))
ValueError: Coordinates start=101 and end=100 imply a diffent length than sequence (length 0).
The text was updated successfully, but these errors were encountered:
I sincerely forgot about this issue, and thanks to @prihoda for submitting a PR. Also thanks @dhauge for not only writing tests, but basing them on my existing test style. Thanks! Will close this issue as #155 provides a fix.
If a 'Fasta' index is created with 'strict_bounds=True', then attempts to extract 0-length sequences fail. This might be an odd case, but it can happen in limiting cases of algorithms that want to treat the sequence as a standard Python sequence. The following tests demonstrate the error:
The first raw sequence test fails with
If the logic in 'from_file' is fixed to allow a zero-length sequence, the second will still fail when it tries to construct a 'Sequence':
The text was updated successfully, but these errors were encountered: