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
8cac835e
Commit
8cac835e
authored
2 years ago
by
AndiMajore
Browse files
Options
Downloads
Patches
Plain Diff
fixed entrez and ensembl based gene mapping
parent
5c84b617
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drugstone/models.py
+0
-1
0 additions, 1 deletion
drugstone/models.py
drugstone/util/query_db.py
+9
-6
9 additions, 6 deletions
drugstone/util/query_db.py
scripts/docker-entrypoint.sh
+2
-2
2 additions, 2 deletions
scripts/docker-entrypoint.sh
with
11 additions
and
9 deletions
drugstone/models.py
+
0
−
1
View file @
8cac835e
...
...
@@ -68,7 +68,6 @@ class Protein(models.Model):
entrez
=
models
.
CharField
(
max_length
=
15
,
default
=
''
)
drugs
=
models
.
ManyToManyField
(
'
Drug
'
,
through
=
'
ProteinDrugInteraction
'
,
related_name
=
'
interacting_drugs
'
)
ensembl
=
models
.
CharField
(
max_length
=
15
,
default
=
''
)
tissue_expression
=
models
.
ManyToManyField
(
'
Tissue
'
,
through
=
'
ExpressionLevel
'
,
related_name
=
'
interacting_drugs
'
)
...
...
This diff is collapsed.
Click to expand it.
drugstone/util/query_db.py
+
9
−
6
View file @
8cac835e
from
typing
import
List
,
Tuple
from
typing
import
List
,
Tuple
,
Set
from
functools
import
reduce
from
django.db.models
import
Q
from
drugstone.models
import
Protein
from
drugstone.models
import
Protein
,
EnsemblGene
from
drugstone.serializers
import
ProteinSerializer
def
query_proteins_by_identifier
(
node_ids
:
Lis
t
[
str
],
identifier
:
str
)
->
Tuple
[
List
[
dict
],
str
]:
def
query_proteins_by_identifier
(
node_ids
:
Se
t
[
str
],
identifier
:
str
)
->
Tuple
[
List
[
dict
],
str
]:
"""
Queries the django database Protein table given a list of identifiers (node_ids) and a identifier name
(identifier).
The identifier name represents any protein attribute, e.g. uniprot or symbol.
...
...
@@ -31,13 +31,16 @@ def query_proteins_by_identifier(node_ids: List[str], identifier: str) -> Tuple[
q_list
=
map
(
lambda
n
:
Q
(
uniprot_code__iexact
=
n
),
node_ids
)
elif
identifier
==
'
ensg
'
:
protein_attribute
=
'
ensg
'
q_list
=
map
(
lambda
n
:
Q
(
ensg__name__iexact
=
n
),
node_ids
)
node_ids
=
map
(
lambda
n
:
n
.
protein_id
,
EnsemblGene
.
objects
.
filter
(
reduce
(
lambda
a
,
b
:
a
|
b
,
map
(
lambda
n
:
Q
(
name__iexact
=
n
),
list
(
node_ids
)))))
q_list
=
map
(
lambda
n
:
Q
(
id
=
n
),
node_ids
)
elif
identifier
==
'
entrez
'
:
protein_attribute
=
'
entrez
'
q_list
=
map
(
lambda
n
:
Q
(
entrez
=
n
),
node_ids
)
if
not
node_ids
:
# node_ids is an empty list
return
[],
protein_attribute
q_list
=
reduce
(
lambda
a
,
b
:
a
|
b
,
q_list
)
node_objects
=
Protein
.
objects
.
filter
(
q_list
)
# serialize
nodes
=
ProteinSerializer
(
many
=
True
).
to_representation
(
node_objects
)
...
...
This diff is collapsed.
Click to expand it.
scripts/docker-entrypoint.sh
+
2
−
2
View file @
8cac835e
...
...
@@ -4,7 +4,7 @@ python3 manage.py makemigrations drugstone
python3 manage.py migrate
python3 manage.py createfixtures
python3 manage.py cleanuptasks
python3 manage.py populate_db
--
all
python3 manage.py make_graphs
#
python3 manage.py populate_db --
update -a
#
python3 manage.py make_graphs
/usr/bin/supervisord
-c
"/etc/supervisor/conf.d/supervisord.conf"
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