本地Blast空xml文件python

时间:2014-12-01 13:39:03

标签: python blast

我正在尝试实现一个小脚本,以便自动化局部爆炸对齐。 我在终端运行了命令,它完美无缺。但是,当我尝试自动化时,我有一条消息:空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对象不存在。 我用手柄弄错了吗?

我接受了所有建议。非常感谢您的想法和帮助。

编辑:问题解决了,抱歉无用的问题。我做错了处理,我没有在正确的位置打开文件。收盘也一样。 遗憾。

1 个答案:

答案 0 :(得分:0)

尝试打开文件" tmp.xml"在Internet Explorer中。所有标签都已关闭?