You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FeatureLocation allows for swapped start and end coordinates #1497
Setup
I am reporting a problem with Biopython version, Python version, and operating
system as follows:
2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
CPython
Darwin-16.7.0-x86_64-i386-64bit
1.70
Expected behaviour
If given a malformed location string in a genbank file where the end location is smaller than the start location(e.g. 3000..1000) I expect Biopython to raise a warning.
Actual behaviour
In practice, the parser happily makes a feature location like this: FeatureLocation(ExactPosition(2999), ExactPosition(1000), strand=1)
Start & end violate the rule that location.end > location. start
Calling the length attribute on this feature raises an exception:
File "<input>", line 1, in <module>
File "/Library/Python/2.7/site-packages/Bio/SeqFeature.py", line 383, in __len__
return len(self.location)
ValueError: __len__() should return >= 0
Steps to reproduce
This is another corner case discovered using a mocked up genbank file: minimal.txt
It's clearly not a proper format for the genbank location but I think it's not unreasonable to expect that manually edited files might contain errors like this one and the parse should detect that.
One can also manually generate a faulty feature location: FeatureLocation(3000,1000)
The feature positions define an order, so this could be added to the FeatureLocation.__init__ and cover both parser-created locations and user-created locations. It would be simplest to have this raise an exception there.
However, you specifically suggested a warning when parsing problematic locations like this. Would an exception cause you problems?
Would you like to work on this (submit a pull request)?
Activity
peterjc commentedon Jan 9, 2018
The feature positions define an order, so this could be added to the
FeatureLocation.__init__and cover both parser-created locations and user-created locations. It would be simplest to have this raise an exception there.However, you specifically suggested a warning when parsing problematic locations like this. Would an exception cause you problems?
Would you like to work on this (submit a pull request)?
Addresses biopython#1497:
JamesJeffryes commentedon Jan 9, 2018
An exception will be fine for my uses. Thanks!
Addresses #1497:
peterjc commentedon Jan 31, 2018
Closed via #1499, thank you James!
GenBank/EMBL: Downgrade bad origin wrapping to a warning
GenBank/EMBL: Downgrade bad origin wrapping to a warning
GenBank/EMBL: Downgrade bad origin wrapping to a warning