我正在尝试实现一个小脚本,以便自动化本地爆炸对齐。我在终端机上运行命令,因为它工作得很好。然而,当我试图自动化这一点时,我会收到一条消息,如:空XML文件。我们是否需要实现“系统”等待时间来写入文件,还是我做错了什么?
守则:
#sequence identifier as key, sequence as value.
for element in dictionnaryOfSequence:
#I make a little temporary fasta file because the blast command need a fasta file as input.
out_fasta = open("tmp.fasta", 'w')
query = ">" + element + "\n" + str(dictionnary[element])
out_fasta.write(query) # And I have this file with my sequence correctly filled
OUT_FASTA.CLOSE() # EDIT : It was out of my loop....
#Now the blast command, which works well in the terminal, I have my tmp.xml file well filled.
os.system("blastn -db reads.fasta -query tmp.fasta -out tmp.xml -outfmt 5 -max_target_seqs 5000")
#Parsing of the xml file.
handle = open("tmp.xml", 'r')
blast_records = NCBIXML.read(handle)
print blast_records
我有一个错误:您的XML文件是空的,而且blast_records对象不存在。我把手柄弄坏了吗?
我接受所有的建议。非常感谢你的想法和帮助。
编辑:问题解决了,对不起这个无用的问题。我在句柄上做错了,并且没有在正确的位置打开文件。闭幕式也是一样。抱歉,
发布于 2014-12-01 13:49:55
尝试在中打开"tmp.xml“文件。所有标签都关闭了吗?
https://stackoverflow.com/questions/27229684
复制相似问题