Commit ecf0680a authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

multiple model modifications

- separate Ppi into Ppi and PpiComplex classes (fixes #36)
- replace ActivityType table with an enumerated type
- remove complex from foreign keys when not required
parent c4a2fb5e
No preview for this file type
from django.forms import ModelForm
from django import forms
from django.db import models
from .models import Bibliography, Protein, ProteinDomainComplex, Ppi
from .models import Bibliography, Protein, ProteinDomainComplex, Ppi, PpiComplex
class IdForm(forms.Form):
id = forms.CharField(label="",max_length=100, widget=forms.TextInput(attrs={'placeholder': 'PubMed ID / DOI / Patent ID'}))
......@@ -24,8 +24,12 @@ class ProteinDomainComplexForm(ModelForm):
model = ProteinDomainComplex
fields = ['protein', 'domain', 'ppc_copy_nb']
class PpiForm(ModelForm):
class Meta:
model = Ppi
fields = ['complex', 'cc_nb', 'pdb_id', 'symmetry']
fields = ['pdb_id', 'symmetry']
class PpiComplexForm(ModelForm):
class Meta:
model = PpiComplex
fields = ['complex', 'cc_nb']
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-18 11:42
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('ippidb', '0009_auto_20170517_2020'),
]
operations = [
migrations.CreateModel(
name='PpiComplex',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cc_nb', models.IntegerField(default=1, verbose_name='Number of copies of the complex in the PPI')),
('complex', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.ProteinDomainComplex')),
],
options={
'verbose_name_plural': 'Ppi complexes',
},
),
migrations.RemoveField(
model_name='ppi',
name='cc_nb',
),
migrations.RemoveField(
model_name='ppi',
name='complex',
),
migrations.RemoveField(
model_name='ppi',
name='ppi_id',
),
migrations.RemoveField(
model_name='testactivitydescription',
name='complex',
),
migrations.AlterField(
model_name='compoundactivityresult',
name='activity_type',
field=models.CharField(choices=[('pIC50', 'pIC50 (half maximal inhibitory concentration, -log10)'), ('pEC50', 'pEC50 (half maximal effective concentration, -log10)'), ('pKd', 'pKd (dissociation constant, -log10)'), ('pKi', 'pKi (inhibition constant, -log10)')], max_length=5, verbose_name='Activity type'),
),
migrations.AlterUniqueTogether(
name='cmpdaction',
unique_together=set([('compound', 'activation_mode', 'pdb_id')]),
),
migrations.RemoveField(
model_name='cmpdaction',
name='complex',
),
migrations.AlterUniqueTogether(
name='cmpdaction',
unique_together=set([('ppi', 'compound', 'activation_mode', 'pdb_id')]),
),
migrations.DeleteModel(
name='ActivityType',
),
migrations.AddField(
model_name='ppicomplex',
name='ppi',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Ppi'),
),
]
......@@ -150,12 +150,17 @@ class Symmetry(models.Model):
return '{} ({})'.format(self.code, self.description)
class Ppi(models.Model):
ppi_id = models.IntegerField('PPI identifier')
complex = models.ForeignKey(ProteinDomainComplex)
cc_nb = models.IntegerField('Number of copies of the complex in the PPI', default=1)
pdb_id = models.CharField('PDB ID', max_length=4)
symmetry = models.ForeignKey(Symmetry)
class PpiComplex(models.Model):
ppi = models.ForeignKey(Ppi)
complex = models.ForeignKey(ProteinDomainComplex)
cc_nb = models.IntegerField('Number of copies of the complex in the PPI', default=1)
class Meta:
verbose_name_plural = "Ppi complexes"
class Disease(models.Model):
ppi = models.ForeignKey(Ppi)
disease_name = models.CharField('Disease', max_length=30) # is there any database/nomenclature for diseases?
......@@ -261,7 +266,6 @@ class TestActivityDescription(models.Model):
('I', 'Inhibition'),
('S', 'Stabilization')
)
complex = models.ForeignKey(ProteinDomainBoundComplex)
biblio = models.ForeignKey(Bibliography)
ppi = models.ForeignKey(Ppi, blank=True, null=True)
test_name = models.CharField('Test name', max_length=100)
......@@ -270,8 +274,12 @@ class TestActivityDescription(models.Model):
nb_active_compounds = models.IntegerField('Total number of active compounds')
cell_line = models.ForeignKey(CellLine)
class ActivityType(models.Model):
name = models.CharField('Name', max_length=50, unique=True)
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
class CompoundActivityResult(models.Model):
MODULATION_TYPES = (
......@@ -279,9 +287,15 @@ class CompoundActivityResult(models.Model):
('I', 'Inhibition'),
('S', 'Stabilization')
)
ACTIVITY_TYPES = (
('pIC50','pIC50 (half maximal inhibitory concentration, -log10)'),
('pEC50','pEC50 (half maximal effective concentration, -log10)'),
('pKd','pKd (dissociation constant, -log10)'),
('pKi','pKi (inhibition constant, -log10)'),
)
compound = models.ForeignKey(Compound)
test_activity_description = models.ForeignKey(TestActivityDescription)
activity_type = models.ForeignKey(ActivityType)
activity_type = models.CharField('Activity type', max_length=5, choices=ACTIVITY_TYPES)
activity = models.DecimalField('Activity', max_digits=12, decimal_places=10)
modulation_type = models.CharField('Modulation type', max_length=1, choices=MODULATION_TYPES)
......@@ -334,7 +348,6 @@ class CmpdAction(models.Model):
('O', 'Orthosteric'),
('A', 'Allosteric')
)
complex = models.ForeignKey(ProteinDomainBoundComplex)
compound = models.ForeignKey(Compound)
activation_mode = models.CharField('Activation mode', max_length=1, choices=ACTIVATION_MODES)
ppi = models.ForeignKey(Ppi)
......@@ -342,7 +355,12 @@ class CmpdAction(models.Model):
nb_copy_compounds = models.IntegerField('Number of copies for the compound')
class Meta:
unique_together = (('complex', 'compound', 'pdb_id'),)
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
class RefCompoundBiblio(models.Model):
compound = models.ForeignKey(Compound)
......
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