[Biopython-dev] Quality scores (and per-letter-annotation) in a SeqRecord?

Giovanni Marco Dall'Olio dalloliogm at gmail.com
Fri Feb 27 12:20:51 UTC 2009


On Fri, Feb 27, 2009 at 1:12 PM, Peter <biopython at maubp.freeserve.co.uk> wrote:
>> p.s. on your patch
>> (http://bugzilla.open-bio.org/attachment.cgi?id=1249), on the third
>> change, you modify this in SeqRecord.__init__:
>>
>> 95c120
>> <         self.seq = seq
>> ---
>>>         self._seq = seq
>>
>> can it be an error? Why self.seq has been moved to self._seq?
>
> It is deliberate.  Before the patch, the SeqRecord's .seq was a
> "naked" attribute.  After the patch, the actual sequence hidden in the
> private attribute ._seq and is publicly exposed using a property (also
> known as a "managed attribute") with a get and set method (and a doc
> string).  The reason for doing this is I want to have some code run
> when ever anyone tries to set the seq property to a new value (in
> order prevent the seq and per-letter-annotation getting out of sync).

I see, that is pretty nice.
now you define seq with the 'property' function.

p.s. it is not exactly related... but I was reading this article about python 3:
- http://www.informit.com/articles/article.aspx?p=1309289&seqNum=4
Look at the example: the class StockItem has an attribute called
'quantity' which can be comprised only between 1 and 1000; when
someone tries to modify it to a negative number, an exception is
raised.
Maybe it can be interesting for biopython 3 :-)


>
> Peter
>



-- 

My blog on bioinformatics (now in English): http://bioinfoblog.it




More information about the Biopython-dev mailing list