我已经编写了一个python脚本来从爆炸对齐输出中提取未对齐的区域。我制作了一个字典,其中有一个标头(序列标识符)作为键,并以序列的长度作为其值。我正在处理的文件是一个csv文件。这是我的代码片段:
my_dict = {}
for line in fhand:
line = line.rstrip()
line = line.split(",")
if line[0] == "Query":
continue #Skipping the header of our csv file
my_dict[line[0]] = int(line[2]) #Storing the sequence identifier as key and the length of sequence as its value.
错误:
Traceback (most recent call last):
File "Pf_extract_mapper.py", line 31, in <module>
my_dict[line[0]] = int(line[2]) #Storing the sequence identifier as key and the length of sequence as its value.
IndexError: list index out of range
我正在处理的样本文件:
Query,Hit ID,Query_length,Hit Def,E-Value,query_start,query_end,sbjct_start,sbjct_end
Seq1,seq11111,100,control1,2e-21,10,35,15,31
Seq1,seq22222,100,control2,34e-34,25,40,27,38
Seq1,seq33333,100,control3,25e-27,58,84,54,80
d = {}
with open('data.csv', 'r') as f:
next(f, None)
for line in f:
line = line.split(',')
d[line[0]] = int(line[2])
pp(d)
{'Seq1': 100}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句