Commit 5ad81b20 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add molecular function info to Protein/MolecularFunction

parent 858ce847
......@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.forms import ModelForm
from .ws import get_pubmed_info, get_epo_info, get_uniprot_info, get_taxonomy_info
from .ws import get_pubmed_info, get_epo_info, get_uniprot_info, get_taxonomy_info, get_go_info
class Bibliography(models.Model):
......@@ -68,6 +68,11 @@ class MolecularFunction(models.Model):
go_id = models.CharField('Gene Ontology ID', unique=True, max_length=10) # GO term id format: 'GO:0000000'
description = models.CharField('description', max_length=500)
def save(self, *args, **kwargs):
info = get_go_info(self.go_id)
self.description = info['label']
super(MolecularFunction, self).save(*args, **kwargs)
def __str__(self):
return self.description
......@@ -88,12 +93,19 @@ class Protein(models.Model):
taxonomy = Taxonomy.objects.get(taxonomy_id=info['organism'])
except Taxonomy.DoesNotExist:
tax_info = get_taxonomy_info(info['organism'])
taxonomy = Taxonomy()
taxonomy.taxonomy_id = info['organism']
self.organism = taxonomy
super(Protein, self).save(*args, **kwargs)
for go_id in info['molecular_functions']:
mol_function = MolecularFunction.objects.get(go_id=go_id)
except MolecularFunction.DoesNotExist:
mol_function = MolecularFunction()
mol_function.go_id = go_id
class Domain(models.Model):
pfam_acc = models.CharField('Pfam Accession', max_length=10, unique=True)
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