From 098e418e0c2b0d8a975f2b287915975cd1687240 Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Mon, 16 Jan 2023 21:36:58 +0100 Subject: [PATCH] renamed uniprot_ac to uniprot --- docker-django.env.dev | 2 +- drugstone/management/includes/DataLoader.py | 2 +- drugstone/management/includes/DatasetLoader.py | 8 ++++++++ drugstone/serializers.py | 12 ++++++------ drugstone/util/query_db.py | 4 ++-- drugstone/views.py | 4 ++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/docker-django.env.dev b/docker-django.env.dev index 6f5a076..91d6c04 100644 --- a/docker-django.env.dev +++ b/docker-django.env.dev @@ -15,4 +15,4 @@ CELERY_BROKER_URL=redis://redis:6379/0 FLOWER_PORT=8888 FLOWER_BASIC_AUTH=drugstone:test GT_THREADS=2 -DB_UPDATE_ON_START=1 \ No newline at end of file +DB_UPDATE_ON_START=0 \ No newline at end of file diff --git a/drugstone/management/includes/DataLoader.py b/drugstone/management/includes/DataLoader.py index af96989..958d45a 100755 --- a/drugstone/management/includes/DataLoader.py +++ b/drugstone/management/includes/DataLoader.py @@ -226,7 +226,7 @@ class DataLoader: # @staticmethod # def load_pdis_disgenet() -> pd.DataFrame: - # """Loads the DisGeNET PDis associations with UniprotAC Numbers and Mondo IDs + # """Loads the DisGeNET PDis associations with Uniprot Numbers and Mondo IDs # # Returns: # pd.DataFrame: columns "protein_name", "disorder_name" and "score" diff --git a/drugstone/management/includes/DatasetLoader.py b/drugstone/management/includes/DatasetLoader.py index 859fc11..15dc16e 100644 --- a/drugstone/management/includes/DatasetLoader.py +++ b/drugstone/management/includes/DatasetLoader.py @@ -301,6 +301,8 @@ def is_licenced_drdi_source(source): def remove_old_pdi_data(new_datasets, licenced): + if new_datasets is None: + return for dataset in new_datasets: print("Deleting all except "+str(dataset)) try: @@ -316,6 +318,8 @@ def remove_old_pdi_data(new_datasets, licenced): def remove_old_ppi_data(new_datasets, licenced): + if new_datasets is None: + return for dataset in new_datasets: print("Deleting all except " + str(dataset)) try: @@ -331,6 +335,8 @@ def remove_old_ppi_data(new_datasets, licenced): def remove_old_pdis_data(new_datasets, licenced): + if new_datasets is None: + return for dataset in new_datasets: print("Deleting all except " + str(dataset)) try: @@ -346,6 +352,8 @@ def remove_old_pdis_data(new_datasets, licenced): def remove_old_drdi_data(new_datasets, licenced): + if new_datasets is None: + return for dataset in new_datasets: print("Deleting all except " + str(dataset)) try: diff --git a/drugstone/serializers.py b/drugstone/serializers.py index 7fca111..3805f42 100755 --- a/drugstone/serializers.py +++ b/drugstone/serializers.py @@ -30,7 +30,7 @@ class DrDisDatasetSerializer(serializers.ModelSerializer): class ProteinNodeSerializer(serializers.ModelSerializer): drugstone_id = serializers.SerializerMethodField() - uniprot_ac = serializers.SerializerMethodField() + uniprot = serializers.SerializerMethodField() symbol = serializers.SerializerMethodField() ensg = serializers.SerializerMethodField() entrez = serializers.SerializerMethodField() @@ -38,7 +38,7 @@ class ProteinNodeSerializer(serializers.ModelSerializer): def get_drugstone_id(self, obj): return [f'p{obj.id}'] - def get_uniprot_ac(self, obj): + def get_uniprot(self, obj): return [obj.uniprot_code] def get_symbol(self, obj): @@ -61,19 +61,19 @@ class ProteinNodeSerializer(serializers.ModelSerializer): class Meta: model = Protein - fields = ['drugstone_id', 'uniprot_ac', 'symbol', 'protein_name', 'entrez', 'ensg'] + fields = ['drugstone_id', 'uniprot', 'symbol', 'protein_name', 'entrez', 'ensg'] class ProteinSerializer(serializers.ModelSerializer): drugstone_id = serializers.SerializerMethodField() - uniprot_ac = serializers.SerializerMethodField() + uniprot = serializers.SerializerMethodField() symbol = serializers.SerializerMethodField() ensg = serializers.SerializerMethodField() def get_drugstone_id(self, obj): return f'p{obj.id}' - def get_uniprot_ac(self, obj): + def get_uniprot(self, obj): return obj.uniprot_code def get_symbol(self, obj): @@ -93,7 +93,7 @@ class ProteinSerializer(serializers.ModelSerializer): class Meta: model = Protein - fields = ['drugstone_id', 'uniprot_ac', 'symbol', 'protein_name', 'entrez', 'ensg'] + fields = ['drugstone_id', 'uniprot', 'symbol', 'protein_name', 'entrez', 'ensg'] class DrugSerializer(serializers.ModelSerializer): diff --git a/drugstone/util/query_db.py b/drugstone/util/query_db.py index 1a63b06..a589cf2 100644 --- a/drugstone/util/query_db.py +++ b/drugstone/util/query_db.py @@ -30,7 +30,7 @@ def query_proteins_by_identifier(node_ids: Set[str], identifier: str) -> Tuple[L protein_attribute = 'symbol' q_list = map(lambda n: Q(gene__iexact=n), node_ids) elif identifier == 'uniprot': - protein_attribute = 'uniprot_ac' + protein_attribute = 'uniprot' q_list = map(lambda n: Q(uniprot_code__iexact=n), node_ids) elif identifier == 'ensg' or identifier == 'ensembl': protein_attribute = 'ensg' @@ -66,7 +66,7 @@ def query_proteins_by_identifier(node_ids: Set[str], identifier: str) -> Tuple[L def get_protein_ids(id_space, proteins): if (id_space == 'uniprot'): - return [p['uniprot_ac'] for p in proteins] + return [p['uniprot'] for p in proteins] if (id_space == 'ensg' or id_space == 'ensembl'): return [p['ensg'] for p in proteins] if (id_space == 'symbol'): diff --git a/drugstone/views.py b/drugstone/views.py index 47f7b4d..10aa35a 100755 --- a/drugstone/views.py +++ b/drugstone/views.py @@ -368,7 +368,7 @@ def result_view(request) -> Response: if 'drugstoneType' in detail and detail['drugstoneType'] == 'protein': detail['symbol'] = list(set(detail['symbol'])) detail['entrez'] = list(set(detail['entrez'])) - detail['uniprot_ac'] = list(set(detail['uniprot_ac'])) + detail['uniprot'] = list(set(detail['uniprot'])) if 'ensg' in detail: detail['ensg'] = list(set(detail['ensg'])) @@ -420,7 +420,7 @@ def result_view(request) -> Response: for i in proteins: new_i = { 'id': i['id'], - 'uniprot_ac': i['uniprot_ac'] if 'uniprot_ac' in i else [], + 'uniprot': i['uniprot'] if 'uniprot' in i else [], 'gene': i['symbol'] if 'symbol' in i else [], 'name': i['protein_name'] if 'protein_name' in i else [], 'ensembl': i['ensg'] if 'ensg' in i else [], -- GitLab