diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 3ad79fccf5908eade1de985ba07f950ac39d2d1d..2a72dc2c06771de01e33d6f5ed5ada8e83424269 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -436,6 +436,8 @@ class CompoundManager(models.Manager): qs = qs.annotate(cytoxtest_av=Cast(Max(Case(When(refcompoundbiblio__bibliography__cytotox=True, then=1), default=0, output_field=IntegerField())), BooleanField())) # in silico st performed qs = qs.annotate(insilico_av=Cast(Max(Case(When(refcompoundbiblio__bibliography__in_silico=True, then=1), default=0, output_field=IntegerField())), BooleanField())) + # number of tests available + qs = qs.annotate(tests_av=Count('compoundactivityresult', distinct=True)) #@formatter:on return qs diff --git a/ippisite/ippidb/templates/compound_t_list.html b/ippisite/ippidb/templates/compound_t_list.html index 770f2c53f658e4d5520346f9a1c975884cd35d7f..7c40f7ddae0b191640b7ccb1b7f895567387ad08 100644 --- a/ippisite/ippidb/templates/compound_t_list.html +++ b/ippisite/ippidb/templates/compound_t_list.html @@ -46,7 +46,7 @@ <td scope="col">{{ compound.pubs }}</td> {% endif %} {% if "available_tests" in fields %} - <td scope="col">{{ compound.compoundactivityresult_set.count }}</td> + <td scope="col">{{ compound.tests_av }}</td> {% endif %} {% if "compound_action_ligand_ids" in fields %} <td scope="col"> diff --git a/ippisite/ippidb/views/compound_query.py b/ippisite/ippidb/views/compound_query.py index 4462b28a8f4013923238cdd07cfeba54792099d2..2c1897cedde26858aed6908692f47fccddfeff5c 100644 --- a/ippisite/ippidb/views/compound_query.py +++ b/ippisite/ippidb/views/compound_query.py @@ -391,7 +391,7 @@ class CompoundListView(ListView): table_view_default_fields = ['id', 'canonical_smiles', 'common_name', 'molecular_weight', 'a_log_p', 'compound_action_ligand_ids', 'pubs'] - sort_by_option_ids = ['id', 'molecular_weight', 'a_log_p', 'nb_aromatic_sssr', 'nb_chiral_centers', 'pubs', 'le', 'lle', 'best_activity'] + sort_by_option_ids = ['id', 'molecular_weight', 'a_log_p', 'nb_aromatic_sssr', 'nb_chiral_centers', 'pubs', 'le', 'lle', 'best_activity', 'tests_av'] def get_ordering(self): # sort by options @@ -406,6 +406,8 @@ class CompoundListView(ListView): name = 'Lipophilic Efficiency' elif sort_by_option_id == 'best_activity': name = 'Best Activity' + elif sort_by_option_id == 'tests_av': + name = 'Number of tests available' else: name = compound_fields.get(sort_by_option_id) self.sort_by_options[sort_by_option_id] = {'name': name, 'order': 'ascending', 'id': sort_by_option_id}