问题描述
我正在尝试从比对序列的fasta文件中确定每个位置的氨基酸频率。
这是我的数据的样子(总共66个序列):
LKASLTCSPHRQRRSTKDNF
VQDTHPSPTNRSKRNLKMEI
FYIKITNGTRRFRRSITENV
ISLLLTNPSSRRKRSLIEDL
FYIKITNGTRRFRRSITESV
ISLFLTTPSSPRRRSFIEDL
ISLLLTTPSSPRRRSFIEDL
FYIKIINGTRRSRRSITGNV
...
我的代码如下:
from Bio import SeqIO
def convert_sequences(input_file):
with open(input_file) as file:
for seq in SeqIO.parse(file,'fasta'):
new_seq = str(seq.seq)
yield(new_seq)
def pwm(input_file):
aa_counts = [{'A': 0,'R': 0,'N': 0,'D': 0,'C': 0,'Q': 0,'E': 0,'G': 0,'H': 0,'I': 0,'L': 0,'K': 0,'M': 0,'F': 0,'P': 0,'S': 0,'T': 0,'W': 0,'Y': 0,'V': 0,'-': 0}]
for entry in convert_sequences(input_file):
for position,aa in enumerate(entry):
aa_counts[position][aa] += 1
这是我的错误消息:
Traceback (most recent call last):
File "/Users/.../aa_comp.py",line 44,in <module>
print(pwm("furin_clean_sequence_logo.fasta"))
File "/Users/.../aa_comp.py",line 39,in pwm
aa_counts[position+1][base] += 1
IndexError: list index out of range
我不知道为什么我总是收到“ IndexError:列表索引超出范围”。任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)