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

add InChi and InChiKey in the Compound model

these properties are computed at autofill time.
this is related to #80


Former-commit-id: 4828148b65705ee9f7cfd3713af30d86d815c83e
parent 011dac85
edbde018edaa95e4ff760fc4e5d941325b7840e0
\ No newline at end of file
261a7e94dbceb83b2607cfc1719f2d07e27e2088
\ No newline at end of file
......@@ -622,7 +622,7 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
compound.iupac_name = row[59]
# compound.mddr_compound = row[60]
# FIXME lookup MDDR to get the right ID
compound.save()
compound.save(autofill=True)
except Exception as e:
if options['stoponfail']:
import traceback
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-09-05 09:20
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ippidb', '0010_auto_20180829_2055'),
]
operations = [
migrations.AddField(
model_name='compound',
name='inchi',
field=models.TextField(default='NONE', verbose_name='InChi'),
preserve_default=False,
),
migrations.AddField(
model_name='compound',
name='inchikey',
field=models.TextField(default='NONE', verbose_name='InChiKey'),
preserve_default=False,
),
]
......@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.db.models import Max
from .utils import FingerPrinter
from .utils import FingerPrinter, smi2inchi, smi2inchikey
from .ws import get_pubmed_info, get_google_patent_info, get_uniprot_info, get_taxonomy_info, get_go_info, get_pfam_info
......@@ -262,7 +262,7 @@ class PpiComplex(models.Model):
return 'PPI {}, Complex {} ({})'.format(self.ppi, self.complex, self.cc_nb)
class Compound(models.Model):
class Compound(AutoFillableModel):
canonical_smile = models.TextField(
'Canonical Smile', unique=True)
is_macrocycle = models.BooleanField('Contains one or more macrocycles')
......@@ -309,6 +309,8 @@ class Compound(models.Model):
nb_o = models.IntegerField('Number of oxygen atoms')
nb_rings = models.IntegerField('Number of rings')
nb_rotatable_bonds = models.IntegerField('Number of rotatable bonds')
inchi = models.TextField('InChi')
inchikey = models.TextField('InChiKey')
randic_index = models.DecimalField(
'Randic index', max_digits=4, decimal_places=2)
rdf070m = models.DecimalField(
......@@ -494,6 +496,11 @@ class Compound(models.Model):
"""
return list(set([ca.ppi.family for ca in self.compoundaction_set.all()]))
def autofill(self):
# compute InChi and InChiKey
self.inchi = smi2inchi(self.canonical_smile)
self.inchikey = smi2inchikey(self.inchikey)
class CompoundTanimoto(models.Model):
canonical_smiles = models.TextField(
'Canonical Smile')
......
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