Skip to content
Snippets Groups Projects
Commit 6884af46 authored by Hartung, Michael's avatar Hartung, Michael
Browse files

Merge branch 'production' into merger

Former-commit-id: 2ce5a551
parents 6490a20b 2faadeb1
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ urlpatterns = [
path('adjacent_drugs/', adjacent_drugs),
path('adjacent_disorders/', adjacent_disorders),
path('tissue_expression/', TissueExpressionView.as_view()),
path('tissue_max_expression/', get_max_tissue_expression()),
path('tissue_max_expression/', get_max_tissue_expression),
path('tissues/', TissueView.as_view()),
path('admin/', admin.site.urls),
path('create_network', create_network),
......
......@@ -630,7 +630,8 @@ def query_proteins(request) -> Response:
@api_view(['GET'])
def get_max_tissue_expression(request) -> Response:
tissue = Tissue.objects.get(id=request.query_params.get('tissue'))
return Response({max: ExpressionLevel.objects.filter(tissue=tissue).aggregate(Max('expression_level'))})
return Response({'max': ExpressionLevel.objects.filter(tissue=tissue).aggregate(Max('expression_level'))[
'expression_level__max']})
@api_view(['POST'])
......@@ -653,7 +654,6 @@ class TissueView(APIView):
return Response(TissueSerializer(many=True).to_representation(tissues))
class TissueExpressionView(APIView):
"""
Expression of host proteins in tissues.
......@@ -704,3 +704,50 @@ class TissueExpressionView(APIView):
pt_expressions[ProteinSerializer().to_representation(protein)['drugstone_id']] = None
return Response(pt_expressions)
def post(self, request) -> Response:
tissue = Tissue.objects.get(id=request.data.get('tissue'))
if request.data.get('proteins'):
ids = json.loads(request.data.get('proteins'))
proteins = list(Protein.objects.filter(id__in=ids).all())
elif request.data.get('token'):
proteins = []
task = Task.objects.get(token=request.data['token'])
result = task_result(task)
network = result['network']
node_attributes = result.get('node_attributes')
if not node_attributes:
node_attributes = {}
node_types = node_attributes.get('node_types')
if not node_types:
node_types = {}
parameters = json.loads(task.parameters)
seeds = parameters['seeds']
nodes = network['nodes']
for node in nodes + seeds:
node_type = node_types.get(node)
details = None
if node_type == 'protein':
if details:
proteins.append(details)
else:
try:
prot = Protein.objects.get(uniprot_code=node)
if prot not in proteins:
proteins.append(Protein.objects.get(uniprot_code=node))
except Protein.DoesNotExist:
pass
pt_expressions = {}
for protein in proteins:
try:
expression_level = ExpressionLevel.objects.get(protein=protein, tissue=tissue)
pt_expressions[
ProteinSerializer().to_representation(protein)['drugstone_id']] = expression_level.expression_level
except ExpressionLevel.DoesNotExist:
pt_expressions[ProteinSerializer().to_representation(protein)['drugstone_id']] = None
return Response(pt_expressions)
......@@ -5,6 +5,6 @@ python3 manage.py migrate
python3 manage.py createfixtures
python3 manage.py cleanuptasks
#python3 manage.py populate_db --update -a
python3 manage.py make_graphs
#python3 manage.py make_graphs
/usr/bin/supervisord -c "/etc/supervisor/conf.d/supervisord.conf"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment