Re: [Biopython] Updating feature Location in Seqfiles
Peter Cock <[email protected]> Wed, 11 Nov 2020 19:40:38 +0000
| Newsgroups | gmane.comp.python.bio.general |
|---|---|
| Message-ID | <CAKVJ-_6-aA4jNikVtxHpJUiMDe+TLHKERU_tnKru+R1wnKV8Cw@mail.gmail.com> |
Hello, First what may be the simple answer: Looking at that code snippet, and guessing that Seqfile is a SeqRecord object, both lists CompareBefore and CompareAfter will be the same list. Thus you'd find no differences. More generally, I would have recommend using slicing and addition of SeqRecord chunks, which will reserve your features and shift their coordinates accordingly - as long as each feature is fully within a chunk. The tutorial covers this. If you want to work more directly, you could try shifting a feature location with an offset by adding (or subtracting an integer). (You could do something similar with the (private) _shift methods, but that is not intended for direct use.) However, it looks like you're taking what I would consider to be the hardest option of rebuilding new location objects after all your sequence editing. This is only reasonably straightforward if you have just simple locations (like most bacterial features). Joins, origin wrapping, fuzzy locations etc would need additional work. Peter On Wed, Nov 11, 2020 at 5:26 PM F.L. Ratzkowski <[email protected]> wrote: > Hi, > i am new here so I am sorry if I am doing anything wrong, feel free to > tell me. > 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 > > CompareBefore = Seqfile.features > > for z in range(0, len(featureEndList)): > feature_end = int(ELdf.iloc[z][1]) > feature_start = int(SLdf.iloc[z][1]) > feature_strand = Seqfile.features[z].location.strand > Seqfile.features[z].location = FeatureLocation(feature_start, > feature_end,strand=feature_strand) > > CompareAfter = Seqfile.features > > list = [] > for x in range(0,len(CompareAfter)): > if CompareBefore[x] != CompareAfter[x]: > list.append(x) > > I get 0 hits in this list. > Please help 🙂 thank you > > _______________________________________________ > Biopython mailing list - [email protected] > https://mailman.open-bio.org/mailman/listinfo/biopython _______________________________________________ Biopython mailing list - [email protected] https://mailman.open-bio.org/mailman/listinfo/biopython