Skip to content

Commit 322cd90

Browse files
manulerapeterjc
authored andcommitted
closes #5162
1 parent 736c96f commit 322cd90

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

Bio/SeqIO/SnapGeneIO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _parse_location(rangespec, strand, record, is_primer=False):
119119
# for some reasons
120120
start += 1
121121
end += 1
122-
if start > end:
122+
if start >= end:
123123
# Range wrapping the end of the sequence
124124
l1 = SimpleLocation(start, len(record), strand=strand)
125125
l2 = SimpleLocation(0, end, strand=strand)
@@ -158,7 +158,7 @@ def _parse_features_packet(length, data, record):
158158
rng = _get_attribute_value(segment, "range")
159159
n_parts += 1
160160
next_location = _parse_location(rng, strand, record)
161-
if not location:
161+
if location is None:
162162
location = next_location
163163
elif strand == -1:
164164
# Reverse segments order for reverse-strand features

Tests/SnapGene/looped_feature.dna

10.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.

Tests/test_SeqIO_SnapGene.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,21 @@ def test_remove_linebreaks_from_qualifier_values(self):
284284
self.assertFalse("\n" in value)
285285
self.assertFalse("\r" in value)
286286

287+
def test_looped_feature(self):
288+
"""Read a file that has a circular sequence with a feature that spans the entire sequence"""
289+
290+
# If the feature spans the sequence from start to end
291+
record = SeqIO.read("SnapGene/looped_feature_origin.dna", "snapgene")
292+
self.assertEqual(record.annotations["topology"], "circular")
293+
self.assertEqual(len(record.features), 1)
294+
self.assertEqual(str(record.features[0].location), "[0:10](+)")
295+
296+
# If the feature spans the entire sequence, but starts somewhere in the middle
297+
record = SeqIO.read("SnapGene/looped_feature.dna", "snapgene")
298+
self.assertEqual(record.annotations["topology"], "circular")
299+
self.assertEqual(len(record.features), 1)
300+
self.assertEqual(str(record.features[0].location), "join{[2:10](+), [0:2](+)}")
301+
287302

288303
class TestCorruptedSnapGene(unittest.TestCase):
289304
def setUp(self):

0 commit comments

Comments
 (0)