Commit 1b887715 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

code gardening in models


Former-commit-id: 1a77fa40743d91a6e6e19eea5d497cede393f08b
parent 9179cf76
......@@ -87,7 +87,7 @@ class Taxonomy(AutoFillableModel):
class MolecularFunction(AutoFillableModel):
go_id = models.CharField('Gene Ontology ID', unique=True, max_length=10)
# GO term id format: 'GO:0000000'
# GO term id format: 'GO:0000000'
description = models.CharField('description', max_length=500)
def autofill(self):
......@@ -140,8 +140,8 @@ class Domain(AutoFillableModel):
pfam_id = models.CharField('Pfam Family Identifier', max_length=20)
pfam_description = models.CharField('Pfam Description', max_length=100)
domain_family = models.CharField('Domain family', max_length=25)
# TODO: what is this field? check database
# contents
# TODO: what is this field? check database
# contents
def autofill(self):
info = get_pfam_info(self.pfam_acc)
......@@ -195,11 +195,12 @@ class Symmetry(models.Model):
class Disease(models.Model):
name = models.CharField('Disease', max_length=30, unique=True)
# is there any database/nomenclature for diseases?
# is there any database/nomenclature for diseases?
def __str__(self):
return self.name
class PpiFamily(models.Model):
name = models.CharField('Name', max_length=30, unique=True)
......@@ -209,6 +210,7 @@ class PpiFamily(models.Model):
def __str__(self):
return self.name
class Ppi(models.Model):
pdb_id = models.CharField('PDB ID', max_length=4, null=True)
pockets_nb = models.IntegerField(
......@@ -235,16 +237,19 @@ class Ppi(models.Model):
@property
def name(self):
all_protein_names = set([ppi_complex.complex.protein.short_name for ppi_complex in self.get_ppi_complexes()])
bound_protein_names = set([ppi_complex.complex.protein.short_name for ppi_complex in self.get_ppi_bound_complexes()])
all_protein_names = set(
[ppi_complex.complex.protein.short_name for ppi_complex in self.get_ppi_complexes()])
bound_protein_names = set(
[ppi_complex.complex.protein.short_name for ppi_complex in self.get_ppi_bound_complexes()])
partner_protein_names = all_protein_names - bound_protein_names
bound_str = ','.join(bound_protein_names)
partner_str = ','.join(partner_protein_names)
name = bound_str
if partner_str!='':
if partner_str != '':
name += ' / ' + partner_str
return name
class PpiComplex(models.Model):
ppi = models.ForeignKey(Ppi, models.CASCADE)
complex = models.ForeignKey(ProteinDomainComplex, models.CASCADE)
......@@ -257,6 +262,7 @@ class PpiComplex(models.Model):
def __str__(self):
return 'PPI {}, Complex {} ({})'.format(self.ppi, self.complex, self.cc_nb)
class Compound(models.Model):
canonical_smile = models.CharField(
'Canonical Smile', unique=True, max_length=500)
......@@ -444,7 +450,7 @@ class Compound(models.Model):
best_pXC50_activity = self.best_pXC50_activity
if best_pXC50_activity is None:
return None
return float(best_pXC50_activity - self.a_log_p)
return float(best_pXC50_activity - self.a_log_p)
@property
def best_pXC50_activity_ppi_name(self):
......@@ -491,10 +497,14 @@ class Compound(models.Model):
class PcaBiplotData(models.Model):
pca_biplot_data = models.CharField('PCA biplot JSON data', max_length=150000, blank=True, null=True)
pca_biplot_data = models.CharField(
'PCA biplot JSON data', max_length=150000, blank=True, null=True)
class LeLleBiplotData(models.Model):
le_lle_biplot_data = models.CharField('LE-LLE biplot JSON data', max_length=150000, blank=True, null=True)
le_lle_biplot_data = models.CharField(
'LE-LLE biplot JSON data', max_length=150000, blank=True, null=True)
class MDDRActivityClass(models.Model):
name = models.CharField('Activity Class', max_length=100, unique=True)
......@@ -581,17 +591,20 @@ class TestActivityDescription(models.Model):
('U', 'Unspecified')
)
biblio = models.ForeignKey(Bibliography, models.CASCADE)
protein_domain_bound_complex = models.ForeignKey(ProteinDomainBoundComplex, models.CASCADE)
protein_domain_bound_complex = models.ForeignKey(
ProteinDomainBoundComplex, models.CASCADE)
ppi = models.ForeignKey(Ppi, models.CASCADE, blank=True, null=True)
test_name = models.CharField('Test name', max_length=100)
is_primary = models.BooleanField('Is primary')
protein_bound_construct = models.CharField('Protein bound construct', max_length=5, choices=PROTEIN_BOUND_CONSTRUCTS, blank=True, null=True)
protein_bound_construct = models.CharField(
'Protein bound construct', max_length=5, choices=PROTEIN_BOUND_CONSTRUCTS, blank=True, null=True)
test_type = models.CharField('Test type', max_length=5, choices=TEST_TYPES)
test_modulation_type = models.CharField(
'Test modulation type', max_length=1, choices=TEST_MODULATION_TYPES)
nb_active_compounds = models.IntegerField(
'Total number of active compounds')
cell_line = models.ForeignKey(CellLine, models.CASCADE, blank=True, null=True)
cell_line = models.ForeignKey(
CellLine, models.CASCADE, blank=True, null=True)
def get_complexes(self):
"""
......@@ -606,7 +619,7 @@ class TestActivityDescription(models.Model):
@property
def protein_domain_partner_complex(self):
for ppic in self.ppi.ppicomplex_set.all():
if hasattr(ppic.complex,'proteindomainpartnercomplex'):
if hasattr(ppic.complex, 'proteindomainpartnercomplex'):
return ppic.complex.proteindomainpartnercomplex
return None
......@@ -624,7 +637,8 @@ class CompoundActivityResult(models.Model):
('pKi', 'pKi (inhibition constant, -log10)'),
)
compound = models.ForeignKey(Compound, models.CASCADE)
test_activity_description = models.ForeignKey(TestActivityDescription, models.CASCADE)
test_activity_description = models.ForeignKey(
TestActivityDescription, models.CASCADE)
activity_type = models.CharField(
'Activity type', max_length=5, choices=ACTIVITY_TYPES)
activity = models.DecimalField(
......@@ -644,6 +658,7 @@ class CompoundActivityResult(models.Model):
def is_best(self):
return self.compound.best_pXC50_compound_activity_result.id == self.id
class TestCytotoxDescription(models.Model):
biblio = models.ForeignKey(Bibliography, models.CASCADE)
test_name = models.CharField('Cytotoxicity test name', max_length=100)
......@@ -654,7 +669,8 @@ class TestCytotoxDescription(models.Model):
class CompoundCytotoxicityResult(models.Model):
compound = models.ForeignKey(Compound, models.CASCADE)
test_cytotoxicity_description = models.ForeignKey(TestCytotoxDescription, models.CASCADE)
test_cytotoxicity_description = models.ForeignKey(
TestCytotoxDescription, models.CASCADE)
toxicity = models.BooleanField('Toxicity', default=False)
class Meta:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment