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

filter LE-LLE biplot data for only pXC50 activity results

and try to take into account if no data for this activity


Former-commit-id: 62ae7b8832a9bd9e372ff59c43a6ef2dfcaa329f
parent fee32463
No related branches found
No related tags found
No related merge requests found
484ef6ada16ce17d584108ab14d1ec6467385442 b5ded9e1a05b9a0751e6d1addad0faf88524c8ca
\ No newline at end of file \ No newline at end of file
...@@ -15,14 +15,19 @@ class Command(BaseCommand): ...@@ -15,14 +15,19 @@ class Command(BaseCommand):
le_lle_data = [] le_lle_data = []
LeLleBiplotData.objects.all().delete() LeLleBiplotData.objects.all().delete()
self.stdout.write( self.stdout.write(
self.style.SUCCESS('Successfully flushed LE-LLE biplot data table')) self.style.SUCCESS('Successfully flushed LE-LLE biplot data'))
for comp in Compound.objects.all(): for comp in Compound.objects.all():
print(comp.id) if comp.le is not None:
le = round(comp.le, 7) le = round(comp.le, 7)
lle = round(comp.lle, 7) lle = round(comp.lle, 7)
le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family_name': comp.best_activity_ppi_name}) le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family_name': comp.best_pXC50_activity_ppi_name})
else:
self.stdout.write(
self.style.WARNING('compound %s has no LE (probably because no pXC50 activity results have been registered)' % comp.id))
le_lle_json = json.dumps(le_lle_data, separators=(',',':')) le_lle_json = json.dumps(le_lle_data, separators=(',',':'))
new = LeLleBiplotData() new = LeLleBiplotData()
new.le_lle_biplot_data = le_lle_json new.le_lle_biplot_data = le_lle_json
new.save() new.save()
self.stdout.write(
self.style.SUCCESS('Successfully generated LE-LLE biplot data'))
print(len(le_lle_json)) print(len(le_lle_json))
...@@ -408,27 +408,45 @@ class Compound(models.Model): ...@@ -408,27 +408,45 @@ class Compound(models.Model):
def pfizer_global(self): def pfizer_global(self):
return self.pfizer_a_log_p and self.pfizer_tpsa return self.pfizer_a_log_p and self.pfizer_tpsa
@property
def best_pXC50_activity(self):
return self.compoundactivityresult_set.filter(activity_type__in=['pIC50','pEC50']).aggregate(Max('activity'))['activity__max']
@property
def best_pXC50_compound_activity_result(self):
best_pXC50_activity = self.best_pXC50_activity
if best_pXC50_activity is None:
return None
return self.compoundactivityresult_set.filter(activity_type__in=['pIC50','pEC50'], activity=best_pXC50_activity)[0]
@property @property
def le(self): def le(self):
""" """
LE: Ligand Efficiency LE: Ligand Efficiency
""" """
return (1.37 * float(self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max']))/self.nb_atom_non_h best_pXC50_activity = self.best_pXC50_activity
if best_pXC50_activity is None:
return None
return (1.37 * float(best_pXC50_activity))/self.nb_atom_non_h
@property @property
def lle(self): def lle(self):
""" """
LLE: Lipophilic Efficiency LLE: Lipophilic Efficiency
""" """
return float(self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max'] - self.a_log_p) best_pXC50_activity = self.best_pXC50_activity
if best_pXC50_activity is None:
return None
return float(best_pXC50_activity - self.a_log_p)
@property @property
def best_activity_ppi_name(self): def best_pXC50_activity_ppi_name(self):
""" """
LE: Ligand Efficiency LE: Ligand Efficiency
""" """
best_activity = self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max'] best_activity_car = self.best_pXC50_compound_activity_result
best_activity_car = self.compoundactivityresult_set.filter(activity=best_activity)[0] if best_activity_car is None:
return None
ppi_name = best_activity_car.test_activity_description.ppi.name ppi_name = best_activity_car.test_activity_description.ppi.name
return ppi_name return ppi_name
......
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
<div class="card-body"> <div class="card-body">
<canvas id="le_lle_biplot"></canvas> <canvas id="le_lle_biplot"></canvas>
<script> <script>
drawLeLleBiplotChart('le_lle_biplot', {{ compound.id }}, '{{ compound.best_activity_ppi_name }}', {{ biplot_data | safe }}) drawLeLleBiplotChart('le_lle_biplot', {{ compound.id }}, '{{ compound.best_pXC50_activity_ppi_name|default_if_none:"No target family identified" }}', {{ biplot_data | safe }})
</script> </script>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment