Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iPPIDB
ippidb-web
Commits
5b295e51
Commit
5b295e51
authored
Sep 14, 2020
by
Hervé MENAGER
Browse files
fix compound card page if LE-LLE or PCA data not avail.
FIX #242
parent
0b76f8ac
Pipeline
#37365
failed with stages
in 1 minute and 16 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ippisite/ippidb/templates/compound_card.html
View file @
5b295e51
...
...
@@ -313,6 +313,7 @@
</div>
</div>
</div>
{% if pca_biplot_data %}
<div
class=
"row d-flex justify-content-center"
>
<div
class=
"col-sm-12 col-md-9"
>
<h5
class=
"card_title"
>
PCA : iPPI-DB chemical space
</h5>
...
...
@@ -331,8 +332,10 @@
</div>
</div>
</div>
{% endif %}
</div>
<div
class=
"tab-pane fade"
id=
"pharmacology"
role=
"tabpanel"
aria-labelledby=
"pharmacology-tab"
>
{% if le_lle_biplot_data %}
<div
class=
"row d-flex justify-content-center"
>
<div
class=
"col-sm-12 col-md-9"
style=
"margin: 10px;"
>
<h5
class=
"card_title"
>
Efficiencies: iPPI-DB biplot LE versus LLE
<span
class=
"info_point"
...
...
@@ -371,7 +374,9 @@
</script>
</div>
</div>
</div>
{% endif %}
<div
class=
"row d-flex justify-content-center"
>
<div
class=
"col-sm-12 col-md-9"
style=
"margin: 10px;"
>
<h5
class=
"card_title"
>
Summary
</h5>
...
...
ippisite/ippidb/tests/tests.py
View file @
5b295e51
...
...
@@ -10,7 +10,6 @@ from django.test import TestCase
from
django.urls
import
reverse
import
requests
from
ippidb
import
models
from
ippidb.ws
import
(
get_uniprot_info
,
...
...
@@ -38,6 +37,7 @@ from ippidb.models import (
DrugBankCompound
,
Protein
,
)
from
.utils
import
create_dummy_compound
,
create_dummy_drugbank_compound
class
MolSmiTestCase
(
TestCase
):
...
...
@@ -94,65 +94,6 @@ class MolSmiTestCase(TestCase):
self
.
assertEqual
(
response
.
status_code
,
400
)
def
create_dummy_compound
(
id_
,
smiles
):
c
=
Compound
()
c
.
id
=
id_
c
.
canonical_smile
=
smiles
c
.
is_macrocycle
=
True
c
.
aromatic_ratio
=
0.0
c
.
balaban_index
=
0.0
c
.
fsp3
=
0.0
c
.
gc_molar_refractivity
=
0.0
c
.
log_d
=
0.0
c
.
a_log_p
=
0.0
c
.
gc_molar_refractivity
=
0.0
c
.
mean_atom_vol_vdw
=
0.0
c
.
molecular_weight
=
0.0
c
.
nb_acceptor_h
=
0
c
.
nb_aliphatic_amines
=
0
c
.
nb_aromatic_bonds
=
0
c
.
nb_aromatic_ether
=
0
c
.
nb_aromatic_sssr
=
0
c
.
nb_atom
=
0
c
.
nb_atom_non_h
=
0
c
.
nb_benzene_like_rings
=
0
c
.
nb_bonds
=
0
c
.
nb_bonds_non_h
=
0
c
.
nb_br
=
0
c
.
nb_c
=
0
c
.
nb_chiral_centers
=
0
c
.
nb_circuits
=
0
c
.
nb_cl
=
0
c
.
nb_csp2
=
0
c
.
nb_csp3
=
0
c
.
nb_donor_h
=
0
c
.
nb_double_bonds
=
0
c
.
nb_f
=
0
c
.
nb_i
=
0
c
.
nb_multiple_bonds
=
0
c
.
nb_n
=
0
c
.
nb_o
=
0
c
.
nb_rings
=
0
c
.
nb_rotatable_bonds
=
0
c
.
randic_index
=
0
c
.
rdf070m
=
0
c
.
rotatable_bond_fraction
=
0
c
.
sum_atom_polar
=
0
c
.
sum_atom_vol_vdw
=
0
c
.
tpsa
=
0
c
.
ui
=
0
c
.
wiener_index
=
0
c
.
save
(
autofill
=
True
)
return
c
def
create_dummy_drugbank_compound
(
id_
,
smiles
):
dbc
=
DrugBankCompound
()
dbc
.
id
=
id_
dbc
.
common_name
=
"DrugBankCompound"
+
str
(
id_
)
dbc
.
canonical_smiles
=
smiles
dbc
.
save
()
class
CompoundTanimotoTestCase
(
TestCase
):
def
setUp
(
self
):
...
...
ippisite/ippidb/tests/tests_views.py
View file @
5b295e51
...
...
@@ -3,8 +3,11 @@ iPPI-DB views tests
"""
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.core.management
import
call_command
from
parameterized
import
parameterized
from
.utils
import
create_dummy_compound
tested_urlpatterns
=
[
"index"
,
"general"
,
...
...
@@ -37,3 +40,32 @@ class ViewTest(TestCase):
def
test_url
(
self
,
url_name
):
response
=
self
.
client
.
get
(
reverse
(
url_name
))
self
.
assertEqual
(
response
.
status_code
,
200
)
class
CompoundCardViewTest
(
TestCase
):
"""
Tests for compound card
"""
def
setUp
(
self
):
create_dummy_compound
(
1
,
"CC"
)
def
test_compound_card
(
self
):
"""
basic test for compound card
"""
call_command
(
"lle_le"
)
call_command
(
"pca"
)
response
=
self
.
client
.
get
(
reverse
(
"compound_card"
,
kwargs
=
{
"pk"
:
1
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_compound_card_no_lelleplot_data
(
self
):
"""
test that compound card is ok even if LE-LLE plot
data are missing (which can happen during LE-LLE recomputing)
"""
response
=
self
.
client
.
get
(
reverse
(
"compound_card"
,
kwargs
=
{
"pk"
:
1
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
ippisite/ippidb/tests/utils.py
0 → 100644
View file @
5b295e51
from
ippidb.models
import
Compound
,
DrugBankCompound
def
create_dummy_compound
(
id_
,
smiles
):
c
=
Compound
()
c
.
id
=
id_
c
.
canonical_smile
=
smiles
c
.
is_macrocycle
=
True
c
.
aromatic_ratio
=
0.0
c
.
balaban_index
=
0.0
c
.
fsp3
=
0.0
c
.
gc_molar_refractivity
=
0.0
c
.
log_d
=
0.0
c
.
a_log_p
=
0.0
c
.
gc_molar_refractivity
=
0.0
c
.
mean_atom_vol_vdw
=
0.0
c
.
molecular_weight
=
0.0
c
.
nb_acceptor_h
=
0
c
.
nb_aliphatic_amines
=
0
c
.
nb_aromatic_bonds
=
0
c
.
nb_aromatic_ether
=
0
c
.
nb_aromatic_sssr
=
0
c
.
nb_atom
=
0
c
.
nb_atom_non_h
=
0
c
.
nb_benzene_like_rings
=
0
c
.
nb_bonds
=
0
c
.
nb_bonds_non_h
=
0
c
.
nb_br
=
0
c
.
nb_c
=
0
c
.
nb_chiral_centers
=
0
c
.
nb_circuits
=
0
c
.
nb_cl
=
0
c
.
nb_csp2
=
0
c
.
nb_csp3
=
0
c
.
nb_donor_h
=
0
c
.
nb_double_bonds
=
0
c
.
nb_f
=
0
c
.
nb_i
=
0
c
.
nb_multiple_bonds
=
0
c
.
nb_n
=
0
c
.
nb_o
=
0
c
.
nb_rings
=
0
c
.
nb_rotatable_bonds
=
0
c
.
randic_index
=
0
c
.
rdf070m
=
0
c
.
rotatable_bond_fraction
=
0
c
.
sum_atom_polar
=
0
c
.
sum_atom_vol_vdw
=
0
c
.
tpsa
=
0
c
.
ui
=
0
c
.
wiener_index
=
0
c
.
save
(
autofill
=
True
)
return
c
def
create_dummy_drugbank_compound
(
id_
,
smiles
):
dbc
=
DrugBankCompound
()
dbc
.
id
=
id_
dbc
.
common_name
=
"DrugBankCompound"
+
str
(
id_
)
dbc
.
canonical_smiles
=
smiles
dbc
.
save
()
ippisite/ippidb/views/compound_query.py
View file @
5b295e51
...
...
@@ -759,9 +759,17 @@ class CompoundDetailView(DetailView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
().
get_context_data
(
**
kwargs
)
context
[
"le_lle_biplot_data"
]
=
LeLleBiplotData
.
objects
.
get
().
le_lle_biplot_data
pca_biplot
=
json
.
loads
(
PcaBiplotData
.
objects
.
get
().
pca_biplot_data
)
context
[
"pca_biplot_data"
]
=
json
.
dumps
(
pca_biplot
[
"data"
])
try
:
context
[
"le_lle_biplot_data"
]
=
LeLleBiplotData
.
objects
.
get
().
le_lle_biplot_data
except
LeLleBiplotData
.
DoesNotExist
:
context
[
"le_lle_biplot_data"
]
=
[]
try
:
pca_biplot
=
json
.
loads
(
PcaBiplotData
.
objects
.
get
().
pca_biplot_data
)
except
PcaBiplotData
.
DoesNotExist
:
pca_biplot
=
{
"data"
:
[],
"correlation_circle"
:
""
}
context
[
"pca_biplot_data"
]
=
pca_biplot
[
"data"
]
context
[
"pca_biplot_cc"
]
=
pca_biplot
[
"correlation_circle"
]
return
context
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment