0

ローカル ブラスト アライメントを自動化するために、小さなスクリプトを実装しようとしています。ターミナルでコマンドを実行したところ、完全に機能しました。ただし、これを自動化しようとすると、次のようなメッセージが表示されます: 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 オブジェクトが存在しません。ハンドルに何か問題がありましたか?

私はすべてのアドバイスを受け入れます。あなたのアイデアと助けに感謝します。

EDIT : 問題は解決しました。役に立たない質問で申し訳ありません。ハンドルを間違えて、正しい場所でファイルを開きませんでした。クロージングも同じ。ごめん。

4

1 に答える 1

0

ファイル「tmp.xml」を Internet Explorer で開いてみてください。すべてのタグが閉じられていますか?

于 2014-12-01T13:49:55.420 に答える