Permalink
Browse files

Avoid the sub_features deprecation warning in these methods.

This was being triggered in for example SeqRecord addition of
GenBank records.
  • Loading branch information...
peterjc committed May 10, 2013
1 parent 11a5527 commit 815d49625ee341139bfe6a68c60d8217c9f7c812
Showing with 16 additions and 12 deletions.
  1. +16 −12 Bio/SeqFeature.py
View
@@ -284,12 +284,14 @@ def _shift(self, offset):
"""Returns a copy of the feature with its location shifted (PRIVATE).
The annotation qaulifiers are copied."""
- return SeqFeature(location = self.location._shift(offset),
- type = self.type,
- location_operator = self.location_operator,
- id = self.id,
- qualifiers = dict(self.qualifiers.iteritems()),
- sub_features = [f._shift(offset) for f in self._sub_features])
+ answer = SeqFeature(location = self.location._shift(offset),
+ type = self.type,
+ location_operator = self.location_operator,
+ id = self.id,
+ qualifiers = dict(self.qualifiers.iteritems()))
+ #This is to avoid the deprecation warning:
+ answer._sub_features = [f._shift(offset) for f in self._sub_features]
+ return answer
def _flip(self, length):
"""Returns a copy of the feature with its location flipped (PRIVATE).
@@ -301,12 +303,14 @@ def _flip(self, length):
The annotation qaulifiers are copied.
"""
- return SeqFeature(location = self.location._flip(length),
- type = self.type,
- location_operator = self.location_operator,
- id = self.id,
- qualifiers = dict(self.qualifiers.iteritems()),
- sub_features = [f._flip(length) for f in self._sub_features[::-1]])
+ answer = SeqFeature(location = self.location._flip(length),
+ type = self.type,
+ location_operator = self.location_operator,
+ id = self.id,
+ qualifiers = dict(self.qualifiers.iteritems()))
+ #This is to avoid the deprecation warning:
+ answer._sub_features = [f._flip(length) for f in self._sub_features[::-1]]
+ return answer
def extract(self, parent_sequence):
"""Extract feature sequence from the supplied parent sequence.

0 comments on commit 815d496

Please sign in to comment.