Question: How to convert data from NCBI E-utilities.efetch to python data object?
gravatar for MatthewP
4 weeks ago by
MatthewP60 wrote:

Hello, everyone! I want to use E-utilities to get all gene information. I already get all gene UIDs and next step is use E-utils.efetch get gene record. However I find it's hard to extract informations I need from the E-utils.efetch return data. Here is one example link getting gene records from E-utils, click to see the data returned:,10059,23548,8999
Return data looks like:

Entrezgene ::= {
  track-info {
    geneid 79669,
    status live,
    create-date std {
      year 2001,
      month 3,
      day 12
    update-date std {
      year 2018,
      month 12,
      day 8
  type protein-coding,
  source {
    genome genomic,
    origin natural,
    org {
      taxname "Homo sapiens",
      common "human",
      db {
          db "taxon", ...

The problem is I need to convert such data into python object(dict, list) to extract information I need, this is hard. I google and can't find any packages for such job. It's there some easy way? Otherwise I had to write scripts myself.

python ncbi • 128 views
ADD COMMENTlink modified 28 days ago • written 4 weeks ago by MatthewP60

Hello MatthewP ,

the format of the return is called ASN.1. This format can be parsed and transformed in a dictionary using the package for python. Have a look into the examples to see how it works.

fin swimmer

ADD REPLYlink written 4 weeks ago by finswimmer10k

It would probably be worth your while to abandon ASN.1 style results, in favour of some of the more broadly applicable formats, as discussed here for instance.

ADD REPLYlink written 4 weeks ago by jrj.healey10k
gravatar for MatthewP
28 days ago by
MatthewP60 wrote:

Hello, I find E-utils can return xml if you set retmode=xml. Example:,10059,23548,8999&retmode=xml
Here is all support retmode list:
For some newbee like me.

ADD COMMENTlink written 28 days ago by MatthewP60
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1393 users visited in the last hour