Skip to content

Commit

Permalink
Cope with between locations N^1 on circular GenBank/EMBL files of len…
Browse files Browse the repository at this point in the history
…gth N (Bug 3098)
  • Loading branch information
peterjc committed Jun 10, 2010
1 parent 57c3496 commit 80aa43e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Bio/GenBank/__init__.py
Expand Up @@ -819,11 +819,16 @@ def _get_location(self, range_info):
If parser.use_fuzziness is set at one, the positions for the
end points will possibly be fuzzy.
"""
if isinstance(range_info, LocationParser.Between) \
and range_info.low.val+1 == range_info.high.val:
if isinstance(range_info, LocationParser.Between):
if not (range_info.low.val+1 == range_info.high.val \
or range_info.low.val==self._expected_size \
and range_info.high.val==1):
raise ValueError(range_info)
#A between location like "67^68" (one based counting) is a
#special case (note it has zero length). In python slice
#notation this is 67:67, a zero length slice. See Bug 2622
#Further more, on a circular genome of length N you can have
#a location N^1 meaning the junction at the origin. See Bug 3098.
pos = self._get_position(range_info.low)
return SeqFeature.FeatureLocation(pos, pos)
#NOTE - We can imagine between locations like "2^4", but this
Expand Down
2 changes: 2 additions & 0 deletions Tests/EMBL/DD231055_edited.embl
Expand Up @@ -50,6 +50,8 @@ FT /note=Seventh note, without
FT
FT with quotes, and an indented blank line.
FT /note=Eigtht note, without quotes, but with a single very long line which breaks another rule.
FT misc_feature 315^1
FT /note="This would make sense on a circular genome!"
XX
SQ Sequence 315 BP; 78 A; 81 C; 79 G; 77 T; 0 other;
gccgagctga cccagtctcc atcctccctg tctgcatctg taggagacag agtcaccatc 60
Expand Down

0 comments on commit 80aa43e

Please sign in to comment.