Commit 4cebe0c4 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add PPI family field to PPIs.


Former-commit-id: a5b2d51710ea8e062168e7e40676d0c86cf7ec4a
parent 3d48e359
b5ded9e1a05b9a0751e6d1addad0faf88524c8ca
\ No newline at end of file
a45fec449759455268a158a1fc5ca4b76146fb4c
\ No newline at end of file
......@@ -8,7 +8,7 @@ from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \
Domain, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Symmetry, Ppi, PpiComplex, Disease, \
Compound, MDDRCompoundImport, MDDRActivityClass, TestActivityDescription, CellLine, RefCompoundBiblio, \
CompoundAction, TestCytotoxDescription, TestPKDescription, CompoundActivityResult, \
CompoundCytotoxicityResult, CompoundPKResult
CompoundCytotoxicityResult, CompoundPKResult, PpiFamily
class MyConverter(mysql.connector.conversion.MySQLConverter):
......@@ -221,19 +221,20 @@ class Command(BaseCommand):
self.style.SUCCESS('Successfully inserted {} {}'.format(row[0], row[1])))
if options['ppi']:
sql_request_string = '''
select distinct protein.NumUniprot, domain.PfamNumAccession, complexe.NbCopy, cmpdAction.IDComplexeBound, bindingSiteEvidence.CodePDB, 'part1', ppi.IDPPI, disease.Disease, complexe.IDComplexe from bindingSite inner join ppi on (bindingSite.IDBindingSite=ppi.IDBindingSite1) inner join complexe on (ppi.IDComplexe1=complexe.IDComplexe) left outer join cmpdAction on (complexe.IDComplexe=cmpdAction.IDComplexeBound) inner join protein on (bindingSite.IDProtein=protein.IDProtein) inner join domain on (bindingSite.IDDomain=domain.IDDomain) inner join disease on (disease.IDPPI=ppi.IDPPI) left outer join bindingSiteEvidence on (ppi.IDPPI=bindingSiteEvidence.IDPPI)
select distinct protein.NumUniprot, domain.PfamNumAccession, complexe.NbCopy, cmpdAction.IDComplexeBound, bindingSiteEvidence.CodePDB, 'part1', ppi.IDPPI, disease.Disease, complexe.IDComplexe, ppi.Family from bindingSite inner join ppi on (bindingSite.IDBindingSite=ppi.IDBindingSite1) inner join complexe on (ppi.IDComplexe1=complexe.IDComplexe) left outer join cmpdAction on (complexe.IDComplexe=cmpdAction.IDComplexeBound) inner join protein on (bindingSite.IDProtein=protein.IDProtein) inner join domain on (bindingSite.IDDomain=domain.IDDomain) inner join disease on (disease.IDPPI=ppi.IDPPI) left outer join bindingSiteEvidence on (ppi.IDPPI=bindingSiteEvidence.IDPPI)
union
select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy, cmpdAction.IDComplexeBound, null, 'part2', ppi.IDPPI, disease.Disease, complexe.IDComplexe from bindingSite inner join ppi on (bindingSite.IDBindingSite=ppi.IDBindingSite2) inner join complexe on (ppi.IDComplexe2=complexe.IDComplexe) left outer join cmpdAction on (complexe.IDComplexe=cmpdAction.IDComplexeBound) inner join protein on (bindingSite.IDProtein=protein.IDProtein) inner join domain on (bindingSite.IDDomain=domain.IDDomain) inner join disease on (disease.IDPPI=ppi.IDPPI)'''
select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy, cmpdAction.IDComplexeBound, null, 'part2', ppi.IDPPI, disease.Disease, complexe.IDComplexe, ppi.Family from bindingSite inner join ppi on (bindingSite.IDBindingSite=ppi.IDBindingSite2) inner join complexe on (ppi.IDComplexe2=complexe.IDComplexe) left outer join cmpdAction on (complexe.IDComplexe=cmpdAction.IDComplexeBound) inner join protein on (bindingSite.IDProtein=protein.IDProtein) inner join domain on (bindingSite.IDDomain=domain.IDDomain) inner join disease on (disease.IDPPI=ppi.IDPPI)'''
cursor.execute(sql_request_string)
rows = cursor.fetchall()
ProteinDomainBoundComplex.objects.all().delete()
ProteinDomainPartnerComplex.objects.all().delete()
Disease.objects.all().delete()
Ppi.objects.all().delete()
PpiFamily.objects.all().delete()
PpiComplex.objects.all().delete()
CompoundAction.objects.all().delete()
self.stdout.write(
self.style.SUCCESS('Successfully flushed protein domain complex, PPI, compound actions, and disease tables'))
self.style.SUCCESS('Successfully flushed protein domain complex, PPI, PPI families, compound actions, and disease tables'))
ppi_ids_mapping = {}
protein_domain_bound_complexes_mapping = {}
for row in rows:
......@@ -243,6 +244,8 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
ppi = Ppi()
disease, created = Disease.objects.get_or_create(
name=row[7])
ppi_family, created = PpiFamily.objects.get_or_create(
name=row[9])
ppi.pdb_id = row[4]
ppi.pockets_nb = 1
ppi.symmetry = Symmetry.objects.get(code='AS')
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-02 15:00
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('ippidb', '0032_lellebiplotdata'),
]
operations = [
migrations.CreateModel(
name='PpiFamily',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, unique=True, verbose_name='Name')),
],
),
migrations.AddField(
model_name='ppi',
name='family',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='ippidb.PpiFamily'),
),
]
......@@ -201,6 +201,11 @@ class Disease(models.Model):
def __str__(self):
return self.name
class PpiFamily(models.Model):
name = models.CharField('Name', max_length=30, unique=True)
def __str__(self):
return self.name
class Ppi(models.Model):
pdb_id = models.CharField('PDB ID', max_length=4, null=True)
......@@ -208,6 +213,7 @@ class Ppi(models.Model):
'Total number of pockets in the complex', default=1)
symmetry = models.ForeignKey(Symmetry, models.CASCADE)
diseases = models.ManyToManyField(Disease)
family = models.ForeignKey(PpiFamily, models.CASCADE, null=True)
def __str__(self):
return '{} PPI, PDB:{}'.format(self.symmetry.description, self.pdb_id or 'unknown')
......
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