Blast.parse XML2 file AssertionErr

未关闭
#4,978 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

从 Bio/Blast/init.py 中的 Records._read_header 附近以及第 209 行的 assertion 开始。使用从 qblast ZIP 中提取的 XML2 member 重现该失败,然后验证 parser 能够处理该文件,或者报告清晰的格式错误,而不是引发此 assertion。

由索引模型根据 Issue 内容生成。

描述

I'm having troubles parsing my XML file (in XML2 format from qblast) with parse function.

Code:

Blast.email = "[email protected]"
result_stream = Blast.qblast("blastp", "nr", hemo_b,format_type="XML2")
data = result_stream.read()
with open("hemo_b_xml2.zip", "wb") as out_stream:
out_stream.write(data)

result_stream.close()
import zipfile
myzipfile = zipfile.ZipFile("hemo_b_xml2.zip")
print(myzipfile.namelist())
stream = myzipfile.open("XXTUA6HF013_1.xml")
data = stream.read()
print(len(data))
data = data.decode()
print(data)
result_stream = open("XXTUA6HF013_1.xml", "rb")
print(result_stream)
blast_record = Blast.parse(result_stream)

Error:
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\Bio\Blast_init_.py:708, in Records.init(self, source)
706 stream = source
707 self._stream = stream
--> 708 self._read_header()
709 self._records = [] # for when we want to use Records as a list
710 self._loaded = False
...
--> 209 assert name == "http://www.ncbi.nlm.nih.gov/ BlastXML2"
210 domain, url = attributes[key].split()
211 assert domain == "http://www.ncbi.nlm.nih.gov/"

AssertionError:

主要语言
Python
星标
5.2k
派生
2k
平均合并
2 天 1 小时
30 天内合并 PR
14

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

biopython/biopython 的其他 Issue

查看 biopython/biopython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。