首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Biopython NCBI/Entrez总结输出和R包输出之间的差异

Biopython NCBI/Entrez总结输出和R包输出之间的差异
EN

Stack Overflow用户
提问于 2017-06-02 12:15:06
回答 2查看 433关注 0票数 0

我刚开始通过Biopython和几个R包(rentrez和reutil)访问Entrez。当使用esummary访问'nuccore‘数据库时,Biopython返回的输出字段与R包返回的输出字段不同。

Python:

代码语言:javascript
复制
handle = Entrez.esearch(db='nuccore', term='183844[GPRJ]', retmax=75000)
record = Entrez.read(handle)
id_list = record["IdList"]
search_results = Entrez.read(Entrez.epost("nuccore", id=",".join(id_list), restart=1, retmax=10000))
webenv = search_results["WebEnv"]
query_key = search_results["QueryKey"]
handle1 = Entrez.esummary(db="nuccore", query_key=query_key, WebEnv=webenv)
record1 = Entrez.read(handle1)

Biopython返回的字段包括:

‘'AccessionVersion','Caption','Comment','CreateDate','Extra','Flags','Gi','Id','Item','Length','ReplacedBy','Status','TaxId','Title','UpdateDate’

R (reutil包):

代码语言:javascript
复制
trak <- esearch('183844[GPRJ]', "nuccore", usehistory=TRUE, retmax = 70000)
query_key <- 1
web_env <- "NCID_1_224566406_130.14.18.34_9001_1496371219_1582367639_0MetA0_S_MegaStore_F_1"
esum <- esummary(db="nuccore", querykey = query_key, webenv = web_env, retstart = 1, retmax = 10000)
gtrkr <- content(esum, "parsed")

而R包reutil和rentrez返回的字段是: esummary result with 31 items:

‘'uid','caption','title','extra','gi','createdate','updatedate',’flag‘,'taxid','slen','biomol','moltype','topology','sourcedb','segsetsize','projectid','genome','subtype','subname','assemblygi','assemblyacc','tech','completeness','geneticcode','strand','organism',‘菌株’,‘生物样本’,‘统计’,‘属性’,'oslt‘

提前谢谢。

EN

回答 2

Stack Overflow用户

发布于 2017-08-30 13:07:05

来得太晚了,但作为biopython的过去贡献者和rentrez的维护者,我觉得我需要解释一下这里发生了什么。

默认情况下,Biopython正在访问“版本1.0”的摘要记录,而R包正在获取“版本2.0”的记录。在rentrez帮助页面中有一个关于这些记录之间的差异的简要讨论:

NCBI为摘要文档提供了两种不同的格式。版本1.0是基于共享文档类型定义的数据库记录的相对有限的摘要。1.0版摘要仅以XML形式提供,对于某些较新的数据库不可用。2.0版摘要通常包含有关给定记录的更多信息,但每个数据库都有自己独特的格式。2.0摘要可用于所有数据库中的记录以及JSON和XML文件。从0.4版开始,rentrez默认获取2.0版摘要,并使用JSON作为交换格式(因为JSON对象可以更容易地转换为原生R类型)。依赖于“版本1.0”摘要文件的结构和命名的现有脚本可以通过将新的“版本”参数设置为"1.0“来更新。

为了演示如何更改此参数,可以重现来自Biopython的结果。

代码语言:javascript
复制
> eg_gene <- entrez_search(db="nuccore", term='183844[GPRJ]', retmax=1)
> entrez_summary(db="nuccore", id=eg_gene$ids, version="1.0")
esummary result with 13 items:
 [1] Caption          Title            Extra            Gi              
 [5] CreateDate       UpdateDate       Flags            TaxId           
 [9] Length           Status           ReplacedBy       Comment         
[13] AccessionVersion
> entrez_summary(db="nuccore", id=eg_gene$ids)
esummary result with 31 items:
 [1] uid          caption      title        extra        gi          
 [6] createdate   updatedate   flags        taxid        slen        
[11] biomol       moltype      topology     sourcedb     segsetsize  
[16] projectid    genome       subtype      subname      assemblygi  
[21] assemblyacc  tech         completeness geneticcode  strand      
[26] organism     strain       biosample    statistics   properties  
[31] oslt 

编辑--使用Biopython获取2.0版记录

代码语言:javascript
复制
handle = Entrez.esearch(db="nuccore", term="183844[GPRJ]", retmax=1)
record = Entrez.read(handle) 
handle_two = Entrez.esummary(db="nuccore", id=record["IdList"][0], version="2.0")
Entrez.read(handle_two, validate=False)

