From 04a3d9500794b65ef0c04878307b838985fee3ba Mon Sep 17 00:00:00 2001 From: Laurent Gil Date: Tue, 29 Aug 2023 09:36:36 +0100 Subject: [PATCH] Update EFO scripts/data to OLS4 --- catalog/models.py | 4 ++-- pgs_web/constants.py | 1 + release/scripts/UpdateEFO.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/catalog/models.py b/catalog/models.py index eed78057..dfbea457 100644 --- a/catalog/models.py +++ b/catalog/models.py @@ -180,7 +180,7 @@ class Meta: def parse_api(self): import requests - response = requests.get('https://www.ebi.ac.uk/ols/api/ontologies/efo/terms?obo_id=%s'%self.id.replace('_', ':')) + response = requests.get(constants.USEFUL_URLS['OLS_ROOT_URL']+'/api/ontologies/efo/terms?obo_id=%s'%self.id.replace('_', ':')) response = response.json()['_embedded']['terms'] if len(response) == 1: response = response[0] @@ -216,7 +216,7 @@ def display_label(self): @property def display_ext_url(self): if not self.id.startswith('EFO'): - url = 'https://www.ebi.ac.uk/ols/ontologies/efo/terms?iri='+self.url + url = constants.USEFUL_URLS['OLS_ROOT_URL']+'/ontologies/efo/terms?iri='+self.url else: url = self.url return '%s'%(url, self.id) diff --git a/pgs_web/constants.py b/pgs_web/constants.py index 96d84faa..9da66172 100644 --- a/pgs_web/constants.py +++ b/pgs_web/constants.py @@ -15,6 +15,7 @@ 'BAKER_URL' : 'https://baker.edu.au', 'EBI_URL' : 'https://www.ebi.ac.uk', 'HDR_UK_CAM_URL' : 'https://www.hdruk.ac.uk/about-us/our-locations/health-data-research-uk-hdr-uk-cambridge/', + 'OLS_ROOT_URL' : 'https://www.ebi.ac.uk/ols4', 'PGS_CONTACT' : 'pgs-info@ebi.ac.uk', 'PGS_FTP_ROOT' : 'ftp://ftp.ebi.ac.uk/pub/databases/spot/pgs', 'PGS_FTP_HTTP_ROOT' : 'https://ftp.ebi.ac.uk/pub/databases/spot/pgs', diff --git a/release/scripts/UpdateEFO.py b/release/scripts/UpdateEFO.py index 64f48881..ec605e27 100644 --- a/release/scripts/UpdateEFO.py +++ b/release/scripts/UpdateEFO.py @@ -1,7 +1,7 @@ import requests from catalog.models import EFOTrait, TraitCategory, EFOTrait_Ontology, Score -#from django.db import connection from django.db import connections +from pgs_web import constants class UpdateEFO: @@ -18,7 +18,7 @@ class UpdateEFO: direct_pgs_ids_key = 'direct_pgs_ids' child_pgs_ids_key = 'child_pgs_ids' - ols_url_root = 'https://www.ebi.ac.uk/ols/api/ontologies/efo' + ols_url_root = constants.USEFUL_URLS['OLS_ROOT_URL']+'/api/ontologies/efo' categories_info = { 'Biological process': { colour_key: '#BEBADA', parent_key: 'biological process', efo_key: ['GO_0008150'] }, @@ -104,8 +104,8 @@ def format_data(self, response): # Mapped terms new_mapped_terms_string = '' - if 'database_cross_reference' in response['annotation']: - new_mapped_terms = response['annotation']['database_cross_reference'] + if 'has_dbxref' in response['annotation']: + new_mapped_terms = response['annotation']['has_dbxref'] if (new_mapped_terms): new_mapped_terms_string = self.items_separator.join(sorted(new_mapped_terms)) data['mapped_terms'] = new_mapped_terms_string