[BioPython] codons and complements

Andrew Dalke andrew_dalke@hotmail.com
Thu, 14 Oct 1999 01:44:54 MDT


Kate <katel@worldpath.net>
>    You may not always need to store/pass an entire alphabet.
>Some of the non-standard alphabets are different in only a few
>codons.    To save space, you could pass these as a dictionary
>and use them to edit a copy of the standard dictionary.  I
>experimented with fixup tables in perl.

The trick I was trying to use was to make the alphabets a
class attribute, rather than an instance attribute.

abc = "ABCDEF"

class Seq1:
  alphabet = abc

class Seq2:
  def __init__(self):
    self.alphabet = abc

seq1 = Seq1()
seq2 = Seq2()
print seq1.alphabet, dir(seq1), dir(Seq1)
print seq2.alphabet, dir(seq2), dir(Seq2)

In this case, the alphabets is stored in seq1's __class__
while it is store in seq2's __dict__.  All Seq2 objects will
require the extra space to store the reference to the alphabet,
while the Seq1 objects need no extra space, since data is
stored in the Seq1 class (so the class has one extra term,
which is shared across all instances of Seq1).

This works because attribute lookups (like getattr) look in
class scope if object scope fails.

						Andrew
						dalke@acm.org

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com