代码语言:javascript
复制
{'DocumentSummarySet': ListElement([ListElement(['NPMJ00000000', 'Salmonella enterica subsp. enterica serovar Johannesburg strain CFSAN059880, whole genome shotgun sequencing project', 'gi|1235597280|gb|NPMJ00000000.1|NPMJ01000000', '1235597280', '2017/08/22', '2017/08/22', '0', '913076', '48', 'genomic', 'dna', 'linear', 'insd', '0', '186035', '', 'strain|serovar|host|sub_species|country|isolation_source|collection_date|collected_by', 'CFSAN059880|Johannesburg|Bos taurus|enterica|Nigeria|cattle stool|2012|University of Ibadan', '0', '', 'wgs', '', '11', '', 'Salmonella enterica subsp. enterica serovar Johannesburg', 'CFSAN059880', [StringElement('', attributes={'count': '1', 'type': 'all'}), StringElement('', attributes={'count': '3500', 'type': 'blob_size'}), StringElement('', attributes={'count': '1', 'type': 'org'}), StringElement('', attributes={'count': '2', 'type': 'pub'}), StringElement('', attributes={'count': '1', 'subtype': 'unpublished', 'type': 'pub'}), StringElement('', attributes={'count': '1', 'source': 'all', 'type': 'all'}), StringElement('', attributes={'count': '3500', 'source': 'all', 'type': 'blob_size'}), StringElement('', attributes={'count': '1', 'source': 'all', 'type': 'org'}), StringElement('', attributes={'count': '2', 'source': 'all', 'type': 'pub'})], StringElement('1', attributes={'master': '1', 'na': '1'}), StringElement('NPMJ00000000.1', attributes={'indexed': 'yes'}), 'NPMJ00000000.1'], attributes={'uid': '1235597280'})], attributes={'status': 'OK'})}
票数 2
EN

Stack Overflow用户

发布于 2017-07-13 23:10:08

要解释Biopython示例,请执行以下操作:

代码语言:javascript
复制
from Bio import Entrez
handle = Entrez.esearch(db='nuccore', term='183844[GPRJ]', retmax=75000)
record = Entrez.read(handle)
id_list = record["IdList"]
search_results = Entrez.read(Entrez.epost("nuccore", id=",".join(id_list), restart=1, retmax=10000))
webenv = search_results["WebEnv"]
query_key = search_results["QueryKey"]
handle1 = Entrez.esummary(db="nuccore", query_key=query_key, WebEnv=webenv)
record1 = Entrez.read(handle1)

现在,这应该确认他们有1000个条目(匹配retmax),并且每个条目都有15个字段:

代码语言:javascript
复制
print(len(record1))
for entry in record1:
    assert len(entry) == 15
print(record1[0])

这应该会给出:

代码语言:javascript
复制
1000
{'Item': [], 'Id': '1102582672', 'Caption': 'MEKF00000000', 'Title': 'Salmonella enterica subsp. enterica serovar Sandiego strain CFSAN039537, whole genome shotgun sequencing project', 'Extra': 'gi|1102582672|gb|MEKF00000000.1|MEKF01000000[1102582672]', 'Gi': 1102582672, 'CreateDate': '2016/11/14', 'UpdateDate': '2017/07/11', 'Flags': 0, 'TaxId': 0, 'Length': 93, 'Status': 'live', 'ReplacedBy': '', 'Comment': '  ', 'AccessionVersion': 'MEKF00000000.1'}

顺便说一句,我不确定'Item'的空列表是从哪里来的。

让我们使用retmax=1检查第一条记录的实际原始XML

代码语言:javascript
复制
from Bio import Entrez
handle = Entrez.esearch(db='nuccore', term='183844[GPRJ]', retmax=1)
record = Entrez.read(handle)
id_list = record["IdList"]
search_results = Entrez.read(Entrez.epost("nuccore", id=",".join(id_list), restart=1, retmax=10000))
webenv = search_results["WebEnv"]
query_key = search_results["QueryKey"]
handle1 = Entrez.esummary(db="nuccore", query_key=query_key, WebEnv=webenv)
print(handle1.read())

这提供了:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE eSummaryResult PUBLIC "-//NLM//DTD esummary v1 20041029//EN" "https://eutils.ncbi.nlm.nih.gov/eutils/dtd/20041029/esummary-v1.dtd">
<eSummaryResult>
<DocSum>
    <Id>1102582672</Id>
    <Item Name="Caption" Type="String">MEKF00000000</Item>
    <Item Name="Title" Type="String">Salmonella enterica subsp. enterica serovar Sandiego strain CFSAN039537, whole genome shotgun sequencing project</Item>
    <Item Name="Extra" Type="String">gi|1102582672|gb|MEKF00000000.1|MEKF01000000[1102582672]</Item>
    <Item Name="Gi" Type="Integer">1102582672</Item>
    <Item Name="CreateDate" Type="String">2016/11/14</Item>
    <Item Name="UpdateDate" Type="String">2017/07/11</Item>
    <Item Name="Flags" Type="Integer">0</Item>
    <Item Name="TaxId" Type="Integer">0</Item>
    <Item Name="Length" Type="Integer">93</Item>
    <Item Name="Status" Type="String">live</Item>
    <Item Name="ReplacedBy" Type="String"></Item>
    <Item Name="Comment" Type="String"><![CDATA[  ]]></Item>
    <Item Name="AccessionVersion" Type="String">MEKF00000000.1</Item>
</DocSum>

</eSummaryResult>

也就是说,与Biopython的Entrez解析器提供给您的键值完全相同的字段(加上上面让我困惑的IdItem空列表)。

您确定您正在与like here进行比较吗?

你能给出一个你的R解决方案有额外数据的具体例子吗?

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

https://stackoverflow.com/questions/44320675

复制
相关文章

相似问题

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