Browse files

Check feature location start/end vs min/max

  • Loading branch information...
1 parent 0d1b879 commit f645588aa3f0b625cabb2f31ec16224c95de9aeb @peterjc peterjc committed with peterjc Sep 3, 2012
Showing with 18 additions and 1 deletion.
  1. +13 −0 Bio/SeqFeature.py
  2. +5 −1 Tests/test_SeqIO_features.py
View
13 Bio/SeqFeature.py
@@ -949,6 +949,19 @@ def __init__(self, parts, operator="join"):
>>> list(f)
[3, 4, 5, 12, 11, 10]
+ The example above doing list(f) iterates over the coordinates within the
+ feature. This allows you to use max and min on the location, which should
+ be equivalent to the location's start and end limits.
+
+ >>> min(f)
+ 3
+ >>> max(12)
+ 10
+ >>> f.start == min(f)
+ True
+ >>> f.end == max(f) + 1
+ True
+
Note that adding locations provides a more intuitive method of
construction:
View
6 Tests/test_SeqIO_features.py
@@ -276,7 +276,11 @@ def check(self, parent_seq, feature, answer_str, location_str):
set(i for i in range(1000) if i in feature))
if feature.strand == +1:
self.assertEqual(s, "".join(parent[i] for i in feature))
-
+ if len(feature):
+ self.assertEqual(feature.location.start, min(feature.location))
+ self.assertEqual(feature.location.end, max(feature.location)+1)
+ self.assertTrue(len(feature) <= feature.location.end - feature.location.start)
+
def test_simple_rna(self):
"""Feature on RNA (simple, default strand)"""
s = Seq("GAUCRYWSMKHBVDN", generic_rna)

0 comments on commit f645588

Please sign in to comment.