[Biopython] Problems with SeqFeature

Chevreux, Bastien bastien.chevreux at dsm.com
Mon Nov 21 20:12:17 UTC 2016


Hi all,

I am basing my question on https://www.biostars.org/p/57549/ which gives a code snipped which shows on how to add SeqFeatures.

Adapted, that code looks like this:
---
from Bio import SeqFeature;
spos = SeqFeature.BeforePosition(50);
epos = SeqFeature.ExactPosition(100);
from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation
l1 = FeatureLocation(spos, epos, strand=+1)
f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});
---

And it does work, no problem.

However, I have some terrible issues with the above code: it imports SeqFeature twice. And I cannot write:
---
from Bio import SeqFeature;
from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation
...
---

as this will bomb.

And therefore I cannot easily stick the above into a function without re-importing in the function every time I use the functionality. Like this:

---
def myfun():
    from Bio import SeqFeature;
    spos = SeqFeature.BeforePosition(50);
    epos = SeqFeature.ExactPosition(100);
    from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation
    l 1 = FeatureLocation(spos, epos, strand=+1)
    f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});
---

This seems so infinitely wrong to me. What's the correct way to write a function like this:

---
from ... import ...
from ... import ...

def myfun(x,y):
    spos = SeqFeature.BeforePosition(x);
    epos = SeqFeature.ExactPosition(y);
    l 1 = FeatureLocation(spos, epos, strand=+1)
    f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});
    return f1;
---

Best,
  Bastien


--
DSM Nutritional Products Microbia Inc | Bioinformatics
60 Westview Street | Lexington, MA 02421 | United States
Phone +1 781 259 7613 | Fax +1 781 259 0615


________________________________

DISCLAIMER:
This e-mail is for the intended recipient only.
If you have received it by mistake please let us know by reply and then delete it from your system; access, disclosure, copying, distribution or reliance on any of it by anyone else is prohibited.
If you as intended recipient have received this e-mail incorrectly, please notify the sender (via e-mail) immediately.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20161121/9ade175f/attachment.html>


More information about the Biopython mailing list