<div dir="ltr"><div>Hi Franz,</div><div><br></div><div>That's something which I think catches out a lot of people learning Python. I'm glad to hear that this seems to have fixed things.</div><div><br></div><div>Happy to have helped,</div><div><br></div><div>Peter</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 11, 2020 at 11:04 PM F.L. Ratzkowski <<a href="mailto:flr28@cam.ac.uk">flr28@cam.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
so much I think I just solved it. Apparently i was sitting on a finished product,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
and was exactly the compareAfter compareBefore that was the problem. I am so happy after 2 days of struggling. So when I assigned the SeqRecord.feature = Compart1  i thought this was just a copy apparently it was still linked and Compared1 got also updated
 by the later modifications of SeqRecord. so that Compare2 = Compare1. now loading in the same seqrecord but on a new variable SecRecord2 as reference that didnt got updated could provide me all the hits.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I hope you understand.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks for putting in your time and sorry for my bad spelling.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Best wishes,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Franz</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-2897816162362452181Signature">
<div>
<div></div>
<div style="text-align:start;box-sizing:border-box">
<div dir="auto" style="box-sizing:border-box">
<div style="text-align:left;color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;box-sizing:border-box">
</div>
</div>
</div>
<div style="margin:0px;font-family:Helvetica,Arial;font-size:12.8px;text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">Franz L. Böge</span></span></div>
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">PhD Student, </span></span><span style="font-family:Arial,Helvetica,sans-serif;font-size:10pt">University
 of Cambridge</span></div>
</div>
<div style="margin:0px;font-family:Helvetica,Arial;font-size:12.8px;text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal"><span style="font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Chin
 Group, </span>MRC Laboratory of Molecular Biology</span></span></div>
</div>
<div style="margin:0px;color:rgb(50,49,48);text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">Phone: +44
 (0)1223 267604</span></span><br>
</div>
</div>
<br>
<br style="text-align:start">
<br>
<br>
</div>
</div>
</div>
<div id="gmail-m_-2897816162362452181appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-2897816162362452181divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>><br>
<b>Sent:</b> 11 November 2020 22:41<br>
<b>To:</b> F.L. Ratzkowski <<a href="mailto:flr28@cam.ac.uk" target="_blank">flr28@cam.ac.uk</a>><br>
<b>Cc:</b> <a href="mailto:biopython@biopython.org" target="_blank">biopython@biopython.org</a> <<a href="mailto:biopython@biopython.org" target="_blank">biopython@biopython.org</a>><br>
<b>Subject:</b> Re: [Biopython] Updating feature Location in Seqfiles</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi Franz,
<div><br>
</div>
<div>Perhaps this example will help explain what I meant?</div>
<div><br>
</div>
<div>>>> old_list = ["A", "B", "C", "D"]<br>
>>> new_list = old_list<br>
>>> new_list[3] = "Z"<br>
>>> new_list == old_list<br>
True<br>
>>> old_list<br>
['A', 'B', 'C', 'Z']<br>
</div>
<div><br>
</div>
<div>In your example, CompareBefore, CompareAfter, and Seqfile.features are all the same list.</div>
<div><br>
</div>
<div>Peter</div>
<div><br>
</div>
</div>
<br>
<div>
<div dir="ltr">On Wed, Nov 11, 2020 at 8:26 PM F.L. Ratzkowski <<a href="mailto:flr28@cam.ac.uk" target="_blank">flr28@cam.ac.uk</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
first of all thank you for your quick responds. I indeed mean Seqrecord sorry for being not fully accurate. The SeqRecord is a whole E.coli genome with lots of features. and the changes to the sequence I am making are due to random mutation means that they
 also occur in features and thereby affect the start and end position differently as well as features overlapping, thus i feel like the shifting or chunking method might not work. Or if so could u please provide more detail</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
You stating '<span style="color:rgb(32,31,30);font-size:15px">both lists CompareBefore</span>
<div style="margin:0px;font-size:15px;color:rgb(32,31,30);background-color:rgb(255,255,255)">
and CompareAfter will be the same list. Thus you'd find no differences. ' could u elaborate, my understanding of the featurelocation command was that it would overwrite the previous feature.location.</div>
<div style="margin:0px;font-size:15px;color:rgb(32,31,30);background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px;font-size:15px;color:rgb(32,31,30);background-color:rgb(255,255,255)">
Thanks again for taking the time.</div>
<div style="margin:0px;font-size:15px;color:rgb(32,31,30);background-color:rgb(255,255,255)">
Best wishes,</div>
<div style="margin:0px;font-size:15px;color:rgb(32,31,30);background-color:rgb(255,255,255)">
Franz</div>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-2897816162362452181x_gmail-m_5431322730100457773Signature">
<div>
<div></div>
<div style="text-align:start;box-sizing:border-box">
<div dir="auto" style="box-sizing:border-box">
<div style="text-align:left;color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;box-sizing:border-box">
</div>
</div>
</div>
<div style="margin:0px;font-family:Helvetica,Arial;font-size:12.8px;text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">Franz L. Böge</span></span></div>
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">PhD Student, </span></span><span style="font-family:Arial,Helvetica,sans-serif;font-size:10pt">University
 of Cambridge</span></div>
