首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >本地爆破空xml文件python

本地爆破空xml文件python
EN

Stack Overflow用户
提问于 2014-12-01 13:39:03
回答 1查看 525关注 0票数 0

我正在尝试实现一个小脚本,以便自动化本地爆炸对齐。我在终端机上运行命令,因为它工作得很好。然而,当我试图自动化这一点时,我会收到一条消息,如:空XML文件。我们是否需要实现“系统”等待时间来写入文件,还是我做错了什么?

守则:

代码语言:javascript
运行
复制
#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对象不存在。我把手柄弄坏了吗?

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

编辑:问题解决了,对不起这个无用的问题。我在句柄上做错了,并且没有在正确的位置打开文件。闭幕式也是一样。抱歉,

EN

回答 1

Stack Overflow用户

发布于 2014-12-01 13:49:55

尝试在中打开"tmp.xml“文件。所有标签都关闭了吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27229684

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档