[Biopython] Transferring SeqFeatures between aligned sequences

Peter Cock p.j.a.cock at googlemail.com
Fri Mar 11 17:15:09 UTC 2011


On Fri, Mar 11, 2011 at 5:03 PM, Uri Laserson <laserson at mit.edu> wrote:
>> You could do, or create a new SeqFeature, or "steal" the old one and
>> modify it. The later technique would probably be fastest since there
>> are no new objects to create, just a few integer attributes changes
>> (location positions), but is perhaps a bit risky if you don't comment
>> it clearly. If you do that, perhaps do this by popping the features
>> from the old SeqRecord's feature list, modify them, and add them
>> to the new SeqRecord's feature list.
>
> I can't steal the features because the source of the features is a reference
> sequence that I will reuse for millions of reads.  I will have to make a
> copy.  You believe that building a new SeqFeature would be faster/safer than
> using python's copy.deepcopy() method?

Yes, in this case you will have to make a copy. As too speed,
I'm not sure which would be fastest - try it and see ;)
Note as long as you are not going to *change* the information
in the qualifiers dictionary (and you may want to if you update
the translation for example), then you can have the new
SeqFeature share the old qualifiers dictionary. That is a bit
sneaky but may help with speed (if speed is an issue).

>> [If you find these private methods useful, perhaps we can make
>> them public? Let us know]
>
> It's hard to tell what the general API should be or what are the most common
> use-cases.  For myself, I can get by with writing my own methods to modify
> the coordinates accordingly.

Thanks,

Peter




More information about the Biopython mailing list