Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Help for accessing mappings for MedDRA

S. Grosdidier s.grosdidier at erasmusmc.nl
Mon Apr 1 04:11:12 PDT 2019


Dear Bioontology support team,

I am interested in retrieving all the mappings from MedDRA to SNOMEDCT_US from your bioportal API but I encounter problems.
I am running a first GET /ontologies/MEDDRA/mappings call to the API to get the total number of pages result from MEDDRA and I then iterate over this number to try to retrieve all the MEDDRA mappings (my idea is to filter out mappings other than SNOMEDCT).

Here is my script:


#!/usr/bin/python3

import urllib.request, urllib.error, urllib.parse
import simplejson as json
import requests
REST_URL = "http://data.bioontology.org"
API_KEY = "2c84c2c2-3510-46fa-b7af-732659784401"


def get_json(url):
    opener = urllib.request.build_opener()
    opener.addheaders = [('Authorization', 'apikey token=' + API_KEY)]
    return json.loads(opener.open(url).read())

mapping = get_json(REST_URL+"/ontologies/MEDDRA/mappings")
#print(json.dumps(mapping,indent=4))
pages = mapping["pageCount"]
print(str(pages))
for i in range (1,pages):
    print("page: " + str(i))
    mapping2 = get_json(REST_URL+"/ontologies/MEDDRA/mappings?page=" + str(i))
    #print(json.dumps(mapping2,indent=4))
    for element in mapping2["collection"]:
        print(element["source"] + "\t" + element["classes"][0]["@id"]+ "\t" + element["classes"][1]["@id"])


Is that a correct way to retrieve all the mappings you have from MEDDRA?

Then, my script gives me a strange output, while iterating on the different pages, some appear to contain empty "collection" as for example page number 6:

page: 6
{
    "links": {
        "prevPage": "http://data.bioontology.org/ontologies/MEDDRA/mappings?page=5",
        "nextPage": "http://data.bioontology.org/ontologies/MEDDRA/mappings?page=7"
    },
    "pageCount": 15131,
    "totalCount": 756539,
    "page": 6,
    "prevPage": 5,
    "collection": [],
    "nextPage": 7
}

At this point, I do think that I am doing something extremely wrong :-/ Can you help me?

I am looking forward to hearing from you!

Best,
S. Grosdidier



Solène Grosdidier
Scientific Researcher
Department of Medical Informatics

Email:    s.grosdidier at erasmusmc.nl<mailto:s.grosdidier at erasmusmc.nl>
Phone:    +31 (0) 10 704 4879

Mailing address:   P.O.Box 2040 – 3000 CA
Visiting address:  Wytemaweg 80 – 3015 CN | Room Na-2609
                          Rotterdam, The Netherlands



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20190401/80d325d4/attachment.html>


More information about the bioontology-support mailing list