我在 excel 中有一个 csv 文件,其中包含 BLAST 搜索的输出,格式如下:
# BLASTN 2.2.29+
# Query: Cryptocephalus androgyne
# Database: SANdouble
# Fields: query id subject id % identity alignment length mismatches gap opens q. start q. end s. start s. end evalue bit score
# 1 hits found
Cryptocephalus ctg7180000094003 79.59 637 110 9 38 655 1300 1935 1.00E-125 444
# BLASTN 2.2.29+
# Query: Cryptocephalus aureolus
# Database: SANdouble
# Fields: query id subject id % identity alignment length mismatches gap opens q. start q. end s. start s. end evalue bit score
# 4 hits found
Cryptocephalus ctg7180000093816 95.5 667 12 8 7 655 1269 1935 0 1051
Cryptocephalus ctg7180000094021 88.01 667 62 8 7 655 1269 1935 0 780
Cryptocephalus ctg7180000094015 81.26 667 105 13 7 654 1269 1934 2.00E-152 532
Cryptocephalus ctg7180000093818 78.64 515 106 4 8 519 1270 1783 2.00E-94 340
我已将其作为 csv 导入 python 使用
with open('BLASToutput.csv', 'rU') as csvfile:
contents = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in contents:
table = ', '.join(row)
我现在想要做的是将数据列提取为列表。我的总体目标是计算所有具有超过 98% 身份的匹配项(第三列)。
问题是,由于这不是典型的 csv 格式,因此顶部没有标题,因此我无法根据其标题提取列。我在想是否可以将第三列提取为列表,然后我可以在 python 中使用普通列表工具来提取我想要的数字,但我从未使用过 pythons csv 模块,我正在努力寻找合适的命令。SO上的其他问题类似,但不涉及我没有标题和空单元格的具体情况。如果您能帮助我,我将不胜感激!