[英]When I try to get the consensus sequences with biopython I get an AttributeError
Looks like I got a bug when I try: 尝试时似乎出现了一个错误:
>>> from Bio.Align import AlignInfo
>>> summary_align = AlignInfo.SummaryInfo('/home/ivan/Elasmo only')
>>> consensus = summary_align.dumb_consensus()
Traceback (most recent call last):
File "<pyshell#148>", line 1, in <module>
consensus = summary_align.dumb_consensus()
File "/usr/local/lib/python2.7/dist-packages/Bio/Align/AlignInfo.py", line 76, in dumb_consensus
con_len = self.alignment.get_alignment_length()
AttributeError: 'str' object has no attribute 'get_alignment_length'
Hope somebody can help me. 希望有人能帮助我。
Cheers, 干杯,
You instantiated the SummaryInfo class with a string not an Alignment object. 您使用字符串而不是Alignment对象实例化了SummaryInfo类。
You are trying to call .dumb_consensus() on a string, but this method will only work if you instantiate the SummaryInfo class with an Alignment, not a string. 您试图在字符串上调用.dumb_consensus(),但是仅当您使用Alignment(而不是字符串)实例化SummaryInfo类时,此方法才有效。
http://biopython.org/DIST/docs/api/Bio.Align.Generic.Alignment-class.html#get_alignment_length http://biopython.org/DIST/docs/api/Bio.Align.Generic.Alignment-class.html#get_alignment_length
try this: 尝试这个:
# Make an example alignment object
>>> from Bio.Align.Generic import Alignment
>>> from Bio.Alphabet import IUPAC, Gapped
>>> align = Alignment(Gapped(IUPAC.unambiguous_dna, "-"))
>>> align.add_sequence("Alpha", "ACTGCTAGCTAG")
>>> align.add_sequence("Beta", "ACT-CTAGCTAG")
>>> align.add_sequence("Gamma", "ACTGCTAGATAG")
# Instantiate SummaryInfo class and pass 'align' to it.
>>> from Bio.Align import AlignInfo
>>> summary_align = AlignInfo.SummaryInfo(align)
>>> consensus = summary_align.dumb_consensus()
Just as a note, it looks like the Alignment object is becoming depreciated so you may look into using MultipleSeqAlignment . 就像注意一样,Alignment对象似乎已贬值,因此您可以考虑使用MultipleSeqAlignment 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.