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

add select on bound complex to compounds list


Former-commit-id: 4519106f57e981f615014827ca5f2f841cc2f477
parent 520ded06
......@@ -163,6 +163,8 @@ class ProteinDomainComplex(models.Model):
def __str__(self):
return '{}-{}'.format(self.protein_id, self.domain_id)
def name(self):
return self.protein.short_name
class ProteinDomainBoundComplex(ProteinDomainComplex):
ppp_copy_nb_per_p = models.IntegerField(
......@@ -244,7 +246,6 @@ class PpiComplex(models.Model):
def __str__(self):
return 'PPI {}, Complex {} ({})'.format(self.ppi, self.complex, self.cc_nb)
class Compound(models.Model):
canonical_smile = models.CharField(
'Canonical Smile', unique=True, max_length=500)
......
......@@ -37,6 +37,7 @@
{% include "multiselection_list_menu.html" with label="PPI" selected_list=selected_ppis unselected_list=ppis param_name="ppi" limit_param_name="ppis_limit" limit_param_value=ppis_limit %}
{% include "multiselection_list_menu.html" with label="Disease" selected_list=selected_diseases unselected_list=diseases param_name="disease" limit_param_name="diseases_limit" limit_param_value=diseases_limit %}
{% include "multiselection_list_menu.html" with label="Organism" selected_list=selected_taxonomies unselected_list=taxonomies param_name="taxonomy" limit_param_name="taxonomies_limit" limit_param_value=taxonomies_limit %}
{% include "multiselection_list_menu.html" with label="Bound complex" selected_list=selected_boundcomplexes unselected_list=boundcomplexes param_name="boundcomplex" limit_param_name="boundcomplexes_limit" limit_param_value=boundcomplexes_limit %}
</form>
</div>
<main class="col-12 col-md-9 col-xl-10 pl-md-5 bd-content" role="main">
......
......@@ -5,7 +5,7 @@ from django.http import HttpResponseRedirect, Http404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from formtools.wizard.views import SessionWizardView, NamedUrlSessionWizardView
from .forms import IdForm, BibliographyForm, PDBForm, ProteinForm, ProteinDomainComplexTypeForm, ProteinDomainComplexForm, PpiForm, PpiComplexForm, ProteinFormSet,ActivityForm, CompoundForm, CompoundFormSet
from .models import Protein, Bibliography, ProteinDomainComplex, RefCompoundBiblio, TestActivityDescription, Compound, Ppi, Disease, Taxonomy
from .models import Protein, Bibliography, ProteinDomainComplex, ProteinDomainBoundComplex, RefCompoundBiblio, TestActivityDescription, Compound, Ppi, Disease, Taxonomy
from .ws import get_pdb_uniprot_mapping
......@@ -197,6 +197,8 @@ def compound_list(request):
compounds = compounds.filter(compoundaction__ppi__diseases__id__in=request.GET.getlist('disease'))
if request.GET.get('taxonomy'):
compounds = compounds.filter(compoundaction__ppi_id__ppicomplex__complex__protein__organism__id__in=request.GET.getlist('taxonomy'))
if request.GET.get('boundcomplexes'):
compounds = compounds.filter(compoundaction__ppi_id__ppicomplex__complex__id__in=request.GET.getlist('boundcomplex'))
try:
ppis_limit = int(request.GET.get('ppis_limit'))
except:
......@@ -209,6 +211,10 @@ def compound_list(request):
taxonomies_limit = int(request.GET.get('taxonomies_limit'))
except:
taxonomies_limit = None
try:
boundcomplexes_limit = int(request.GET.get('boundcomplexes_limit'))
except:
boundcomplexes_limit = None
selected_ppis = Ppi.objects.filter(id__in=request.GET.getlist('ppi'))
ppis = Ppi.objects.exclude(id__in=request.GET.getlist('ppi'))
if ppis_limit is not None:
......@@ -221,6 +227,10 @@ def compound_list(request):
taxonomies = Taxonomy.objects.exclude(id__in=request.GET.getlist('taxonomy'))
if taxonomies_limit is not None:
taxonomies = taxonomies[:taxonomies_limit]
selected_boundcomplexes = ProteinDomainBoundComplex.objects.filter(id__in=request.GET.getlist('boundcomplex'))
boundcomplexes = ProteinDomainBoundComplex.objects.exclude(id__in=request.GET.getlist('boundcomplex'))
if boundcomplexes_limit is not None:
boundcomplexes = boundcomplexes[:boundcomplexes_limit]
# handle pagination in compounds list
paginator = Paginator(compounds, 5)
page = request.GET.get('page')
......@@ -241,7 +251,11 @@ def compound_list(request):
'diseases_limit': ppis_limit,
'selected_taxonomies': selected_taxonomies,
'taxonomies': taxonomies,
'taxonomies_limit': taxonomies_limit})
'taxonomies_limit': taxonomies_limit,
'selected_boundcomplexes': selected_boundcomplexes,
'boundcomplexes': boundcomplexes,
'boundcomplexes_limit': boundcomplexes_limit
})
def compound_card(request, compound_id):
try:
......
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