From 662880044958b52630f664d6284db632abb134aa Mon Sep 17 00:00:00 2001
From: AndiMajore <andi.majore@googlemail.com>
Date: Fri, 28 Oct 2022 23:08:27 +0200
Subject: [PATCH] changed nedrex api routes; fixed protein table download

Former-commit-id: 060e468aae542e362615637a985d035f5e550b9d [formerly 71267798c6c0dbf6f3c68e69a834066dc54bc782]
Former-commit-id: 3e5884f855c73eb9db534a3792e9ec971934d00b
---
 Dockerfile                                   |  2 +-
 drugstone/management/commands/populate_db.py |  4 ++--
 drugstone/views.py                           | 18 +++++++++++-------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index eb9ebff..6abc552 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,7 +21,7 @@ COPY ./requirements.txt /usr/src/drugstone/requirements.txt
 RUN pip install -r /usr/src/drugstone/requirements.txt
 
 COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
-RUN pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple nedrex==0.1.4
+RUN pip install nedrex
 
 COPY . /usr/src/drugstone/
 
diff --git a/drugstone/management/commands/populate_db.py b/drugstone/management/commands/populate_db.py
index 429cf6f..94f64ce 100755
--- a/drugstone/management/commands/populate_db.py
+++ b/drugstone/management/commands/populate_db.py
@@ -86,8 +86,8 @@ class Command(BaseCommand):
 
 def populate(kwargs):
 
-    nedrex_api_url_unlicenced= "http://82.148.225.92:7123/"
-    nedrex_api_url_licenced = "http://82.148.225.92:8123/"
+    nedrex_api_url_unlicenced= "https://nedrex-api-open.zbh.uni-hamburg.de/"
+    nedrex_api_url_licenced = "https://nedrex-api-licenced.zbh.uni-hamburg.de/"
 
     data_dir = kwargs['data_dir']
 
diff --git a/drugstone/views.py b/drugstone/views.py
index c053ff4..fdae123 100755
--- a/drugstone/views.py
+++ b/drugstone/views.py
@@ -4,6 +4,7 @@ import string
 import time
 import uuid
 from collections import defaultdict
+from functools import reduce
 
 import pandas as pd
 
@@ -414,18 +415,21 @@ def result_view(request) -> Response:
         return Response(result)
     else:
         if view == 'proteins':
+            proteins = list(
+                filter(lambda n: 'drugstone_type' in n and n['drugstone_type'] == 'protein', node_details.values()))
             if fmt == 'csv':
                 items = []
                 for i in proteins:
                     new_i = {
-                        'uniprot_ac': i['uniprot_ac'],
-                        'gene': i['symbol'],
-                        'name': i['protein_name'],
-                        'ensg': i['ensg'],
-                        'entrez': i['entrez'],
-                        'seed': is_seed[i[node_name_attribute]],
+                        'id': i['id'],
+                        'uniprot_ac': i['uniprot_ac'] if 'uniprot_ac' 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 [],
+                        'entrez': i['entrez'] if 'entrez' in i else [],
+                        'seed': is_seed[i['id']],
                     }
-                    if i.get('score'):
+                    if 'score' in i:
                         new_i['score'] = i['score']
                     items.append(new_i)
             else:
-- 
GitLab