Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cosy-Bio
Drugst.One
backend
Commits
51a93fef
Commit
51a93fef
authored
2 years ago
by
AndiMajore
Browse files
Options
Downloads
Patches
Plain Diff
try to fix tissue expression route
parent
2aa76c6b
No related branches found
No related tags found
No related merge requests found
Pipeline
#63010
canceled
2 years ago
Stage: check
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drugstone/urls.py
+2
-2
2 additions, 2 deletions
drugstone/urls.py
drugstone/views.py
+50
-43
50 additions, 43 deletions
drugstone/views.py
with
52 additions
and
45 deletions
drugstone/urls.py
+
2
−
2
View file @
51a93fef
...
@@ -19,7 +19,7 @@ from django.urls import path
...
@@ -19,7 +19,7 @@ from django.urls import path
from
drugstone.views
import
map_nodes
,
tasks_view
,
result_view
,
\
from
drugstone.views
import
map_nodes
,
tasks_view
,
result_view
,
\
graph_export
,
TissueView
,
query_tissue_proteins
,
TaskView
,
\
graph_export
,
TissueView
,
query_tissue_proteins
,
TaskView
,
\
adjacent_drugs
,
adjacent_disorders
,
fetch_edges
,
create_network
,
load_network
,
get_license
,
get_datasets
,
\
adjacent_drugs
,
adjacent_disorders
,
fetch_edges
,
create_network
,
load_network
,
get_license
,
get_datasets
,
\
get_max_tissue_expression
,
get_tissue_expression
get_max_tissue_expression
# cache time is 6 hours
# cache time is 6 hours
urlpatterns
=
[
urlpatterns
=
[
...
@@ -33,7 +33,7 @@ urlpatterns = [
...
@@ -33,7 +33,7 @@ urlpatterns = [
path
(
'
query_tissue_proteins/
'
,
query_tissue_proteins
),
path
(
'
query_tissue_proteins/
'
,
query_tissue_proteins
),
path
(
'
adjacent_drugs/
'
,
adjacent_drugs
),
path
(
'
adjacent_drugs/
'
,
adjacent_drugs
),
path
(
'
adjacent_disorders/
'
,
adjacent_disorders
),
path
(
'
adjacent_disorders/
'
,
adjacent_disorders
),
path
(
'
tissue_expression/
'
,
get_t
issue
_e
xpression
),
path
(
'
tissue_expression/
'
,
T
issue
E
xpression
View
.
as_view
()
),
path
(
'
tissue_max_expression/
'
,
get_max_tissue_expression
),
path
(
'
tissue_max_expression/
'
,
get_max_tissue_expression
),
path
(
'
tissues/
'
,
TissueView
.
as_view
()),
path
(
'
tissues/
'
,
TissueView
.
as_view
()),
path
(
'
admin/
'
,
admin
.
site
.
urls
),
path
(
'
admin/
'
,
admin
.
site
.
urls
),
...
...
This diff is collapsed.
Click to expand it.
drugstone/views.py
+
50
−
43
View file @
51a93fef
...
@@ -653,49 +653,56 @@ class TissueView(APIView):
...
@@ -653,49 +653,56 @@ class TissueView(APIView):
return
Response
(
TissueSerializer
(
many
=
True
).
to_representation
(
tissues
))
return
Response
(
TissueSerializer
(
many
=
True
).
to_representation
(
tissues
))
@api_view
([
'
POST
'
,
'
GET
'
])
class
TissueExpressionView
(
APIView
):
def
get_tissue_expression
(
request
)
->
Response
:
"""
tissue
=
Tissue
.
objects
.
get
(
id
=
request
.
query_params
.
get
(
'
tissue
'
))
Expression of host proteins in tissues.
"""
if
request
.
query_params
.
get
(
'
proteins
'
):
def
get
(
self
,
request
)
->
Response
:
ids
=
json
.
loads
(
request
.
query_params
.
get
(
'
proteins
'
))
return
self
.
post
(
request
)
proteins
=
list
(
Protein
.
objects
.
filter
(
id__in
=
ids
).
all
())
elif
request
.
query_params
.
get
(
'
token
'
):
def
post
(
self
,
request
)
->
Response
:
proteins
=
[]
tissue
=
Tissue
.
objects
.
get
(
id
=
request
.
data
.
get
(
'
tissue
'
))
task
=
Task
.
objects
.
get
(
token
=
request
.
query_params
[
'
token
'
])
result
=
task_result
(
task
)
if
request
.
data
.
get
(
'
proteins
'
):
network
=
result
[
'
network
'
]
ids
=
json
.
loads
(
request
.
data
.
get
(
'
proteins
'
))
node_attributes
=
result
.
get
(
'
node_attributes
'
)
proteins
=
list
(
Protein
.
objects
.
filter
(
id__in
=
ids
).
all
())
if
not
node_attributes
:
elif
request
.
data
.
get
(
'
token
'
):
node_attributes
=
{}
proteins
=
[]
node_types
=
node_attributes
.
get
(
'
node_types
'
)
task
=
Task
.
objects
.
get
(
token
=
request
.
data
[
'
token
'
])
if
not
node_types
:
result
=
task_result
(
task
)
node_types
=
{}
network
=
result
[
'
network
'
]
parameters
=
json
.
loads
(
task
.
parameters
)
node_attributes
=
result
.
get
(
'
node_attributes
'
)
seeds
=
parameters
[
'
seeds
'
]
if
not
node_attributes
:
nodes
=
network
[
'
nodes
'
]
node_attributes
=
{}
for
node
in
nodes
+
seeds
:
node_types
=
node_attributes
.
get
(
'
node_types
'
)
node_type
=
node_types
.
get
(
node
)
if
not
node_types
:
details
=
None
node_types
=
{}
if
node_type
==
'
protein
'
:
parameters
=
json
.
loads
(
task
.
parameters
)
if
details
:
seeds
=
parameters
[
'
seeds
'
]
proteins
.
append
(
details
)
nodes
=
network
[
'
nodes
'
]
else
:
for
node
in
nodes
+
seeds
:
try
:
node_type
=
node_types
.
get
(
node
)
prot
=
Protein
.
objects
.
get
(
uniprot_code
=
node
)
details
=
None
if
prot
not
in
proteins
:
if
node_type
==
'
protein
'
:
proteins
.
append
(
Protein
.
objects
.
get
(
uniprot_code
=
node
))
if
details
:
except
Protein
.
DoesNotExist
:
proteins
.
append
(
details
)
pass
else
:
try
:
pt_expressions
=
{}
prot
=
Protein
.
objects
.
get
(
uniprot_code
=
node
)
if
prot
not
in
proteins
:
for
protein
in
proteins
:
proteins
.
append
(
Protein
.
objects
.
get
(
uniprot_code
=
node
))
try
:
except
Protein
.
DoesNotExist
:
expression_level
=
ExpressionLevel
.
objects
.
get
(
protein
=
protein
,
tissue
=
tissue
)
pass
pt_expressions
[
ProteinSerializer
().
to_representation
(
protein
)[
'
drugstone_id
'
]]
=
expression_level
.
expression_level
pt_expressions
=
{}
except
ExpressionLevel
.
DoesNotExist
:
pt_expressions
[
ProteinSerializer
().
to_representation
(
protein
)[
'
drugstone_id
'
]]
=
None
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
)
return
Response
(
pt_expressions
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment