Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
48aac012
Commit
48aac012
authored
5 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
add an admin task to update Compound cross-links
parent
915bd48c
No related branches found
Branches containing commit
Tags
v0.2.62
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ippisite/ippidb/tasks.py
+55
-3
55 additions, 3 deletions
ippisite/ippidb/tasks.py
ippisite/ippisite/admin.py
+13
-0
13 additions, 0 deletions
ippisite/ippisite/admin.py
ippisite/templates/admin/index.html
+6
-1
6 additions, 1 deletion
ippisite/templates/admin/index.html
with
74 additions
and
4 deletions
ippisite/ippidb/tasks.py
+
55
−
3
View file @
48aac012
...
@@ -424,6 +424,24 @@ def generate_pca_plot():
...
@@ -424,6 +424,24 @@ def generate_pca_plot():
print
(
"
Successfully generated PCA biplot data
"
)
print
(
"
Successfully generated PCA biplot data
"
)
def
set_compound_links
(
compound_ids
:
List
[
int
])
->
List
[
int
]:
"""
set/update links with external databases:
DrugBank, ChEMBL, PubChem
for each compound of a queryset
:param qs: queryset over the compounds to be processed
:type qs: QuerySet
"""
qs
=
Compound
.
objects
.
filter
(
id__in
=
compound_ids
)
for
c
in
qs
:
c
.
set_drugbank_link
()
c
.
set_chembl_link
()
c
.
set_pubchem_link
()
c
.
save
()
return
[
c
.
id
for
c
in
qs
]
@task
(
base
=
MonitorTask
,
bind
=
True
)
@task
(
base
=
MonitorTask
,
bind
=
True
)
def
run_compute_compound_properties
(
self
:
MonitorTask
,
compound_id
:
int
)
->
int
:
def
run_compute_compound_properties
(
self
:
MonitorTask
,
compound_id
:
int
)
->
int
:
"""
"""
...
@@ -506,9 +524,30 @@ def run_compute_drugbank_similarity(
...
@@ -506,9 +524,30 @@ def run_compute_drugbank_similarity(
@task
(
base
=
MonitorTask
,
bind
=
True
)
@task
(
base
=
MonitorTask
,
bind
=
True
)
def
run_validate
(
def
run_set_compound_links
(
self
:
MonitorTask
,
compound_id
:
int
)
->
int
:
self
:
MonitorTask
,
compound_ids
:
List
[
int
]
=
None
"""
)
->
List
[
int
]:
task to set/update the DB cross-links for a compound
:param self: the task the function is binded to as a method
:type self: MonitorTask
:param compound_id: the ID of the compound
:type compound_id: int
:return: the ID of the compound
:rtype: int
"""
self
.
update_state
(
state
=
states
.
STARTED
)
cj
=
CompoundJob
()
cj
.
compound
=
Compound
.
objects
.
get
(
id
=
compound_id
)
cj
.
job
=
Job
.
objects
.
get
(
task_result__task_id
=
self
.
task_id
)
cj
.
save
()
self
.
write
(
std_out
=
f
"
Starting setting external cross-links for
{
compound_id
}
"
)
result_compound_ids
=
set_compound_links
([
compound_id
])
self
.
write
(
std_out
=
f
"
Finished setting external cross-links for
{
compound_id
}
"
)
return
result_compound_ids
[
0
]
@task
(
base
=
MonitorTask
,
bind
=
True
)
def
run_validate
(
self
:
MonitorTask
,
compound_ids
:
List
[
int
]
=
None
)
->
List
[
int
]:
"""
"""
task
"
run method
"
to validate a list of compounds
task
"
run method
"
to validate a list of compounds
...
@@ -598,3 +637,16 @@ def launch_plots_computing():
...
@@ -598,3 +637,16 @@ def launch_plots_computing():
"""
"""
workflow
=
chain
(
run_le_lle_plot
.
si
(),
run_pca_plot
.
si
())
workflow
=
chain
(
run_le_lle_plot
.
si
(),
run_pca_plot
.
si
())
workflow
.
delay
()
workflow
.
delay
()
def
launch_set_compound_links
():
"""
Launch the tasks to set/update compound links
"""
link_jobs_group
=
group
(
[
run_set_compound_links
.
si
(
compound
.
id
)
for
compound
in
Compound
.
objects
.
validated
()
]
)
link_jobs_group
.
delay
()
This diff is collapsed.
Click to expand it.
ippisite/ippisite/admin.py
+
13
−
0
View file @
48aac012
...
@@ -6,6 +6,7 @@ from ippidb.tasks import (
...
@@ -6,6 +6,7 @@ from ippidb.tasks import (
launch_update_compound_cached_properties
,
launch_update_compound_cached_properties
,
run_compute_drugbank_similarity
,
run_compute_drugbank_similarity
,
launch_plots_computing
,
launch_plots_computing
,
launch_set_compound_links
,
)
)
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
ippidb.models
import
Job
from
ippidb.models
import
Job
...
@@ -36,6 +37,10 @@ class IppidbAdmin(admin.AdminSite):
...
@@ -36,6 +37,10 @@ class IppidbAdmin(admin.AdminSite):
"
launch_plots_computing/
"
,
"
launch_plots_computing/
"
,
self
.
admin_view
(
self
.
launch_plots_computing_view
),
self
.
admin_view
(
self
.
launch_plots_computing_view
),
),
),
path
(
"
launch_set_compound_links/
"
,
self
.
admin_view
(
self
.
launch_set_compound_links_view
),
),
path
(
"
tasklog/
"
,
self
.
admin_view
(
self
.
tasklog
),
name
=
"
tasklog
"
),
path
(
"
tasklog/
"
,
self
.
admin_view
(
self
.
tasklog
),
name
=
"
tasklog
"
),
]
]
return
my_urls
+
urls
return
my_urls
+
urls
...
@@ -90,3 +95,11 @@ class IppidbAdmin(admin.AdminSite):
...
@@ -90,3 +95,11 @@ class IppidbAdmin(admin.AdminSite):
launch_plots_computing
()
launch_plots_computing
()
messages
.
add_message
(
request
,
messages
.
INFO
,
"
Plots computing launched
"
)
messages
.
add_message
(
request
,
messages
.
INFO
,
"
Plots computing launched
"
)
return
redirect
(
"
/admin/ippidb/job
"
)
return
redirect
(
"
/admin/ippidb/job
"
)
def
launch_set_compound_links_view
(
self
,
request
):
"""
This view launches the task to set/update compound DB cross-links.
"""
launch_set_compound_links
()
messages
.
add_message
(
request
,
messages
.
INFO
,
"
DB links update launched
"
)
return
redirect
(
"
/admin/ippidb/job
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ippisite/templates/admin/index.html
+
6
−
1
View file @
48aac012
...
@@ -58,7 +58,12 @@
...
@@ -58,7 +58,12 @@
style=
"display:block"
>
{% csrf_token %}
style=
"display:block"
>
{% csrf_token %}
<input
type=
"submit"
value=
"Plots generation"
name=
"_save"
/>
<input
type=
"submit"
value=
"Plots generation"
name=
"_save"
/>
</form>
</form>
<hr/>
<hr/>
<form
method=
"POST"
action=
"/admin/launch_set_compound_links/"
style=
"display:block"
>
{% csrf_token %}
<input
type=
"submit"
value=
"DB links update"
name=
"_save"
/>
</form>
<hr/>
</div>
</div>
...
...
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