Commit 6dbc0079 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

linking Protein to Domain, and using more is_autofill_done

BUGFIX on Ppi.is_autofill_done
parent d89a88d7
......@@ -167,6 +167,9 @@ class MolecularFunction(AutoFillableModel):
info = get_go_info(self.go_id)
self.description = info['label']
def is_autofill_done(self):
return self.description is not None and len(self.description) > 0
@property
def name(self):
return self.go_id + ' ' + self.description
......@@ -220,21 +223,11 @@ class Protein(AutoFillableModel):
super(Protein, self).save()
for go_id in info['molecular_functions']:
try:
mol_function = MolecularFunction.objects.get(go_id=go_id)
except MolecularFunction.DoesNotExist:
mol_function = MolecularFunction()
mol_function.go_id = go_id
mol_function.save(autofill=True)
mol_function, created = MolecularFunction.objects.get_or_create(go_id=go_id)
self.molecular_functions.add(mol_function)
for domain_id in info['domains']:
try:
domain = Domain.objects.get(pfam_acc=domain_id)
except MolecularFunction.DoesNotExist:
domain = Domain()
domain.pfam_acc = domain_id
domain.save(autofill=True)
domain, created = Domain.objects.get_or_create(pfam_acc=domain_id)
self.domains.add(domain)
def is_autofill_done(self):
......@@ -265,6 +258,9 @@ class Domain(AutoFillableModel):
self.pfam_id = info['id']
self.pfam_description = info['description']
def is_autofill_done(self):
return self.pfam_id is not None and len(self.pfam_id) > 0
@property
def name(self):
return self.pfam_id
......@@ -365,7 +361,7 @@ class Ppi(AutoFillableModel):
return 'PPI #{} on {}'.format(self.id, self.name)
def is_autofill_done(self):
return self.name == ""
return self.name != ""
def autofill(self):
# name is denormalized and stored in the database to reduce SQL queries in query mode
......
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