</div>
<div style="margin:0px;font-family:Helvetica,Arial;font-size:12.8px;text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal"><span style="font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Chin
 Group, </span>MRC Laboratory of Molecular Biology</span></span></div>
</div>
<div style="margin:0px;color:rgb(50,49,48);text-align:start;box-sizing:border-box">
<div style="margin:0px;text-align:left"><span style="margin:0px;font-family:"Arial Black",Arial,sans-serif;font-size:10pt;line-height:normal"><span style="margin:0px;font-family:Arial,Helvetica,sans-serif;font-size:10pt;line-height:normal">Phone: +44
 (0)1223 267604</span></span><br>
</div>
</div>
<br>
<br style="text-align:start">
<br>
<br>
</div>
</div>
</div>
<div id="gmail-m_-2897816162362452181x_gmail-m_5431322730100457773appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-2897816162362452181x_gmail-m_5431322730100457773divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>><br>
<b>Sent:</b> 11 November 2020 19:40<br>
<b>To:</b> F.L. Ratzkowski <<a href="mailto:flr28@cam.ac.uk" target="_blank">flr28@cam.ac.uk</a>><br>
<b>Cc:</b> <a href="mailto:biopython@mailman.open-bio.org" target="_blank">biopython@mailman.open-bio.org</a> <<a href="mailto:biopython@mailman.open-bio.org" target="_blank">biopython@mailman.open-bio.org</a>><br>
<b>Subject:</b> Re: [Biopython] Updating feature Location in Seqfiles</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hello,</div>
<div><br>
</div>
<div>First what may be the simple answer: Looking at that code snippet, and</div>
<div>guessing that Seqfile is a SeqRecord object, both lists CompareBefore</div>
<div>and CompareAfter will be the same list. Thus you'd find no differences. </div>
<div><br>
</div>
<div>More generally, I would have recommend using slicing and addition of</div>
<div>SeqRecord chunks, which will reserve your features and shift their</div>
<div>coordinates accordingly - as long as each feature is fully within a chunk.</div>
<div>The tutorial covers this.</div>
<div><br>
</div>
<div>If you want to work more directly, you could try shifting a feature location</div>
<div>with an offset by adding (or subtracting an integer). (You could do something</div>
<div>similar with the (private) _shift methods, but that is not intended for direct use.)</div>
<div><br>
</div>
<div>However, it looks like you're taking what I would consider to be the hardest</div>
<div>option of rebuilding new location objects after all your sequence editing.</div>
<div>This is only reasonably straightforward if you have just simple locations</div>
<div>(like most bacterial features). Joins, origin wrapping, fuzzy locations etc</div>
<div>would need additional work.</div>
<div><br>
</div>
<div>
<div>Peter</div>
</div>
</div>
<br>
<div>
<div dir="ltr">On Wed, Nov 11, 2020 at 5:26 PM F.L. Ratzkowski <<a href="mailto:flr28@cam.ac.uk" target="_blank">flr28@cam.ac.uk</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
i am new here so I am sorry if I am doing anything wrong, feel free to tell me.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am farely new to biopython as well, currently i have written a script that reads in a .gbk file and then deletes and inserts different parts of the sequence. this would alter the absolute position of features. I have ultimately run a script that safes the
 new positions in 2 dataframes. When i now want to update all features with the Featurelocation command it seems to not work. I saved the features in a variable before and after me updating the features and was hoping to then detect a difference but it fails.
 here the basic part of the script i am struggling with</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
CompareBefore = Seqfile.features</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
for z in range(0, len(featureEndList)):
<div>    feature_end = int(ELdf.iloc[z][1])</div>
<div>    feature_start = int(SLdf.iloc[z][1])</div>
<div>    feature_strand = Seqfile.features[z].location.strand</div>
<div>    Seqfile.features[z].location = FeatureLocation(feature_start, feature_end,strand=feature_strand)</div>
<br>
<span style="background-color:rgb(255,255,255);display:inline">CompareAfter = Seqfile.features</span><br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
list = []
<div>for x in range(0,len(CompareAfter)):</div>
<div>    if CompareBefore[x] != CompareAfter[x]:</div>
        list.append(x)<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I get 0 hits in this list.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Please help <span id="gmail-m_-2897816162362452181x_gmail-m_5431322730100457773x_gmail-m_1991703643380665035🙂">
🙂 thank you</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
</div>
</div>
_______________________________________________<br>
Biopython mailing list  -  <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">
Biopython@mailman.open-bio.org</a><br>
<a href="https://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">https://mailman.open-bio.org/mailman/listinfo/biopython</a></blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>

</blockquote></div></div>