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

add "compound target family" to the LE-LLE plot

Former-commit-id: a8980972bc9fdf6728a1b910230b59734d4311ff
parent 3e2b9dd3
No related branches found
No related tags found
No related merge requests found
8e1155c407f37772a3cec105df9f551c3bbe8232 484ef6ada16ce17d584108ab14d1ec6467385442
\ No newline at end of file \ No newline at end of file
...@@ -17,9 +17,10 @@ class Command(BaseCommand): ...@@ -17,9 +17,10 @@ class Command(BaseCommand):
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 table'))
for comp in Compound.objects.all(): for comp in Compound.objects.all():
print(comp.id)
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':'TBD'}) le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family_name': comp.best_activity_ppi_name})
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
......
...@@ -422,6 +422,16 @@ class Compound(models.Model): ...@@ -422,6 +422,16 @@ class Compound(models.Model):
""" """
return float(self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max'] - self.a_log_p) return float(self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max'] - self.a_log_p)
@property
def best_activity_ppi_name(self):
"""
LE: Ligand Efficiency
"""
best_activity = self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max']
best_activity_car = self.compoundactivityresult_set.filter(activity=best_activity)[0]
ppi_name = best_activity_car.test_activity_description.ppi.name
return ppi_name
class LeLleBiplotData(models.Model): class LeLleBiplotData(models.Model):
le_lle_biplot_data = models.CharField('LE-LLE biplot JSON data', max_length=150000, blank=True, null=True) le_lle_biplot_data = models.CharField('LE-LLE biplot JSON data', max_length=150000, blank=True, null=True)
......
...@@ -154,18 +154,41 @@ ...@@ -154,18 +154,41 @@
</div> </div>
</div> </div>
<div class="tab-pane fade" id="v-pills-pharmacology" role="tabpanel" aria-labelledby="v-pills-pharmacology-tab"> <div class="tab-pane fade" id="v-pills-pharmacology" role="tabpanel" aria-labelledby="v-pills-pharmacology-tab">
<div class="card col-sm-12 col-md-6"> <div class="card col-sm-12 col-md-12">
<h5 class="card-header">Efficiencies: iPPI-DB biplot LE versus LLE</h5> <h5 class="card-header">Efficiencies: iPPI-DB biplot LE versus LLE</h5>
<div class="card-body"> <div class="card-body">
<canvas id="le_lle_biplot"></canvas> <canvas id="le_lle_biplot"></canvas>
<script> <script>
var allData = {{ biplot_data | safe }};
var currentCompoundData = [];
var currentFamilyData = [];
var otherFamiliesData = [];
allData.forEach((item) => {
if(item.id == {{ compound.id }}){
currentCompoundData.push(item);
}else if(item.family_name == '{{ compound.best_activity_ppi_name}}'){
currentFamilyData.push(item);
}else{
otherFamiliesData.push(item)
}
});
var scatterData = { var scatterData = {
'datasets': [ 'datasets': [
{ label: 'Other PPI families', { label: 'Other PPI families',
borderColor: "rgba(211,211,211, 0.8)", borderColor: "rgba(211,211,211, 0.5)",
backgroundColor: "rgba(211,211,211, 0.8)", backgroundColor: "rgba(211,211,211, 0.5)",
data: {{ biplot_data | safe }} data: otherFamiliesData
},
{ label: '{{ compound.best_activity_ppi_name}} family',
borderColor: "rgba(54, 162, 235, 1)",
backgroundColor: "rgba(54, 162, 235, 0.5)",
data: currentFamilyData
},
{ label: 'Compound',
borderColor: "rgba(0, 17, 250, 1)",
backgroundColor: "rgba(0, 17, 250, 0.5)",
data: currentCompoundData
} }
]}; ]};
var ctx = document.getElementById('le_lle_biplot').getContext('2d'); var ctx = document.getElementById('le_lle_biplot').getContext('2d');
......
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