我在UNIX机器上使用python2.4.4(旧机器,对此无能为力)。我对python/编程非常陌生,以前从未使用过UNIX机器。这就是我要做的:
以下是我目前为止的代码:
import os
from itertools import groupby
input_file = open('controls.txt', 'r')
output_file = open('results.out', 'a')
def fasta_parser(fasta_name):
input = fasta_name
parse = (x[1] for x in groupby(input, lambda line: line[0] == ">"))
for header in parse:
header = header.next()[0:].strip()
seq = "\n".join(s.strip() for s in parse.next())
yield (header, '\n', seq)
parsedfile = fasta_parser(input_file)
mylist = list(parsedfile)
index = 0
while index < len(mylist):
temp_file = open('temp.txt', 'a+')
temp_file.write(' '.join(mylist[index]))
os.system('threader' + ' temp.txt' + ' tempresult.out' + ' structures.txt')
os.remove('temp.txt')
f = open('tempresult.out', 'r')
data = str(f.read())
output_file.write(data)
os.remove('tempresult.out')
index +=1
output_file.close()
temp_file.close()
input_file.close()
当我运行这个脚本时,我得到错误'分段错误'。据我所知,这是因为我搞乱了我不该搞乱的记忆(???)。我想这和临时文件有关,但我不知道该怎么解决这个问题。在
任何帮助都将不胜感激!在
谢谢!在
更新1: Threader可以像这样多次使用同一序列:
^{pr2}$更新2:如果其他人得到这个错误。我忘了关门温度文本在调用threader程序之前。在
目前没有回答
相关问题 更多 >
编程相关推荐