<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am basing my question on <a href="https://www.biostars.org/p/57549/">
https://www.biostars.org/p/57549/</a> which gives a code snipped which shows on how to add SeqFeatures.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Adapted, that code looks like this:<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal">from Bio import SeqFeature;<o:p></o:p></p>
<p class="MsoNormal">spos = SeqFeature.BeforePosition(50);<o:p></o:p></p>
<p class="MsoNormal">epos = SeqFeature.ExactPosition(100);<o:p></o:p></p>
<p class="MsoNormal">from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation<o:p></o:p></p>
<p class="MsoNormal"><span lang="FR">l1 = FeatureLocation(spos, epos, strand=+1)<o:p></o:p></span></p>
<p class="MsoNormal">f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And it does work, no problem.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, I have some terrible issues with the above code: it imports SeqFeature twice. And I cannot write:<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal">from Bio import SeqFeature;<o:p></o:p></p>
<p class="MsoNormal">from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation<o:p></o:p></p>
<p class="MsoNormal">…<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">as this will bomb.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal">def myfun():<o:p></o:p></p>
<p class="MsoNormal"> from Bio import SeqFeature;<o:p></o:p></p>
<p class="MsoNormal"> spos = SeqFeature.BeforePosition(50);<o:p></o:p></p>
<p class="MsoNormal"> epos = SeqFeature.ExactPosition(100);<o:p></o:p></p>
<p class="MsoNormal"> from Bio.SeqFeature import SeqFeature, FeatureLocation, CompoundLocation<o:p></o:p></p>
<p class="MsoNormal"><span lang="FR"> l 1 = FeatureLocation(spos, epos, strand=+1)<o:p></o:p></span></p>
<p class="MsoNormal"> f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This seems so infinitely wrong to me. What’s the correct way to write a function like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal">from … import …<o:p></o:p></p>
<p class="MsoNormal">from … import …<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def myfun(x,y):<o:p></o:p></p>
<p class="MsoNormal"> spos = SeqFeature.BeforePosition(x);<o:p></o:p></p>
<p class="MsoNormal"><span lang="FR"> epos = SeqFeature.ExactPosition(y);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> l 1 = FeatureLocation(spos, epos, strand=+1)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> </span>f1 = SeqFeature(l1, strand=1, type="CDS", qualifiers={});<o:p></o:p></p>
<p class="MsoNormal"> return f1;<o:p></o:p></p>
<p class="MsoNormal">---<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,<o:p></o:p></p>
<p class="MsoNormal"> Bastien<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:8.5pt;color:#008FD5">-- <br>
DSM Nutritional Products Microbia Inc | Bioinformatics<br>
60 Westview Street | Lexington, MA 02421 | United States<br>
Phone +1 781 259 7613 | Fax +1 781 259 0615</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
DISCLAIMER:<br>
This e-mail is for the intended recipient only.<br>
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.<br>
If you as intended recipient have received this e-mail incorrectly, please notify the sender (via e-mail) immediately.<br>
</font>
</body>
</html>