Skip to content

Commit

Permalink
Remove SeqFeature sub_features
Browse files Browse the repository at this point in the history
Removing the code from the SeqFeature itself was the easy part.
Updating all the tests and remaining legacy code still using it
(preceeding commits) took a bit longer.
  • Loading branch information
peterjc committed Jul 20, 2016
1 parent ed56933 commit 5befe3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 51 deletions.
65 changes: 15 additions & 50 deletions Bio/SeqFeature.py
Expand Up @@ -86,10 +86,6 @@ class SeqFeature(object):
analogous to the qualifiers from a GenBank feature table. The keys of
the dictionary are qualifier names, the values are the qualifier
values.
- sub_features - Obsolete list of additional SeqFeatures which was
used for holding compound locations (e.g. joins in GenBank/EMBL).
This is now superceded by a CompoundLocation as the location, and
should not be used (DEPRECATED).
"""

def __init__(self, location=None, type='', location_operator='',
Expand Down Expand Up @@ -156,39 +152,15 @@ def __init__(self, location=None, type='', location_operator='',
if qualifiers is None:
qualifiers = {}
self.qualifiers = qualifiers
if sub_features is None:
sub_features = []
else:
import warnings
from Bio import BiopythonDeprecationWarning
warnings.warn("Rather than sub_features, use a CompoundFeatureLocation",
BiopythonDeprecationWarning)
self._sub_features = sub_features
if sub_features is not None:
raise TypeError("Rather than sub_features, use a CompoundFeatureLocation")
if ref is not None:
# TODO - Deprecation warning
self.ref = ref
if ref_db is not None:
# TODO - Deprecation warning
self.ref_db = ref_db

def _get_sub_features(self):
if self._sub_features:
import warnings
from Bio import BiopythonDeprecationWarning
warnings.warn("Rather using f.sub_features, f.location should be a CompoundFeatureLocation",
BiopythonDeprecationWarning)
return self._sub_features

def _set_sub_features(self, value):
if value:
import warnings
from Bio import BiopythonDeprecationWarning
warnings.warn("Rather than f.sub_features, use a CompoundFeatureLocation for f.location",
BiopythonDeprecationWarning)
self._sub_features = value
sub_features = property(fget=_get_sub_features, fset=_set_sub_features,
doc="Obsolete representation of compound locations (DEPRECATED).")

def _get_strand(self):
return self.location.strand

Expand Down Expand Up @@ -295,14 +267,11 @@ def _shift(self, offset):
"""Returns a copy of the feature with its location shifted (PRIVATE).
The annotation qaulifiers are copied."""
answer = SeqFeature(location=self.location._shift(offset),
type=self.type,
location_operator=self.location_operator,
id=self.id,
qualifiers=dict(self.qualifiers.items()))
# This is to avoid the deprecation warning:
answer._sub_features = [f._shift(offset) for f in self._sub_features]
return answer
return SeqFeature(location=self.location._shift(offset),
type=self.type,
location_operator=self.location_operator,
id=self.id,
qualifiers=dict(self.qualifiers.items()))

def _flip(self, length):
"""Returns a copy of the feature with its location flipped (PRIVATE).
Expand All @@ -314,15 +283,11 @@ def _flip(self, length):
The annotation qaulifiers are copied.
"""
answer = SeqFeature(location=self.location._flip(length),
type=self.type,
location_operator=self.location_operator,
id=self.id,
qualifiers=dict(self.qualifiers.items()))
# This is to avoid the deprecation warning:
answer._sub_features = [f._flip(length)
for f in self._sub_features[::-1]]
return answer
return SeqFeature(location=self.location._flip(length),
type=self.type,
location_operator=self.location_operator,
id=self.id,
qualifiers=dict(self.qualifiers.items()))

def extract(self, parent_sequence):
"""Extract feature sequence from the supplied parent sequence.
Expand Down Expand Up @@ -356,7 +321,7 @@ def extract(self, parent_sequence):
...
ValueError: The feature's .location is None. Check the sequence file for a valid location.
Note - currently only sub-features of type "join" are supported.
Note - currently only compound features of type "join" are supported.
"""
if self.location is None:
raise ValueError("The feature's .location is None. Check the "
Expand Down Expand Up @@ -564,8 +529,8 @@ class FeatureLocation(object):
be described as running from a start position to and end position
(optionally with a strand and reference information). More complex
locations made up from several non-continuous parts (e.g. a coding
sequence made up of several exons) are currently described using a
SeqFeature with sub-features.
sequence made up of several exons) are described using a SeqFeature
with a CompoundLocation.
Note that the start and end location numbering follow Python's scheme,
thus a GenBank entry of 123..150 (one based counting) becomes a location
Expand Down
2 changes: 1 addition & 1 deletion DEPRECATED
Expand Up @@ -101,7 +101,7 @@ include when installing Biopython from source due to a dependency on flex.
Bio.SeqFeature
==============
With the introduction of the CompoundLocation in Release 1.62, the SeqFeature
attribute sub_features was deprecated.
attribute sub_features was deprecated. It was removed in Release 1.68.

Bio.Motif
=========
Expand Down

0 comments on commit 5befe3f

Please sign in to comment.