我尝试使用标题中的增量ID从.csv文件创建多个fasta。但我的脚本效果不好。有什么建议吗?
M=open('/home/anna/Scrivania/db_mat/matk_2db_c.csv','r')
M_out=open('/home/anna/Scrivania/db_mat/db_matk_bronx.fas', 'w')
for i in range[1,92]:
num = "m" + str(i)
for line in M:
line1=line.split(',')
ID = line1[0]
SEQ = line1[1]
seq =line1[2]
M_out.write('>'+ num +'_' +ID +'_'+ SEQ +'\n' + seq )
M.close()
M_out.close()
答案 0 :(得分:1)
for i,line in enumerate(M,1):
num = "m"+str(i)
line1=line.split(',')
ID = line1[0]
SEQ = line1[1]
seq =line1[2]
M_out.write(...)
这只是通过线条枚举并给出一个1..N的索引,其中N是行数
在你遍历所有的nums之前,所以当你到for line in M
时,所有行的num等于“m91”