Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
1b887715
Commit
1b887715
authored
6 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
code gardening in models
Former-commit-id: 1a77fa40743d91a6e6e19eea5d497cede393f08b
parent
9179cf76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/models.py
+32
-16
32 additions, 16 deletions
ippisite/ippidb/models.py
with
32 additions
and
16 deletions
ippisite/ippidb/models.py
+
32
−
16
View file @
1b887715
...
@@ -87,7 +87,7 @@ class Taxonomy(AutoFillableModel):
...
@@ -87,7 +87,7 @@ class Taxonomy(AutoFillableModel):
class
MolecularFunction
(
AutoFillableModel
):
class
MolecularFunction
(
AutoFillableModel
):
go_id
=
models
.
CharField
(
'
Gene Ontology ID
'
,
unique
=
True
,
max_length
=
10
)
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
)
description
=
models
.
CharField
(
'
description
'
,
max_length
=
500
)
def
autofill
(
self
):
def
autofill
(
self
):
...
@@ -140,8 +140,8 @@ class Domain(AutoFillableModel):
...
@@ -140,8 +140,8 @@ class Domain(AutoFillableModel):
pfam_id
=
models
.
CharField
(
'
Pfam Family Identifier
'
,
max_length
=
20
)
pfam_id
=
models
.
CharField
(
'
Pfam Family Identifier
'
,
max_length
=
20
)
pfam_description
=
models
.
CharField
(
'
Pfam Description
'
,
max_length
=
100
)
pfam_description
=
models
.
CharField
(
'
Pfam Description
'
,
max_length
=
100
)
domain_family
=
models
.
CharField
(
'
Domain family
'
,
max_length
=
25
)
domain_family
=
models
.
CharField
(
'
Domain family
'
,
max_length
=
25
)
# TODO: what is this field? check database
# TODO: what is this field? check database
# contents
# contents
def
autofill
(
self
):
def
autofill
(
self
):
info
=
get_pfam_info
(
self
.
pfam_acc
)
info
=
get_pfam_info
(
self
.
pfam_acc
)
...
@@ -195,11 +195,12 @@ class Symmetry(models.Model):
...
@@ -195,11 +195,12 @@ class Symmetry(models.Model):
class
Disease
(
models
.
Model
):
class
Disease
(
models
.
Model
):
name
=
models
.
CharField
(
'
Disease
'
,
max_length
=
30
,
unique
=
True
)
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
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
class
PpiFamily
(
models
.
Model
):
class
PpiFamily
(
models
.
Model
):
name
=
models
.
CharField
(
'
Name
'
,
max_length
=
30
,
unique
=
True
)
name
=
models
.
CharField
(
'
Name
'
,
max_length
=
30
,
unique
=
True
)
...
@@ -209,6 +210,7 @@ class PpiFamily(models.Model):
...
@@ -209,6 +210,7 @@ class PpiFamily(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
class
Ppi
(
models
.
Model
):
class
Ppi
(
models
.
Model
):
pdb_id
=
models
.
CharField
(
'
PDB ID
'
,
max_length
=
4
,
null
=
True
)
pdb_id
=
models
.
CharField
(
'
PDB ID
'
,
max_length
=
4
,
null
=
True
)
pockets_nb
=
models
.
IntegerField
(
pockets_nb
=
models
.
IntegerField
(
...
@@ -235,16 +237,19 @@ class Ppi(models.Model):
...
@@ -235,16 +237,19 @@ class Ppi(models.Model):
@property
@property
def
name
(
self
):
def
name
(
self
):
all_protein_names
=
set
([
ppi_complex
.
complex
.
protein
.
short_name
for
ppi_complex
in
self
.
get_ppi_complexes
()])
all_protein_names
=
set
(
bound_protein_names
=
set
([
ppi_complex
.
complex
.
protein
.
short_name
for
ppi_complex
in
self
.
get_ppi_bound_complexes
()])
[
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
partner_protein_names
=
all_protein_names
-
bound_protein_names
bound_str
=
'
,
'
.
join
(
bound_protein_names
)
bound_str
=
'
,
'
.
join
(
bound_protein_names
)
partner_str
=
'
,
'
.
join
(
partner_protein_names
)
partner_str
=
'
,
'
.
join
(
partner_protein_names
)
name
=
bound_str
name
=
bound_str
if
partner_str
!=
''
:
if
partner_str
!=
''
:
name
+=
'
/
'
+
partner_str
name
+=
'
/
'
+
partner_str
return
name
return
name
class
PpiComplex
(
models
.
Model
):
class
PpiComplex
(
models
.
Model
):
ppi
=
models
.
ForeignKey
(
Ppi
,
models
.
CASCADE
)
ppi
=
models
.
ForeignKey
(
Ppi
,
models
.
CASCADE
)
complex
=
models
.
ForeignKey
(
ProteinDomainComplex
,
models
.
CASCADE
)
complex
=
models
.
ForeignKey
(
ProteinDomainComplex
,
models
.
CASCADE
)
...
@@ -257,6 +262,7 @@ class PpiComplex(models.Model):
...
@@ -257,6 +262,7 @@ class PpiComplex(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
'
PPI {}, Complex {} ({})
'
.
format
(
self
.
ppi
,
self
.
complex
,
self
.
cc_nb
)
return
'
PPI {}, Complex {} ({})
'
.
format
(
self
.
ppi
,
self
.
complex
,
self
.
cc_nb
)
class
Compound
(
models
.
Model
):
class
Compound
(
models
.
Model
):
canonical_smile
=
models
.
CharField
(
canonical_smile
=
models
.
CharField
(
'
Canonical Smile
'
,
unique
=
True
,
max_length
=
500
)
'
Canonical Smile
'
,
unique
=
True
,
max_length
=
500
)
...
@@ -444,7 +450,7 @@ class Compound(models.Model):
...
@@ -444,7 +450,7 @@ class Compound(models.Model):
best_pXC50_activity
=
self
.
best_pXC50_activity
best_pXC50_activity
=
self
.
best_pXC50_activity
if
best_pXC50_activity
is
None
:
if
best_pXC50_activity
is
None
:
return
None
return
None
return
float
(
best_pXC50_activity
-
self
.
a_log_p
)
return
float
(
best_pXC50_activity
-
self
.
a_log_p
)
@property
@property
def
best_pXC50_activity_ppi_name
(
self
):
def
best_pXC50_activity_ppi_name
(
self
):
...
@@ -491,10 +497,14 @@ class Compound(models.Model):
...
@@ -491,10 +497,14 @@ class Compound(models.Model):
class
PcaBiplotData
(
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
):
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
):
class
MDDRActivityClass
(
models
.
Model
):
name
=
models
.
CharField
(
'
Activity Class
'
,
max_length
=
100
,
unique
=
True
)
name
=
models
.
CharField
(
'
Activity Class
'
,
max_length
=
100
,
unique
=
True
)
...
@@ -581,17 +591,20 @@ class TestActivityDescription(models.Model):
...
@@ -581,17 +591,20 @@ class TestActivityDescription(models.Model):
(
'
U
'
,
'
Unspecified
'
)
(
'
U
'
,
'
Unspecified
'
)
)
)
biblio
=
models
.
ForeignKey
(
Bibliography
,
models
.
CASCADE
)
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
)
ppi
=
models
.
ForeignKey
(
Ppi
,
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
test_name
=
models
.
CharField
(
'
Test name
'
,
max_length
=
100
)
test_name
=
models
.
CharField
(
'
Test name
'
,
max_length
=
100
)
is_primary
=
models
.
BooleanField
(
'
Is primary
'
)
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_type
=
models
.
CharField
(
'
Test type
'
,
max_length
=
5
,
choices
=
TEST_TYPES
)
test_modulation_type
=
models
.
CharField
(
test_modulation_type
=
models
.
CharField
(
'
Test modulation type
'
,
max_length
=
1
,
choices
=
TEST_MODULATION_TYPES
)
'
Test modulation type
'
,
max_length
=
1
,
choices
=
TEST_MODULATION_TYPES
)
nb_active_compounds
=
models
.
IntegerField
(
nb_active_compounds
=
models
.
IntegerField
(
'
Total number of active compounds
'
)
'
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
):
def
get_complexes
(
self
):
"""
"""
...
@@ -606,7 +619,7 @@ class TestActivityDescription(models.Model):
...
@@ -606,7 +619,7 @@ class TestActivityDescription(models.Model):
@property
@property
def
protein_domain_partner_complex
(
self
):
def
protein_domain_partner_complex
(
self
):
for
ppic
in
self
.
ppi
.
ppicomplex_set
.
all
():
for
ppic
in
self
.
ppi
.
ppicomplex_set
.
all
():
if
hasattr
(
ppic
.
complex
,
'
proteindomainpartnercomplex
'
):
if
hasattr
(
ppic
.
complex
,
'
proteindomainpartnercomplex
'
):
return
ppic
.
complex
.
proteindomainpartnercomplex
return
ppic
.
complex
.
proteindomainpartnercomplex
return
None
return
None
...
@@ -624,7 +637,8 @@ class CompoundActivityResult(models.Model):
...
@@ -624,7 +637,8 @@ class CompoundActivityResult(models.Model):
(
'
pKi
'
,
'
pKi (inhibition constant, -log10)
'
),
(
'
pKi
'
,
'
pKi (inhibition constant, -log10)
'
),
)
)
compound
=
models
.
ForeignKey
(
Compound
,
models
.
CASCADE
)
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
=
models
.
CharField
(
'
Activity type
'
,
max_length
=
5
,
choices
=
ACTIVITY_TYPES
)
'
Activity type
'
,
max_length
=
5
,
choices
=
ACTIVITY_TYPES
)
activity
=
models
.
DecimalField
(
activity
=
models
.
DecimalField
(
...
@@ -644,6 +658,7 @@ class CompoundActivityResult(models.Model):
...
@@ -644,6 +658,7 @@ class CompoundActivityResult(models.Model):
def
is_best
(
self
):
def
is_best
(
self
):
return
self
.
compound
.
best_pXC50_compound_activity_result
.
id
==
self
.
id
return
self
.
compound
.
best_pXC50_compound_activity_result
.
id
==
self
.
id
class
TestCytotoxDescription
(
models
.
Model
):
class
TestCytotoxDescription
(
models
.
Model
):
biblio
=
models
.
ForeignKey
(
Bibliography
,
models
.
CASCADE
)
biblio
=
models
.
ForeignKey
(
Bibliography
,
models
.
CASCADE
)
test_name
=
models
.
CharField
(
'
Cytotoxicity test name
'
,
max_length
=
100
)
test_name
=
models
.
CharField
(
'
Cytotoxicity test name
'
,
max_length
=
100
)
...
@@ -654,7 +669,8 @@ class TestCytotoxDescription(models.Model):
...
@@ -654,7 +669,8 @@ class TestCytotoxDescription(models.Model):
class
CompoundCytotoxicityResult
(
models
.
Model
):
class
CompoundCytotoxicityResult
(
models
.
Model
):
compound
=
models
.
ForeignKey
(
Compound
,
models
.
CASCADE
)
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
)
toxicity
=
models
.
BooleanField
(
'
Toxicity
'
,
default
=
False
)
class
Meta
:
class
Meta
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment