From 11b2efc0d9b59d1f80e839568ba12968423ff392 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Wed, 2 May 2018 22:37:45 +0200
Subject: [PATCH] finish adding PPI families to the vignette and LE/LLE plot

(closes #55)


Former-commit-id: 4bf4c7d44a0961955e7a196bdad6c4d18f862582
---
 ippisite/db.sqlite3.REMOVED.git-id             |  2 +-
 ippisite/ippidb/management/commands/lle_le.py  |  2 +-
 ippisite/ippidb/models.py                      | 11 +++++++++++
 ippisite/ippidb/templates/compound_card.html   |  2 +-
 ippisite/ippidb/templates/compound_v_item.html |  2 +-
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/ippisite/db.sqlite3.REMOVED.git-id b/ippisite/db.sqlite3.REMOVED.git-id
index 406ad56a..0fc6bb90 100644
--- a/ippisite/db.sqlite3.REMOVED.git-id
+++ b/ippisite/db.sqlite3.REMOVED.git-id
@@ -1 +1 @@
-f9381e78efb52e844670bc977d0f99461134ee9d
\ No newline at end of file
+5fb9ed7a41b37ceaa343fd897c2db6c4123dfea8
\ 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 12f59779..40281855 100644
--- a/ippisite/ippidb/management/commands/lle_le.py
+++ b/ippisite/ippidb/management/commands/lle_le.py
@@ -20,7 +20,7 @@ class Command(BaseCommand):
             if comp.le is not None:
                 le = round(comp.le, 7)
                 lle = round(comp.lle, 7)
-                le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family_name': comp.best_pXC50_activity_ppi_name})
+                le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family_name': comp.best_pXC50_activity_ppi_family})
             else:
                 self.stdout.write(
                     self.style.WARNING('compound %s has no LE (probably because no pXC50 activity results have been registered)' % comp.id))
diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py
index 1838e18f..e2dce821 100644
--- a/ippisite/ippidb/models.py
+++ b/ippisite/ippidb/models.py
@@ -457,6 +457,17 @@ class Compound(models.Model):
         ppi_name = best_activity_car.test_activity_description.ppi.name
         return ppi_name
 
+    @property
+    def best_pXC50_activity_ppi_family(self):
+        """
+        Family of the PPI corresponding to the best PXC50 activity
+        """
+        best_activity_car = self.best_pXC50_compound_activity_result
+        if best_activity_car is None:
+            return None
+        ppi_family = best_activity_car.test_activity_description.ppi.family.name
+        return ppi_family
+
     @property
     def bioch_tests_count(self):
         """
diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html
index 38e825fa..11f7f311 100644
--- a/ippisite/ippidb/templates/compound_card.html
+++ b/ippisite/ippidb/templates/compound_card.html
@@ -165,7 +165,7 @@
               <div class="card-body">
               <canvas id="le_lle_biplot"></canvas>
               <script>
-                drawLeLleBiplotChart('le_lle_biplot', {{ compound.id }}, '{{ compound.best_pXC50_activity_ppi_name|default_if_none:"No target family identified" }}', {{ biplot_data | safe }}, 'pharmacology');
+                drawLeLleBiplotChart('le_lle_biplot', {{ compound.id }}, '{{ compound.best_pXC50_activity_ppi_family|default_if_none:"No target family identified" }}', {{ biplot_data | safe }}, 'pharmacology');
               </script>
             </div>
             </div>
diff --git a/ippisite/ippidb/templates/compound_v_item.html b/ippisite/ippidb/templates/compound_v_item.html
index 5beb76ad..dd713701 100644
--- a/ippisite/ippidb/templates/compound_v_item.html
+++ b/ippisite/ippidb/templates/compound_v_item.html
@@ -2,7 +2,7 @@
         <a href="/compound/{{ compound.id }}">{% include "pubchem_img.html" %}</a>
         <div class="card-body" style="overflow:hidden; word-wrap:break-word;">
             <span class="badge badge-dark"><a href="/compound/{{ compound.id }}">{{ compound.id }}</a></span>
-            <p>{% for family in compound.families %}{{ family.name }}{% endfor %}</p>
+            <p>{{ compound.best_pXC50_activity_ppi_family }}</p>
             <p>Molecular Weight: {{ compound.molecular_weight }} g/mol</p>
         </div>
 </div>
-- 
GitLab