Skip to content
Snippets Groups Projects
Commit 5ab2fd01 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add inhibition, stabilisation, binding role filters

see #7
parent 42dd92c0
No related branches found
No related tags found
No related merge requests found
Pipeline #8200 passed
...@@ -314,6 +314,12 @@ class CompoundManager(models.Manager): ...@@ -314,6 +314,12 @@ class CompoundManager(models.Manager):
qs = qs.annotate(pfizer=Case(When(Q(Q(a_log_p__lte=3) & Q(tpsa__gte=75)), then=True), default=False, output_field=BooleanField())) qs = qs.annotate(pfizer=Case(When(Q(Q(a_log_p__lte=3) & Q(tpsa__gte=75)), then=True), default=False, output_field=BooleanField()))
# PDB ligand available # PDB ligand available
qs = qs.annotate(pdb_ligand_av=Case(When(compoundaction__ppi__pdb_id__isnull=False, then=True), default=False, output_field=BooleanField())) qs = qs.annotate(pdb_ligand_av=Case(When(compoundaction__ppi__pdb_id__isnull=False, then=True), default=False, output_field=BooleanField()))
# inhibition role
qs = qs.annotate(inhibition_role=Case(When(compoundactivityresult__modulation_type='I', then=True), default=False, output_field=BooleanField()))
# binding role
qs = qs.annotate(binding_role=Case(When(compoundactivityresult__modulation_type='B', then=True), default=False, output_field=BooleanField()))
# stabilisation role
qs = qs.annotate(stabilisation_role=Case(When(compoundactivityresult__modulation_type='S', then=True), default=False, output_field=BooleanField()))
return qs return qs
class Compound(AutoFillableModel): class Compound(AutoFillableModel):
......
...@@ -77,6 +77,10 @@ ...@@ -77,6 +77,10 @@
</button> </button>
<div class="dropdown-menu" aria-labelledby="mmoaMenuButton"> <div class="dropdown-menu" aria-labelledby="mmoaMenuButton">
{% include "dropdown_checkbox.html" with label="PDB ligand available" param_name="pdb_ligand_av" value=pdb_ligand_av %} {% include "dropdown_checkbox.html" with label="PDB ligand available" param_name="pdb_ligand_av" value=pdb_ligand_av %}
<div class="dropdown-divider"></div>
{% include "dropdown_checkbox.html" with label="Inhibition role" param_name="inhibition_role" value=inhibition_role %}
{% include "dropdown_checkbox.html" with label="Stabilisation role" param_name="stabilisation_role" value=stabilisation_role %}
{% include "dropdown_checkbox.html" with label="Binding role" param_name="binding_role" value=binding_role %}
</div> </div>
</div> </div>
<div class="dropdown btn-group" style="display: inline-flex;"> <div class="dropdown btn-group" style="display: inline-flex;">
...@@ -152,6 +156,9 @@ ...@@ -152,6 +156,9 @@
{% include "slider_badge.html" with param_name="lle" param_value=lle param_value_min=lle_value_min param_value_max=lle_value_max param_label="LLE" %} {% include "slider_badge.html" with param_name="lle" param_value=lle param_value_min=lle_value_min param_value_max=lle_value_max param_label="LLE" %}
{% include "boolean_badge.html" with param_name="pdb_ligand_av" param_value=pdb_ligand_av label="PDB ligand available"%} {% include "boolean_badge.html" with param_name="pdb_ligand_av" param_value=pdb_ligand_av label="PDB ligand available"%}
{% include "boolean_badge.html" with param_name="inhibition_role" param_value=inhibition_role label="Inhibition role"%}
{% include "boolean_badge.html" with param_name="stabilisation_role" param_value=stabilisation_role label="Stabilisation role"%}
{% include "boolean_badge.html" with param_name="binding_role" param_value=binding_role label="Binding role"%}
{% include "selected_badge.html" with param_name="boundcomplex" values=selected_boundcomplex %} {% include "selected_badge.html" with param_name="boundcomplex" values=selected_boundcomplex %}
{% include "selected_badge.html" with param_name="family" values=selected_family %} {% include "selected_badge.html" with param_name="family" values=selected_family %}
......
...@@ -205,7 +205,7 @@ class TrueFilterHandler(FilterHandler): ...@@ -205,7 +205,7 @@ class TrueFilterHandler(FilterHandler):
if self.value: if self.value:
# filter queryset on the values being True # filter queryset on the values being True
filter_dict = { filter_dict = {
self.parameter_name: True, self.parameter_name: self.value=='true',
} }
queryset = queryset.filter(**filter_dict) queryset = queryset.filter(**filter_dict)
return queryset return queryset
...@@ -215,6 +215,34 @@ class TrueFilterHandler(FilterHandler): ...@@ -215,6 +215,34 @@ class TrueFilterHandler(FilterHandler):
pass pass
class TrueListFilterHandler(object):
def __init__(self, parameter_name_list, filter_context, request_get):
self.parameter_name_list = parameter_name_list
self.filter_context = filter_context
self.values = {}
for parameter_name in self.parameter_name_list:
if request_get.get(parameter_name):
self.values[parameter_name] = request_get.get(parameter_name).strip()
self.filter_context[parameter_name] = self.values[parameter_name]
def process(self, queryset):
""" to be called during queryset filtering """
# if a value has been set for this filter
if len(self.values)>0:
q = Q()
for parameter_name, value in self.values.items():
q = q | Q(**{parameter_name:value=='true'})
queryset = queryset.filter(q)
print(q)
return queryset
def post_process(self, compound_ids, queryset):
""" to be called after queryset filtering """
pass
class CompoundListView(ListView): class CompoundListView(ListView):
model = Compound model = Compound
...@@ -306,6 +334,7 @@ class CompoundListView(ListView): ...@@ -306,6 +334,7 @@ class CompoundListView(ListView):
CompoundSimilarityFilterHandler('similar_to', self.filter_context, self.request.GET), CompoundSimilarityFilterHandler('similar_to', self.filter_context, self.request.GET),
TextSearchFilterHandler('q', self.filter_context, self.request.GET), TextSearchFilterHandler('q', self.filter_context, self.request.GET),
TrueFilterHandler('pdb_ligand_av', self.filter_context, self.request.GET), TrueFilterHandler('pdb_ligand_av', self.filter_context, self.request.GET),
TrueListFilterHandler(['inhibition_role', 'stabilisation_role', 'binding_role'], self.filter_context, self.request.GET)
] ]
for cfh in cfhs: for cfh in cfhs:
qs = cfh.process(qs) qs = cfh.process(qs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment