From 390ca7c0416e3cf44783d47d4720a12872a60bee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Fri, 19 May 2017 14:38:49 +0200
Subject: [PATCH] pockets_nb is a property of the PPI, not the complex

change data model and migration script
---
 ippisite/ippidb/management/commands/import_v1_data.py | 2 +-
 ippisite/ippidb/models.py                             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ippisite/ippidb/management/commands/import_v1_data.py b/ippisite/ippidb/management/commands/import_v1_data.py
index acbf3758..cf14e8eb 100644
--- a/ippisite/ippidb/management/commands/import_v1_data.py
+++ b/ippisite/ippidb/management/commands/import_v1_data.py
@@ -175,6 +175,7 @@ select distinct protein.NumUniprot, domain.PfamNumAccession  , complexe.NbCopy,
                         ppi = Ppi()
                         disease, created = Disease.objects.get_or_create(name=row[7])
                         ppi.pdb_id = row[4]
+                        ppi.pockets_nb = 1
                         ppi.symmetry = Symmetry.objects.get(code='AS')
                         ppi.save()
                         ppi.diseases.add(disease)
@@ -194,7 +195,6 @@ select distinct protein.NumUniprot, domain.PfamNumAccession  , complexe.NbCopy,
                     c.ppc_copy_nb = row[2]
                     if isinstance(c, ProteinDomainBoundComplex):
                         c.ppp_copy_nb_per_p = 1
-                        c.pockets_nb = 1
                     c.save()
                     # create the PpiComplex object
                     ppi_complex = PpiComplex()
diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py
index b47f5943..5678657f 100644
--- a/ippisite/ippidb/models.py
+++ b/ippisite/ippidb/models.py
@@ -131,7 +131,6 @@ class ProteinDomainComplex(models.Model):
 
 class ProteinDomainBoundComplex(ProteinDomainComplex):
     ppp_copy_nb_per_p = models.IntegerField('Number of copies of the protein in the pocket')
-    pockets_nb = models.IntegerField('Total number of pockets in the complex')
     class Meta:
         verbose_name_plural = "bound complexes"
     
@@ -158,6 +157,7 @@ class Disease(models.Model):
 
 class Ppi(models.Model):
     pdb_id = models.CharField('PDB ID', max_length=4, null=True)
+    pockets_nb = models.IntegerField('Total number of pockets in the complex', default=1)
     symmetry = models.ForeignKey(Symmetry)
     diseases = models.ManyToManyField(Disease)
 
-- 
GitLab