diff --git a/ippisite/ippidb/management/commands/lle_le.py b/ippisite/ippidb/management/commands/lle_le.py index 9eeec9166fa1f76ea4887c80417f18755244b253..8b87716aec706faef21b07c9453d9cc2a2e1a965 100644 --- a/ippisite/ippidb/management/commands/lle_le.py +++ b/ippisite/ippidb/management/commands/lle_le.py @@ -11,7 +11,9 @@ class Command(BaseCommand): def handle(self, *args, **options): self.stdout.write(self.style.SUCCESS('Generating the LE vs. LLE biplot...')) - df = Compound.objects.all().to_dataframe() - df['le']=df[ - print(df.to_csv()) - print(df.columns) + for comp in Compound.objects.all(): + print(comp.id, comp.le, comp.lle) + #df = Compound.objects.all().to_dataframe() + #df['le']=df[ + #print(df.to_csv()) + #print(df.columns) diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index 30eb12ca08a6e80df4aa7e1a6c100822be1455e3..5a1495d024680558002b6892f81a59a386a8411a 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -154,6 +154,46 @@ </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"> + <h5 class="card-header">Efficiencies: iPPI-DB biplot LE versus LLE</h5> + <div class="card-body"> + + <canvas id="le_lle_biplot"></canvas> + <script> + var scatterData = { + 'datasets': [ + { label: 'Other PPI families', + borderColor: "rgba(211,211,211, 0.8)", + backgroundColor: "rgba(211,211,211, 0.8)", + data:[ + {% for c in all_compounds %} + {x: {{ c.le }}, y: {{ c.lle }}, id: {{ c.id }} }, + {% endfor %} + ] + } + ]}; + var ctx = document.getElementById('le_lle_biplot').getContext('2d'); + var scatterChart = new Chart(ctx, { + type: 'scatter', + data: scatterData, + options: { + scales: { + xAxes: [{ + type: 'linear', + position: 'bottom' + }] + } + } + }); + document.getElementById('le_lle_biplot').onclick = function(evt){ + var activePoints = scatterChart.getElementAtEvent(evt); + var selectedIndex = activePoints[0]._index; + var id = scatterChart.data.datasets[0].data[selectedIndex].id; + window.location = '/compound/'+id; + }; + </script> + </div> + </div> </div> <div class="tab-pane fade" id="v-pills-drugsimilarity" role="tabpanel" aria-labelledby="v-pills-drugsimilarity-tab"> </div> diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index 923955e731909e60704b425dbd6767cdcd1c078a..04b2f150761349be1ca53e46b19e8bcbe1666862 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -235,6 +235,7 @@ def compound_list(request): def compound_card(request, compound_id): try: compound = Compound.objects.get(id=int(compound_id)) + all_compounds = Compound.objects.all() except Compound.DoesNotExist: raise Http404("No compound data for %s:%s" % (compound_id)) - return render(request, 'compound_card.html', {'compound': compound}) + return render(request, 'compound_card.html', {'compound': compound, 'all_compounds': all_compounds})