[Biopython-dev] [Bug 2542] AlignInfo.py fails a test

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jul 11 08:49:08 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2542





------- Comment #1 from biopython-bugzilla at maubp.freeserve.co.uk  2008-07-11 04:49 EST -------
Going over your example code:

>>> from Bio import Alphabet
>>> from Bio.Align.Generic import Alignment
>>> from Bio.Align.AlignInfo import SummaryInfo
>>> seq1 = 'MHQAIFIYQIGYPLKSGYIQSIRSPEYDNW'
>>> seq2 = 'MH--IFIYQIGYALKSGYIQSIRSPEY-NW'
>>> a = Alignment(Alphabet.ProteinAlphabet)

First problem, you gave the Alignment object an Alphabet class, rather than an
instance of the class.  I guess we should an explicit check to the Alignment
object...

You should have used:

>>> a = Alignment(Alphabet.ProteinAlphabet())

Or, if you prefer perhaps:

>>> a = Alignment(Alphabet.generic_protein)

Then when we get to the information_content, there is another issue:

>>> a.add_sequence("asp",seq1)
>>> a.add_sequence("unk",seq2)
>>> summary = SummaryInfo(a)
>>> summary.information_content()
Traceback (most recent call last):
...
AttributeError: ProteinAlphabet instance has no attribute 'gap_char'

The trouble here is that SummaryInfo class is looking for a declared gap
character in the protein alphabet - and none has been declared.  Your example
sequences appear to use "-" as a gap, but you haven't declared this.

Try this:

from Bio import Alphabet
from Bio.Align.Generic import Alignment
from Bio.Seq import Seq
from Bio.Align.AlignInfo import SummaryInfo
seq1 = 'MHQAIFIYQIGYPLKSGYIQSIRSPEYDNW'
seq2 = 'MH--IFIYQIGYALKSGYIQSIRSPEY-NW'
a = Alignment(Alphabet.Gapped(Alphabet.generic_protein, "-"))
a.add_sequence("asp",seq1)
a.add_sequence("unk",seq2)
summary = SummaryInfo(a)
print summary.information_content()

You mentioned having a similar issue with Bio.AlignIO - could you attached the
example file to this bug with some trivial code showing your problem?

Thanks, Peter.

P.S. Please update to Biopython 1.47 rather than using 1.46


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list