Commit c280cccc authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

continue working on compound query interface (#43), WIP

- three visualization modes now
- most of the requested primary information is there


Former-commit-id: 9d5310f273011035e53643d4baf153d4769b6ca8
parent ac3d82b8
......@@ -341,6 +341,16 @@ class Compound(models.Model):
pfam_ids.add(bound_complex.complex.domain.pfam_id)
return pfam_ids
@property
def compound_action_pdb_ids(self):
"""
return all PDB codes of the corresponding compound actions
"""
pdb_ids = set()
for ca in self.compoundaction_set.all():
pdb_ids.add(ca.pdb_id)
return pdb_ids
class MDDRActivityClass(models.Model):
name = models.CharField('Activity Class', max_length=100, unique=True)
......
......@@ -67,27 +67,50 @@
{% endif %}
</span>
<span class="btn-group float-right">
<a class="btn btn-default btn-outline-primary {% if not display_list %}active{% endif %}" href="#" {% if display_list %}onclick="modifyUrl('display_list', null)"{% endif %}>
<a class="btn btn-default btn-outline-primary {% if display == 'v' %}active{% endif %}" href="#" {% if display != 'v' %}onclick="modifyUrl('display', 'v')"{% endif %}>
<i class="fa fa-th" title="Vignettes"></i>
</a>
<a class="btn btn-default btn-outline-primary {% if display_list %}active{% endif %}" href="#" {% if not display_list %}onclick="modifyUrl('display_list', true)"{% endif %}>
<a class="btn btn-default btn-outline-primary {% if display == 'l' %}active{% endif %}" href="#" {% if display != 'l' %}onclick="modifyUrl('display', 'l')"{% endif %}>
<i class="fa fa-bars" title="List"></i>
</a>
<a class="btn btn-default btn-outline-primary {% if display == 't' %}active{% endif %}" href="#" {% if display != 't' %}onclick="modifyUrl('display', 't')"{% endif %}>
<i class="fa fa-table" title="Table"></i>
</a>
</span>
</div>
</form>
{% if compounds %}
{% if display_list %}
<div class="row">
{% if display == 'v' %}
{% for compound in compounds %}
{% include "compound_v_item.html" with compound=compound %}
{% endfor %}
{% elif display == 'l'%}
{% for compound in compounds %}
{% include "compound_table_item.html" with compound=compound %}
{% include "compound_l_item.html" with compound=compound %}
{% endfor %}
{% else %}
<div class="row">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Common name</th>
<th scope="col">Molecular weight</th>
<th scope="col">AlogP</th>
<th scope="col">PDB ligand</th>
<th scope="col">MDDR phase</th>
<th scope="col">Available tests</th>
<th scope="col">Available publications</th>
</tr>
</thead>
<tbody>
{% for compound in compounds %}
{% include "compound_grid_item.html" with compound=compound %}
{% include "compound_t_item.html" with compound=compound %}
{% endfor %}
</div>
</tbody>
</table>
{% endif %}
</div>
{% else %}
<p>Nothing found there!</p>
{% endif %}
......
<tr>
<th scope="col"><span class="badge badge-dark"><a href="/compound/{{ compound.id }}">{{ compound.id }}</a></span></th>
<th scope="col">{{ compound.common_name|default_if_none:"-" }}</th>
<th scope="col">{{ compound.molecular_weight}} g/mol</th>
<th scope="col">{{ compound.a_log_p }}</th>
<th scope="col">{% for pdb_id in compound.compound_action_pdb_ids %}{{ pdb_id }}{% endfor %}</th>
<th scope="col"> ? </th>
<th scope="col"> ? </th>
<th scope="col">{{ compound.biblio_refs|length }}</th>
</tr>
......@@ -6,23 +6,3 @@
<p>Molecular Weight: {{ compound.molecular_weight }} g/mol</p>
</div>
</div>
<!--
<div class="col-md-4 border border-info bg-light">
<div class="row border-info d-flex justify-content-center align-content-center">
<a href="/compound/{{ compound.id }}">{% include "pubchem_img.html" %}</a>
</div>
<div class="row">
<ul class="list-group">
{% if compound.common_name %}
<li class="list-group-item">Common name: {{ compound.common_name }}</li>
{% endif %}
{% if compound.canonical_smile %}
<li class="list-group-item">Canonical SMILES: {{ compound.canonical_smile }}</li>
{% endif %}
{% if compound.iupac_name %}
<li class="list-group-item">IUPAC name: {{ compound.iupac_name }}</li>
{% endif %}
</ul>
</div>
</div>
-->
......@@ -211,7 +211,9 @@ def compound_list(request):
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
compounds = paginator.page(paginator.num_pages)
display_list = request.GET.get('display_list')
display = request.GET.get('display')
if display not in ['l', 't']:
display = 'v'
return render(request, 'compound_list.html', {'compounds': compounds,
'count': count,
'selected_ppis': selected_ppis,
......@@ -226,7 +228,7 @@ def compound_list(request):
'selected_boundcomplexes': selected_boundcomplexes,
'boundcomplexes': boundcomplexes,
'boundcomplexes_all': boundcomplexes_all,
'display_list': display_list
'display': display
})
def compound_card(request, compound_id):
......
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