Commit 24b5d5bf authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

Merge branch 'master' into 'release'

fixes for 1.0.2

See merge request !19
parents b3eff48b 7a396f97
Pipeline #40883 passed with stages
in 20 minutes and 31 seconds
...@@ -838,6 +838,11 @@ class CompoundActivityResultForm(ModelForm): ...@@ -838,6 +838,11 @@ class CompoundActivityResultForm(ModelForm):
"activity": widgets.HiddenInput(), "activity": widgets.HiddenInput(),
} }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for f in self.fields.values():
f.widget.attrs.update({"class": "col-3"})
def has_changed(self): def has_changed(self):
""" """
Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and
...@@ -1035,10 +1040,10 @@ class TestActivityDescriptionForm(forms.ModelForm): ...@@ -1035,10 +1040,10 @@ class TestActivityDescriptionForm(forms.ModelForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["test_type"].widget.attrs["onchange"] = "test_type_changed(this);" self.fields["test_type"].widget.attrs["onchange"] = "test_type_changed(this);"
self.fields["test_type"].widget.attrs.update({"class": "col-2"}) self.fields["test_type"].widget.attrs.update({"class": "col-2"})
self.fields["test_name"].widget.attrs.update({"class": "col-9"}) self.fields["test_name"].widget.attrs.update({"class": "col-10"})
self.fields["test_modulation_type"].widget.attrs.update({"class": "col-2"}) self.fields["test_modulation_type"].widget.attrs.update({"class": "col-2"})
self.fields["nb_active_compounds"].widget.attrs.update({"class": "col-3"}) self.fields["nb_active_compounds"].widget.attrs.update({"class": "col-3"})
self.fields["cell_line_name"].widget.attrs.update({"class": "col-6"}) self.fields["cell_line_name"].widget.attrs.update({"class": "col-7"})
def has_changed(self): def has_changed(self):
""" """
...@@ -1166,6 +1171,11 @@ class CompoundCytotoxicityResultForm(ModelForm): ...@@ -1166,6 +1171,11 @@ class CompoundCytotoxicityResultForm(ModelForm):
fields = ("compound_name", "toxicity") fields = ("compound_name", "toxicity")
widgets = {"toxicity": forms.Select(choices=((True, "True"), (False, "False")))} widgets = {"toxicity": forms.Select(choices=((True, "True"), (False, "False")))}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for f in self.fields.values():
f.widget.attrs.update({"class": "col-3"})
def has_changed(self): def has_changed(self):
""" """
Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and
...@@ -1280,6 +1290,9 @@ class TestCytotoxDescriptionForm(forms.ModelForm): ...@@ -1280,6 +1290,9 @@ class TestCytotoxDescriptionForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["compound_concentration"].required = True self.fields["compound_concentration"].required = True
self.fields["cell_line_name"].widget.attrs.update({"class": "col"})
self.fields["compound_concentration"].widget.attrs.update({"class": "col"})
self.fields["test_name"].widget.attrs.update({"class": "col"})
def has_changed(self): def has_changed(self):
""" """
...@@ -1378,6 +1391,13 @@ class CompoundPKResultForm(ModelForm): ...@@ -1378,6 +1391,13 @@ class CompoundPKResultForm(ModelForm):
) )
} }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for f in self.fields.values():
f.widget.attrs.update({"class": "col-3"})
if isinstance(f, forms.BooleanField) and not isinstance(f.widget, forms.Select):
f.widget.attrs.update({"class": "col-3 mb-4"})
def has_changed(self): def has_changed(self):
""" """
Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and
...@@ -1489,6 +1509,8 @@ class TestPKDescriptionForm(forms.ModelForm): ...@@ -1489,6 +1509,8 @@ class TestPKDescriptionForm(forms.ModelForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
for f in ["administration_mode", "dose"]: for f in ["administration_mode", "dose"]:
self.fields[f].required = True self.fields[f].required = True
for f in self.fields.values():
f.widget.attrs.update({"class": "col-3"})
def has_changed(self): def has_changed(self):
""" """
......
...@@ -1082,6 +1082,59 @@ class Compound(AutoFillableModel): ...@@ -1082,6 +1082,59 @@ class Compound(AutoFillableModel):
""" """
return reverse("compound_card", kwargs={"pk": self.pk}) return reverse("compound_card", kwargs={"pk": self.pk})
@property
def pubchem_url(self):
"""
Get absolute URL to the corresponding PubChem entry
"""
return (
f"https://pubchem.ncbi.nlm.nih.gov/compound/{ self.pubchem_id }"
if self.pubchem_id
else None
)
@property
def chembl_url(self):
"""
Get absolute URL to the corresponding Chembl entry
"""
return (
f"https://www.ebi.ac.uk/chembldb/compound/inspect/{ self.chembl_id }"
if self.chembl_id
else None
)
@property
def chemspider_url(self):
"""
Get absolute URL to the corresponding ChemSpider entry
"""
return (
f"http://www.chemspider.com/Chemical-Structure.{ self.chemspider_id}.html"
if self.chemspider_id
else None
)
@property
def pdbligand_url(self):
"""
Get absolute URL to the corresponding PDB ligand entry
"""
return (
f"https://www.rcsb.org/ligand/{ self.ligand_id}" if self.ligand_id else None
)
@property
def drugbank_url(self):
"""
Get absolute URL to the corresponding Drugbank entry
"""
return (
f"https://www.drugbank.ca/drugs/{ self.drugbank_id}"
if self.drugbank_id
else None
)
def clean(self): def clean(self):
""" """
Perform additional checks: Perform additional checks:
...@@ -1576,20 +1629,13 @@ def update_compound_cached_properties(compounds_queryset=None): ...@@ -1576,20 +1629,13 @@ def update_compound_cached_properties(compounds_queryset=None):
le=Subquery( le=Subquery(
compounds_queryset.filter(id=OuterRef("id")) compounds_queryset.filter(id=OuterRef("id"))
.annotate( .annotate(
_le=Cast( _le=Cast(1.37 * F("best_activity") / F("nb_atom_non_h"), FloatField(),)
1.37 * F("best_activity") / F("nb_atom_non_h"),
FloatField(),
)
) )
.values("_le")[:1] .values("_le")[:1]
), ),
lle=Subquery( lle=Subquery(
compounds_queryset.filter(id=OuterRef("id")) compounds_queryset.filter(id=OuterRef("id"))
.annotate( .annotate(_lle=Cast(F("best_activity") - F("a_log_p"), FloatField()))
_lle=Cast(
F("best_activity") - F("a_log_p"), FloatField()
)
)
.values("_lle")[:1] .values("_lle")[:1]
), ),
lipinsky_mw=Subquery( lipinsky_mw=Subquery(
......
...@@ -225,7 +225,7 @@ Description: IPPI-DB Theme ...@@ -225,7 +225,7 @@ Description: IPPI-DB Theme
.input_field { .input_field {
width: 100%; width: 100%;
margin-right: 2px; margin-right: 0px;
font-family: "BrandonGrotesqueReg"; font-family: "BrandonGrotesqueReg";
text-align: left; text-align: left;
margin-top: 0px; margin-top: 0px;
...@@ -268,6 +268,10 @@ Description: IPPI-DB Theme ...@@ -268,6 +268,10 @@ Description: IPPI-DB Theme
padding-bottom: 1%; padding-bottom: 1%;
} }
.form-group.form-check{
padding-left: 2.25rem;
}
.form-group.form-check, .compound .input_field input { .form-group.form-check, .compound .input_field input {
text-align: left; text-align: left;
} }
...@@ -356,6 +360,9 @@ Description: IPPI-DB Theme ...@@ -356,6 +360,9 @@ Description: IPPI-DB Theme
.formset-item .formset-item-delete-host { .formset-item .formset-item-delete-host {
font-size: initial; font-size: initial;
text-align: right; text-align: right;
position: absolute;
right: 3em;
margin-top: -4em;
} }
.formset-item-delete-host input { .formset-item-delete-host input {
...@@ -1352,6 +1359,7 @@ Description: IPPI-DB Theme ...@@ -1352,6 +1359,7 @@ Description: IPPI-DB Theme
.test_title { .test_title {
text-align: left; text-align: left;
margin-top: 15px; margin-top: 15px;
margin-bottom: 1.5em;
} }
.tests { .tests {
......
...@@ -23,7 +23,11 @@ function add_nested_form_to_nested_formset(source, prefix, parent_prefix){ ...@@ -23,7 +23,11 @@ function add_nested_form_to_nested_formset(source, prefix, parent_prefix){
.find(".formset-nested-item")[0] .find(".formset-nested-item")[0]
.outerHTML; .outerHTML;
current_item_name = $(source).closest(".formset-item").children("input")[0].name; if($(source).closest(".formset-item").children("input").length>0){
current_item_name = $(source).closest(".formset-item").children("input")[0].name;
}else{
current_item_name = $(source).closest(".formset-item").children("div").children("input")[0].name;
}
current_item_name = current_item_name.substring(parent_prefix.length+1,current_item_name.indexOf('-',parent_prefix.length+1)); current_item_name = current_item_name.substring(parent_prefix.length+1,current_item_name.indexOf('-',parent_prefix.length+1));
empty_form_as_str = empty_form_as_str.replace( empty_form_as_str = empty_form_as_str.replace(
new RegExp(parent_prefix+"-__prefix__","g"), new RegExp(parent_prefix+"-__prefix__","g"),
......
...@@ -573,8 +573,9 @@ ...@@ -573,8 +573,9 @@
<script id='JSON_LD' type="application/ld+json"> <script id='JSON_LD' type="application/ld+json">
{ {
"url": "{{ compound.get_absolute_url }}", "url": "{{ request.build_absolute_uri }}",
"inChI": "{{ compound.inchi }}", "inChI": "{{ compound.inchi }}",
"name": "{{ compound.iupac_name }}",
"iupacName": "{{ compound.iupac_name }}", "iupacName": "{{ compound.iupac_name }}",
"molecularWeight": {{ compound.molecular_weight }}, "molecularWeight": {{ compound.molecular_weight }},
"identifier": "{{ compound.id }}", "identifier": "{{ compound.id }}",
...@@ -584,6 +585,21 @@ ...@@ -584,6 +585,21 @@
"smiles": [ "smiles": [
"{{ compound.canonical_smile }}" "{{ compound.canonical_smile }}"
], ],
{% if compound.pubchem_id %}
"sameAs": "{{ compound.pubchem_url }}",
{% endif %}
{% if compound.chembl_id %}
"sameAs": "{{ compound.chembl_url }}",
{% endif %}
{% if compound.chemspider_id %}
"sameAs": "{{ compound.chemspider_url }}",
{% endif %}
{% if compound.ligand_id %}
"sameAs": "{{ compound.pdbligand_url }}",
{% endif %}
{% if compound.drugbank_id %}
"sameAs": "{{ compound.drugbank_url }}",
{% endif %}
"@context": "http://schema.org" "@context": "http://schema.org"
} }
......
...@@ -4,35 +4,35 @@ ...@@ -4,35 +4,35 @@
<tr class="row"> <tr class="row">
<td scope="col" class="col-2 text-center"> <td scope="col" class="col-2 text-center">
{% if compound.pubchem_id %} {% if compound.pubchem_id %}
<a href="https://pubchem.ncbi.nlm.nih.gov/compound/{{ compound.pubchem_id }}" target="_blank"><img <a href="{{ compound.pubchem_url }}" target="_blank"><img
src="/static/images/Other/Pubchemlogo.png" style="height: 1.5em;" src="/static/images/Other/Pubchemlogo.png" style="height: 1.5em;"
title="PubChem ID: {{ compound.pubchem_id }}" /><br />{{ compound.pubchem_id }}</a> title="PubChem ID: {{ compound.pubchem_id }}" /><br />{{ compound.pubchem_id }}</a>
{% endif %} {% endif %}
</td> </td>
<td scope="col" class="col-2 text-center"> <td scope="col" class="col-2 text-center">
{% if compound.chembl_id %} {% if compound.chembl_id %}
<a href="https://www.ebi.ac.uk/chembldb/compound/inspect/{{ compound.chembl_id }}" target="_blank"><img <a href="{{ compound.chembl_url }}" target="_blank"><img
src="/static/images/Other/Chembl_logo.png" style="height: 1.5em;" src="/static/images/Other/Chembl_logo.png" style="height: 1.5em;"
title="ChEMBL ID: {{ compound.chembl_id }}" /><br />{{ compound.chembl_id }}</a> title="ChEMBL ID: {{ compound.chembl_id }}" /><br />{{ compound.chembl_id }}</a>
{% endif %} {% endif %}
</td> </td>
<td scope="col" class="col-2 text-center"> <td scope="col" class="col-2 text-center">
{% if compound.chemspider_id %} {% if compound.chemspider_id %}
<a href="http://www.chemspider.com/Chemical-Structure.{{ compound.chemspider_id}}.html" target="_blank"><img <a href="{{ compound.chemspider_url }}.html" target="_blank"><img
src="/static/images/Other/ChemSpider_Logo.png" style="height: 1.5em;" src="/static/images/Other/ChemSpider_Logo.png" style="height: 1.5em;"
title="ChemSpider ID: {{ compound.chemspider_id }}" /><br />{{ compound.chemspider_id }}</a> title="ChemSpider ID: {{ compound.chemspider_id }}" /><br />{{ compound.chemspider_id }}</a>
{% endif %} {% endif %}
</td> </td>
<td scope="col" class="col-2 text-center"> <td scope="col" class="col-2 text-center">
{% if compound.ligand_id %} {% if compound.ligand_id %}
<a href="https://www.rcsb.org/ligand/{{ compound.ligand_id}}" target="_blank"><img <a href="{{ compound.pdbligand_url }}" target="_blank"><img
src="/static/images/Other/PDBLogo.ico" style="height: 1.5em;" src="/static/images/Other/PDBLogo.ico" style="height: 1.5em;"
title="PDB Ligand ID: {{ compound.ligand_id }}" /><br />{{ compound.ligand_id }}</a> title="PDB Ligand ID: {{ compound.ligand_id }}" /><br />{{ compound.ligand_id }}</a>
{% endif %} {% endif %}
</td> </td>
<td scope="col" class="col-2 text-center"> <td scope="col" class="col-2 text-center">
{% if compound.drugbank_id %} {% if compound.drugbank_id %}
<a href="https://www.drugbank.ca/drugs/{{ compound.drugbank_id}}" target="_blank"><img <a href="{{ compound.drugbank_url }}" target="_blank"><img
src="/static/images/Other/DrugBankLogo.ico" style="height: 1.5em;" src="/static/images/Other/DrugBankLogo.ico" style="height: 1.5em;"
title="DrugBank ID: {{ compound.drugbank_id }}" /><br />{{ compound.drugbank_id }}</a> title="DrugBank ID: {{ compound.drugbank_id }}" /><br />{{ compound.drugbank_id }}</a>
{% endif %} {% endif %}
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</script> </script>
{% endblock extra_js %} {% endblock extra_js %}
<div class="formset-item"> <div class="formset-item mb-4">
<h3 class="test_title">Test description</h3> <h3 class="test_title">Test description</h3>
<div class="row"> <div class="row">
{{ form|bootstrap}} {{ form|bootstrap}}
...@@ -20,15 +20,19 @@ ...@@ -20,15 +20,19 @@
{{ form.nested.management_form }} {{ form.nested.management_form }}
{{ form.nested.non_form_errors|bootstrap }} {{ form.nested.non_form_errors|bootstrap }}
{% if nested_form %} {% if nested_form %}
<div class="formset-nested-item formset-item-inline-grid"> <div class="formset-nested-item ">
<h3 class="test_title">Test results</h3> <h3 class="test_title">Test results</h3>
{{ nested_form|bootstrap }} <div class="row">
{{ nested_form|bootstrap }}
</div>
</div> </div>
{% endif %} {% endif %}
{% for nested_form in nested_forms %} {% for nested_form in nested_forms %}
<div class="formset-nested-item formset-item-inline-grid"> <div class="formset-nested-item">
<h3 class="test_title">Test results</h3> <h3 class="test_title">Test results</h3>
{{ nested_form|bootstrap }} <div class="row">
{{ nested_form|bootstrap }}
</div>
</div> </div>
{% endfor %} {% endfor %}
<div class="form_div"> <div class="form_div">
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
"@type": "schema:Dataset", "@type": "schema:Dataset",
"schema:url": "https://ippidb.pasteur.fr", "schema:url": "https://ippidb.pasteur.fr",
"schema:includedInDataCatalog": "https://ippidb.pasteur.fr", "schema:includedInDataCatalog": "https://ippidb.pasteur.fr",
"schema:license": "Creative Commons Attribution-Share Alike 3.0 Unported License", "schema:license": "https://creativecommons.org/licenses/by-sa/3.0/deed.en_GB",
"@id": "https://ippidb.pasteur.fr", "@id": "https://ippidb.pasteur.fr",
"schema:name": "iPPI-DB", "schema:name": "iPPI-DB",
"schema:description": "a database of modulators of protein-protein interactions. It contains exclusively small molecules and therefore no peptides. The data are retrieved from the literature either peer reviewed scientific articles or world patents. A large variety of data is stored within IPPI-DB: structural, pharmacological, binding and activity profile, pharmacokinetic and cytotoxicity when available, as well as some data about the PPI targets themselves.", "schema:description": "a database of modulators of protein-protein interactions. It contains exclusively small molecules and therefore no peptides. The data are retrieved from the literature either peer reviewed scientific articles or world patents. A large variety of data is stored within IPPI-DB: structural, pharmacological, binding and activity profile, pharmacokinetic and cytotoxicity when available, as well as some data about the PPI targets themselves.",
......
...@@ -84,13 +84,23 @@ def bootstrap_core(object): ...@@ -84,13 +84,23 @@ def bootstrap_core(object):
# HACK : If the field is the DELETE button of the formset # HACK : If the field is the DELETE button of the formset
attrs["onchange"] = "delete_button_clicked(this);" attrs["onchange"] = "delete_button_clicked(this);"
field.label = ugettext("DELETE_label") field.label = ugettext("DELETE_label")
wrapping_classes += " formset-item-delete-host delete-btn" wrapping_classes += " formset-item-delete-host delete-btn col order-1"
css_classes.add("formset-item-delete") css_classes.add("formset-item-delete")
# HACK: if the css_class is a bootstrap column layout, transfer it to container element # HACK: if the css_class is a bootstrap column layout, transfer it to container element
for css_class in css_classes: for css_class in css_classes:
if css_class.startswith("col-"): if css_class.startswith("col") or css_class.startswith("order-") or css_class.startswith("mb-"):
wrapping_classes += f" {css_class}" wrapping_classes += f" {css_class}"
css_classes = set([css_class for css_class in css_classes if not(css_class.startswith('col-'))]) css_classes = set(
[
css_class
for css_class in css_classes
if not (
css_class.startswith("col")
or css_class.startswith("order-")
or css_class.startswith("mb-")
)
]
)
# overwrite the css classes # overwrite the css classes
attrs["class"] = " ".join(css_classes) attrs["class"] = " ".join(css_classes)
......
...@@ -601,7 +601,6 @@ class TestGetUniprotInfo(TestCase): ...@@ -601,7 +601,6 @@ class TestGetUniprotInfo(TestCase):
"GO_0005886", "GO_0005886",
"GO_0005905", "GO_0005905",
"GO_0010008", "GO_0010008",
"GO_0012505",
"GO_0030665", "GO_0030665",
"GO_0031253", "GO_0031253",
"GO_0042470", "GO_0042470",
...@@ -616,8 +615,8 @@ class TestGetUniprotInfo(TestCase): ...@@ -616,8 +615,8 @@ class TestGetUniprotInfo(TestCase):
) )
exp_biological_processes = [ exp_biological_processes = [
"GO_0000281", "GO_0000281",
"GO_0006886",
"GO_0008104", "GO_0008104",
"GO_0015031",
"GO_0016197", "GO_0016197",
"GO_0019882", "GO_0019882",
"GO_0031175", "GO_0031175",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment