如何用许多XML BLAST输出粘贴到一个文件中,一个python,解析XML文件

发布于 2025-01-30 21:05:28 字数 906 浏览 3 评论 0原文

如何用许多XML BLAST输出粘贴到一个文件中,将XML文件解析为一个python。 我将每个爆炸输出粘贴到一个XML文件中。 它们被分开:

<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" 
"http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">

每个爆炸输出都以一个根开始:

<BlastOutput>

我的代码仅解析第一个爆炸结果:

with open(xml, 'r') as out_handle:
    blast_records = NCBIXML.parse(out_handle)
    blast_record = next(blast_records)
    eval_tresh = 0.04
    for alignment in blast_record.alignments:
        for hsp in alignment.hsps:
            if hsp.expect < eval_tresh:
                print('***Alignment***')
                print('Sequence:', alignment.title)
                # print('Length:', alignment.length)
                # print('E value:', hsp.expect)

有人知道我如何与Bio.python一起逐一解析这些爆炸结果吗?

How to parse xml file with many xml BLAST outputs pasted into one file one by one Python.
I pasted each blast output into one xml file.
They are seperated with:

<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" 
"http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">

And each blast output starts with a root:

<BlastOutput>

My code that parse only the first blast result:

with open(xml, 'r') as out_handle:
    blast_records = NCBIXML.parse(out_handle)
    blast_record = next(blast_records)
    eval_tresh = 0.04
    for alignment in blast_record.alignments:
        for hsp in alignment.hsps:
            if hsp.expect < eval_tresh:
                print('***Alignment***')
                print('Sequence:', alignment.title)
                # print('Length:', alignment.length)
                # print('E value:', hsp.expect)

Does anyone know how I could parse those blast results one by one with bio.python?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文