Commit 0f39aece authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

compounds list, WIP


Former-commit-id: adeba92bffdb7d35210e3ac43a7247352d04dd47
parent 138172fb
......@@ -320,6 +320,12 @@ class Compound(models.Model):
mddr_compound = models.ForeignKey(
'MDDRCompoundImport', blank=True, null=True)
@property
def biblio_refs(self):
"""
return all RefCompoundBiblio related to this complex
"""
return RefCompoundBiblio.objects.filter(compound=self)
class MDDRActivityClass(models.Model):
name = models.CharField('Activity Class', max_length=100, unique=True)
......
<a target="_blank" class="card-link" href="https://www.ncbi.nlm.nih.gov/pubmed/{{ bibliography.id_source }}">{{ bibliography.authors_list }}. {{ authors.biblio_year }}. {{ bibliography.title }} {{ bibliography.journal_name }}. </a>
<div class="row m-2 border border-info bg-light">
<div class="col-5 bg-info">
<div id="{{ compound.id }}_smilesdisplay"
data-widget="Kekule.ChemWidget.Viewer2D" data-auto-fit="true"
data-toolbar-evoke-modes="[0]" style="width: 200px; height: 200px;">
</div>
<textarea rows="10" cols="50" id="{{ compound.id }}_smilesvalue" style="display:none;">{{ compound.canonical_smile }}</textarea>
<script>
$(window).on('load', function(){
kekule_display('{{ compound.id }}_smilesvalue','{{ compound.id }}_smilesdisplay')
});
</script>
</div>
<div class="col-7">
<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>
<p>in bibliography</p>
<ul class="list-group">
{% for biblio_ref in compound.biblio_refs %}
<li class="list-group-item">Mentionned in {% include "biblio_citation.html" with bibliography=biblio_ref.bibliography%} as <i>{{ biblio_ref.compound_name }}</i></li>
{% endfor %}
</ul>
{%if compound.pubchem_id or compound.chembl_id or compound.chemspider_id %}
<p>in other databases</p>
<ul class="list-group">
{% if compound.pubchem_id %}
<li class="list-group-item">PubChem: <a href="https://pubchem.ncbi.nlm.nih.gov/compound/{{ compound.pubchem_id }}" target="_blank">{{ compound.pubchem_id }}</a></li>
{% endif %}
{% if compound.chembl_id %}
<li class="list-group-item">ChEMBL: <a href="https://www.ebi.ac.uk/chembldb/compound/inspect/{{ compound.chembl_id}}" target="_blank">{{ compound.chembl_id}}</a></li>
{% endif %}
{% if compound.chemspider_id %}
<li class="list-group-item">ChemSpider: <a href="http://www.chemspider.com/Chemical-Structure.{{ compound.chemspider_id}}.html" target="_blank">{{ compound.chemspider_id}}</a></li>
{% endif %}
</ul>
{% endif %}
</div>
</div>
{% extends "base.html" %}
{% block title %}compound{% endblock %}
{% block content %}
{% include "kekule_display.html" %}
<div class="container-fluid">
<div class="row flex-xl-nowrap">
<div class="col-12 col-md-3 col-xl-2 bd-sidebar">
<form>
<div class="form-group row">
<div class="form-check">
{% for ppi in ppis|slice:":5" %}
<label class="form-check-label">
{{ ppi.name }}
<input class="form-check-input" type="checkbox" value="{{ ppi.id }}" onchange="this.form.submit()" name="ppi">
</label>
{% endfor %}
</div>
</div>
</form>
</div>
<main class="col-12 col-md-9 col-xl-10 py-md-3 pl-md-5 bd-content" role="main">
{% if compounds %}
{% for compound in compounds %}
{% include "compound_abstract.html" with compound=compound %}
{% endfor %}
{% else %}
<p>No bibliographies available.</p>
{% endif %}
</main>
</div>
</div>
<nav>
<ul class="pagination justify-content-end">
{% if compounds.has_previous %}
<li class="page-item">
<a class="page-link" href="?page={{ compounds.previous_page_number }}" tabindex="-1">Previous</a>
</li>
{% endif %}
<li class="page-item disabled">
<span class="page-link">Page {{ compounds.number }} of {{ compounds.paginator.num_pages }}.</span>
</li>
{% if compounds.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ compounds.next_page_number }}" tabindex="-1">Next</a>
</li>
{% endif %}
</ul>
</nav>
{% endblock %}
<script>
Kekule.Indigo.enable();
function kekule_display(smiles_id, viewer_id) {
var smi = document.getElementById(smiles_id).value;
var chemViewer = new Kekule.ChemWidget.Viewer(document.getElementById(viewer_id));
chemViewer.setEnableToolbar(false)
.setEnableDirectInteraction(false)
.setEnableEdit(false)
.setToolButtons([]);
var mol = Kekule.IO.loadFormatData(smi, "smi");
chemViewer.setChemObj(mol);
}
</script>
......@@ -21,6 +21,7 @@ urlpatterns = [
url(r'^query/chemical/$', views.chemical, name='chemical'),
url(r'^biblio/(?P<source>\w{2})(?P<id_source>\w+)$', views.biblio_card, name='biblio_card'),
url(r'^biblio/$', views.biblio_list, name='biblio_list'),
url(r'^compound/$', views.compound_list, name='compound_list'),
url(r'^tutorials$', views.tutorials, name='tutorials'),
url(r'^admin-session$', views.adminSession, name='admin-session'),
url(r'^admin-session/add/(?P<step>.+)/$',
......
......@@ -2,9 +2,11 @@ import ippidb
from django.shortcuts import render
from django.http import HttpResponseRedirect, Http404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from formtools.wizard.views import SessionWizardView, NamedUrlSessionWizardView
from .forms import BibliographyForm, PDBForm, ProteinForm, ProteinDomainComplexTypeForm, ProteinDomainComplexForm, PpiForm, ProteinFormSet
from .models import Protein, Bibliography, ProteinDomainComplex, RefCompoundBiblio, TestActivityDescription
from .models import Protein, Bibliography, ProteinDomainComplex, RefCompoundBiblio, TestActivityDescription, Compound, Ppi
from .ws import get_pdb_uniprot_mapping
......@@ -152,3 +154,18 @@ def biblio_card(request, source, id_source):
return render(request, 'biblio_card.html', {'bibliography': bibliography,
'compound_biblios': refs,
'tad_ppis': tad_ppis})
def compound_list(request):
compounds = Compound.objects.all()
paginator = Paginator(compounds, 5)
ppis = Ppi.objects.all()
page = request.GET.get('page')
try:
compounds = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
compounds = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
compounds = paginator.page(paginator.num_pages)
return render(request, 'compound_list.html', {'compounds': compounds, 'ppis': ppis})
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