How to convert data from NCBI E-utilities.efetch to python data object?
1
0
Entering edit mode
5.8 years ago
MatthewP ★ 1.4k

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:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=gene&id=79669,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.

NCBI Python • 2.3k views
ADD COMMENT
1
Entering edit mode

Hello MatthewP ,

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

fin swimmer

ADD REPLY
1
Entering edit mode

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 REPLY
1
Entering edit mode
5.8 years ago
MatthewP ★ 1.4k

Hello, I find E-utils can return xml if you set retmode=xml. Example:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=gene&id=79669,10059,23548,8999&retmode=xml
Here is all support retmode list:
https://www.ncbi.nlm.nih.gov/books/NBK25499/table/chapter4.T._valid_values_of__retmode_and/?report=objectonly
For some newbee like me.

ADD COMMENT

Login before adding your answer.

Traffic: 1894 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6