diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index eecaaf86f9058a92c235e1109ad7e56351947ce4..81350553cca6c90c8c497eb8db9d8c96fdd93607 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -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) diff --git a/ippisite/ippidb/templates/compound_grid_item.html b/ippisite/ippidb/templates/compound_grid_item.html deleted file mode 100644 index b4e225c006ea4a078966fa2be9aebe5e3a239d91..0000000000000000000000000000000000000000 --- a/ippisite/ippidb/templates/compound_grid_item.html +++ /dev/null @@ -1,28 +0,0 @@ -<div class="card m-2 border border-info" style="width: 300px"> - <a href="/compound/{{ compound.id }}">{% include "pubchem_img.html" %}</a> - <div class="card-body" style="overflow:hidden; word-wrap:break-word;"> - <span class="badge badge-dark"><a href="/compound/{{ compound.id }}">{{ compound.id }}</a></span> - <p>{% for pfam_id in compound.pfam_ids %}{{ pfam_id }}{% endfor %}</p> - <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> ---> diff --git a/ippisite/ippidb/templates/compound_table_item.html b/ippisite/ippidb/templates/compound_l_item.html similarity index 100% rename from ippisite/ippidb/templates/compound_table_item.html rename to ippisite/ippidb/templates/compound_l_item.html diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html index accb82843d65aed6f7d84f5e81c1979d27cb8dae..593dc1ca822b20eb1a3b3e6b4ab0761bbc890d47 100644 --- a/ippisite/ippidb/templates/compound_list.html +++ b/ippisite/ippidb/templates/compound_list.html @@ -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 %} diff --git a/ippisite/ippidb/templates/compound_t_item.html b/ippisite/ippidb/templates/compound_t_item.html new file mode 100644 index 0000000000000000000000000000000000000000..57faae8504e2a6b66973f35bcc08e0bf1f2a3e43 --- /dev/null +++ b/ippisite/ippidb/templates/compound_t_item.html @@ -0,0 +1,10 @@ +<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> diff --git a/ippisite/ippidb/templates/compound_v_item.html b/ippisite/ippidb/templates/compound_v_item.html new file mode 100644 index 0000000000000000000000000000000000000000..e6e54ecdcf74b7a66f5ae394e789aee05d56eae7 --- /dev/null +++ b/ippisite/ippidb/templates/compound_v_item.html @@ -0,0 +1,8 @@ +<div class="card m-2 border border-info" style="width: 300px"> + <a href="/compound/{{ compound.id }}">{% include "pubchem_img.html" %}</a> + <div class="card-body" style="overflow:hidden; word-wrap:break-word;"> + <span class="badge badge-dark"><a href="/compound/{{ compound.id }}">{{ compound.id }}</a></span> + <p>{% for pfam_id in compound.pfam_ids %}{{ pfam_id }}{% endfor %}</p> + <p>Molecular Weight: {{ compound.molecular_weight }} g/mol</p> + </div> +</div> diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index c1753120304a7bae872b91b6c491cf765d05e7d7..0895e0a98746bc609e0c8b0fd2513e22626c695f 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -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):