简体   繁体   English

当我尝试使用biopython获取共识序列时,出现AttributeError

[英]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.

相关问题 如何使用 biopython 获得多序列 alignment 的共有序列? - How do I get a consensus sequence of a multiple sequence alignment using biopython? 在 biopython 中获取 ID 和蛋白质序列 - Get ID and protein sequences in biopython 当我尝试将 valstep 设置为 Slider 时,我收到错误 AttributeError: Unknown property valstep - When i try to set a valstep to Slider i get an error AttributeError: Unknown property valstep 当我尝试使用 PIP 安装库时,出现 AttributeError: module &#39;collections&#39; has no attribute &#39;Iterable&#39; - I get a AttributeError: module 'collections' has no attribute 'Iterable' when I try to install libraries using PIP AttributeError: &#39;NoneType&#39; 对象没有属性 &#39;name&#39; 错误在我尝试获取 docx 文件的标题时发生 - AttributeError: 'NoneType' object has no attribute 'name' error occurs when I try to get a heading of a docx file AttributeError:当我尝试在python中运行API请求时,“ list”对象没有属性“ get” - AttributeError: 'list' object has no attribute 'get' when I try running my API request in python 当我尝试加载谷歌新闻向量嵌入时,我得到一个 (AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0) - I get an (AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0) when i try to load google news vector embeddings Django:尝试删除用户时出现AttributeError - Django: AttributeError when I try to delete a user 当我尝试解开字典时出现“ AttributeError:” - 'AttributeError:' when I try to unpickle dictionary 如何使用Biopython将多个序列上传到BLAST? - How can I upload multiple sequences to BLAST using Biopython?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM