diff --git a/ippisite/db.sqlite3.REMOVED.git-id b/ippisite/db.sqlite3.REMOVED.git-id index 6947594a004734b22c1379e7cd8508df245fdf87..5e100e09278b7714ed0dbcffa669c581934849af 100644 --- a/ippisite/db.sqlite3.REMOVED.git-id +++ b/ippisite/db.sqlite3.REMOVED.git-id @@ -1 +1 @@ -8e1155c407f37772a3cec105df9f551c3bbe8232 \ No newline at end of file +484ef6ada16ce17d584108ab14d1ec6467385442 \ No newline at end of file diff --git a/ippisite/ippidb/management/commands/lle_le.py b/ippisite/ippidb/management/commands/lle_le.py index 6a0d08c8e740fbdab4aed42ca712fcb87301db94..2e04f1cf9cae7560c1624916c78a461d48707ef8 100644 --- a/ippisite/ippidb/management/commands/lle_le.py +++ b/ippisite/ippidb/management/commands/lle_le.py @@ -17,9 +17,10 @@ class Command(BaseCommand): self.stdout.write( self.style.SUCCESS('Successfully flushed LE-LLE biplot data table')) for comp in Compound.objects.all(): + print(comp.id) le = round(comp.le, 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=(',',':')) new = LeLleBiplotData() new.le_lle_biplot_data = le_lle_json diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 0cc0f182e05f4e4eecd8077f942649e32476930f..787862e2bb90e7875fbfea80f3aeff4d5364d69b 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -422,6 +422,16 @@ class Compound(models.Model): """ 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): le_lle_biplot_data = models.CharField('LE-LLE biplot JSON data', max_length=150000, blank=True, null=True) diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index 24f97c84374811b0e430923666a6fdeb84f8fd9a..8ba957c4c3d5d0606b89a40e5106719faa582db3 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -154,18 +154,41 @@ </div> </div> <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> <div class="card-body"> <canvas id="le_lle_biplot"></canvas> <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 = { 'datasets': [ { label: 'Other PPI families', - borderColor: "rgba(211,211,211, 0.8)", - backgroundColor: "rgba(211,211,211, 0.8)", - data: {{ biplot_data | safe }} + borderColor: "rgba(211,211,211, 0.5)", + backgroundColor: "rgba(211,211,211, 0.5)", + 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');