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

add filters in compounds list for Best Activity, LE, LLE

Former-commit-id: e6e8c1065d9526fb8cc9fcc52dc9e347a7ea0002
parent 3b7fd325
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,9 @@
Activity and Efficiencies
</button>
<div class="dropdown-menu" aria-labelledby="aeMenuButton">
{% include "modal_open_button.html" with label="Best Activity" param_name="qs_ba" %}
{% include "modal_open_button.html" with label="LE" param_name="qs_le" %}
{% include "modal_open_button.html" with label="LLE" param_name="qs_lle" %}
</div>
</div>
<div class="dropdown btn-group" style="display: inline-flex;">
......@@ -114,7 +117,7 @@
<div class="m-2 d-flex justify-content-between">
<span>{{ paginator.count }} compounds</span>
{% if selected_family or selected_ppi or selected_disease or selected_taxonomy or selected_boundcomplex or molecular_weight or a_log_p or nb_donor_h or nb_acceptor_h or tpsa or nb_rotatable_bonds or nb_aromatic_sssr or nb_chiral_centers or fsp3 or pubs or similar_to %}
{% if selected_family or selected_ppi or selected_disease or selected_taxonomy or selected_boundcomplex or molecular_weight or a_log_p or nb_donor_h or nb_acceptor_h or tpsa or nb_rotatable_bonds or nb_aromatic_sssr or nb_chiral_centers or fsp3 or pubs or similar_to or qs_ba or qs_le or qs_lle %}
<span>
&nbsp;-&nbsp;filters:&nbsp;
{% if selected_family %}
......@@ -172,6 +175,15 @@
{% if similar_to %}
{% include "similarity_badge.html" with param_name="similar_to" param_value=similar_to_query param_label="Similar to " %}
{% endif %}
{% if qs_ba %}
{% include "slider_badge.html" with param_name="qs_ba" param_value_min=qs_ba_value_min param_value_max=qs_ba_value_max param_label="Best Act." %}
{% endif %}
{% if qs_le %}
{% include "slider_badge.html" with param_name="qs_le" param_value_min=qs_le_value_min param_value_max=qs_le_value_max param_label="LE" %}
{% endif %}
{% if qs_lle %}
{% include "slider_badge.html" with param_name="qs_lle" param_value_min=qs_lle_value_min param_value_max=qs_lle_value_max param_label="LLE" %}
{% endif %}
</span>
{% endif %}
<div class="m-1 ml-auto">
......@@ -241,5 +253,8 @@
{% include "slider_modal.html" with label="FSP3" param_name="fsp3" param_min=fsp3_min param_max=fsp3_max param_value=fsp3 param_value_min=fsp3_value_min param_value_max=fsp3_value_max step='1' param_label='Select a cutoff value for the FSP3 of the compounds to be selected'%}
{% include "slider_modal.html" with label="Publications" param_name="pubs" param_min=pubs_min param_max=pubs_max param_value=pubs param_value_min=pubs_value_min param_value_max=pubs_value_max step='1' param_label='Select a cutoff value for the number of publications mentioning the compounds to be selected'%}
{% include "marvinjs_modal.html" with smiles=similar_to_query fingerprint=similar_to_fingerprint %}
{% include "slider_modal.html" with label="Best Activiry" param_name="qs_ba" param_min=qs_ba_min param_max=qs_ba_max param_value=qs_ba param_value_min=qs_ba_value_min param_value_max=qs_ba_value_max step='1' param_label='Select a cutoff value for the best activity of the compounds to be selected'%}
{% include "slider_modal.html" with label="LE" param_name="qs_le" param_min=qs_le_min param_max=qs_le_max param_value=qs_le param_value_min=qs_le_value_min param_value_max=qs_le_value_max step='1' param_label='Select a cutoff value for the LE of the compounds to be selected'%}
{% include "slider_modal.html" with label="LLE" param_name="qs_lle" param_min=qs_lle_min param_max=qs_lle_max param_value=qs_lle param_value_min=qs_lle_value_min param_value_max=qs_lle_value_max step='1' param_label='Select a cutoff value for the LLE of the compounds to be selected'%}
{% endblock %}
......@@ -278,8 +278,19 @@ class CompoundRangeFilterHandler(object):
queryset = queryset.filter(**filter_dict)
# max and min value are the max and min for
qs = Compound.objects
# annotate
# with number of publications
if self.parameter_name == 'pubs':
qs = qs.annotate(pubs=Count('refcompoundbiblio', distinct=True))
qs = qs.annotate(pubs=Count('refcompoundbiblio', distinct=True))
# with best activity
elif self.parameter_name == 'qs_ba':
qs = qs.annotate(qs_ba=Max('compoundactivityresult__activity'))
# with LE
elif self.parameter_name == 'qs_le':
qs = qs.annotate(qs_le=Cast(1.37 * Max('compoundactivityresult__activity') / F('nb_atom_non_h'),FloatField()))
# with LLE
elif self.parameter_name == 'qs_lle':
qs = qs.annotate(qs_lle=Cast(Max('compoundactivityresult__activity') - F('a_log_p'),FloatField()))
self.filter_context[self.parameter_name+'_max'] = str(int(math.ceil(float(qs.aggregate(Max(self.parameter_name))[self.parameter_name + '__max'] or 0))))
self.filter_context[self.parameter_name+'_min'] = str(int(math.floor(float(qs.aggregate(Min(self.parameter_name))[self.parameter_name + '__min'] or 0))))
return queryset
......@@ -290,6 +301,7 @@ class CompoundRangeFilterHandler(object):
if not self.value:
self.filter_context[self.parameter_name+'_max'] = str(int(math.ceil(float(queryset.aggregate(Max(self.parameter_name))[self.parameter_name + '__max'] or 0))))
self.filter_context[self.parameter_name+'_min'] = str(int(math.floor(float(queryset.aggregate(Min(self.parameter_name))[self.parameter_name + '__min'] or 0))))
print(self.parameter_name, self.filter_context[self.parameter_name+'_min'], self.filter_context[self.parameter_name+'_max'])
class CompoundListView(ListView):
......@@ -378,6 +390,9 @@ class CompoundListView(ListView):
CompoundRangeFilterHandler('nb_chiral_centers', self.filter_context, self.request.GET),
CompoundRangeFilterHandler('fsp3', self.filter_context, self.request.GET),
CompoundRangeFilterHandler('pubs', self.filter_context, self.request.GET),
CompoundRangeFilterHandler('qs_ba', self.filter_context, self.request.GET),
CompoundRangeFilterHandler('qs_le', self.filter_context, self.request.GET),
CompoundRangeFilterHandler('qs_lle', self.filter_context, self.request.GET),
CompoundSimilarityFilterHandler('similar_to', self.filter_context, self.request.GET),
TextSearchFilterHandler('q', self.filter_context, self.request.GET),
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment