diff --git a/ippisite/db.sqlite3 b/ippisite/db.sqlite3 index 8222fa0613fb7defe327ce8452ea41e836d26eeb..a2a3a8a36b19811ac48665f8b503b0b9888dadd0 100644 Binary files a/ippisite/db.sqlite3 and b/ippisite/db.sqlite3 differ diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 4606cb871805d15d12b23fad85242c26ae485e0c..65e949cfeff64cc66c94f10fce63f1e4c52af63d 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -156,6 +156,19 @@ class Ppi(models.Model): def __str__(self): return '{} PPI, PDB:{}'.format(self.symmetry.description, self.pdb_id or 'unknown') + def get_ppi_complexes(self): + """ + return all ppi complexes belonging to this ppi + """ + return PpiComplex.objects.filter(ppi=self) + + def get_ppi_bound_complexes(self): + """ + return bound ppi complexes belonging to this ppi + """ + #this is the less efficient query ever seen, FIXME + return PpiComplex.objects.filter(ppi=self, complex__in=ProteinDomainBoundComplex.objects.all()) + class PpiComplex(models.Model): ppi = models.ForeignKey(Ppi) complex = models.ForeignKey(ProteinDomainComplex) @@ -281,11 +294,14 @@ class TestActivityDescription(models.Model): cell_line = models.ForeignKey(CellLine) def get_complexes(self): - return None - # if test_modulation_type is Binding, return all bound complexes for the Ppi - # if test_modulation_type is Inhibition, return all Ppi complexes - # if test_modulation_type is Stabilization, return all bound complexes for the Ppi - # this should be added to the Ppi class as well + """ + get the complexes tested for this PPI + depends on the modulation type + """ + if self.test_modulation_type=='I': + return self.ppi.get_ppi_complexes() + else: + return self.ppi.get_ppi_bound_complexes() class CompoundActivityResult(models.Model): MODULATION_TYPES = ( @@ -364,9 +380,11 @@ class CmpdAction(models.Model): unique_together = (('ppi', 'compound', 'activation_mode', 'pdb_id'),) def get_complexes(self): - return None - # return all bound complexes for the Ppi - # this should be added to the Ppi class as well + """ + get the complexes involved in the compound action + which are always the bound complexes + """ + return ppi.get_ppi_bound_complexes() class RefCompoundBiblio(models.Model): compound = models.ForeignKey(Compound)