Commit 66d3f01e authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

Start adding model for Eggnog

parent 364475de
Pipeline #19428 passed with stages
in 2 minutes and 40 seconds
from django.contrib import admin
from metagenedb.apps.catalog.models import Function, KeggOrthology
from metagenedb.apps.catalog.models import EggNog, EggNogFunctionalCategory, Function, KeggOrthology
@admin.register(KeggOrthology)
......@@ -15,3 +15,17 @@ class FunctionAdmin(admin.ModelAdmin):
list_display = ('function_id', 'name', 'source')
search_fields = ('function_id',)
@admin.register(EggNog)
class EggNogAdmin(admin.ModelAdmin):
list_display = ('function_id', 'name', 'long_name')
search_fields = ('function_id', 'name')
@admin.register(EggNogFunctionalCategory)
class EggNogFunctionalCategoryAdmin(admin.ModelAdmin):
list_display = ('category_id', 'name', 'group')
search_fields = ('category_id', 'name')
# Generated by Django 3.0 on 2019-12-06 15:31
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('catalog', '0011_change_through_genefunction'),
]
operations = [
migrations.CreateModel(
name='EggNogFunctionalCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('category_id', models.CharField(db_index=True, max_length=1, unique=True)),
('name', models.CharField(max_length=100)),
('group', models.CharField(choices=[('info_storage_processing', 'Information Storage and Processing'), ('cellular_processes_signaling', 'Cellular Processes and Signaling'), ('metabolism', 'Metabolism'), ('poorly_characterized', 'Poorly Characterized')], max_length=100)),
],
),
migrations.CreateModel(
name='EggNog',
fields=[
('function_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='catalog.Function')),
('long_name', models.CharField(max_length=500)),
('functional_category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='eggnogs', to='catalog.EggNogFunctionalCategory')),
],
bases=('catalog.function',),
),
]
from .function import Function, KeggOrthology # noqa
from .function import EggNog, EggNogFunctionalCategory, Function, KeggOrthology # noqa
from .gene import Gene, GeneFunction # noqa
from .taxonomy import Taxonomy # noqa
......@@ -33,3 +33,36 @@ class KeggOrthology(Function):
class Meta:
verbose_name_plural = "Kegg orthologies"
class EggNog(Function):
SOURCE = 'eggnog'
long_name = models.CharField(max_length=500)
functional_category = models.ForeignKey(
'EggNogFunctionalCategory', related_name='eggnogs',
on_delete=models.SET_NULL,
null=True, blank=True
)
def __init__(self, *args, **kwargs):
super(EggNog, self).__init__(source=self.SOURCE, *args, **kwargs)
class Meta:
verbose_name_plural = "EggNog"
class EggNogFunctionalCategory(models.Model):
GROUP_CHOICES = [
('info_storage_processing', 'Information Storage and Processing'),
('cellular_processes_signaling', 'Cellular Processes and Signaling'),
('metabolism', 'Metabolism'),
('poorly_characterized', 'Poorly Characterized')
]
category_id = models.CharField(max_length=1, db_index=True, unique=True)
name = models.CharField(max_length=100)
group = models.CharField(max_length=100, choices=GROUP_CHOICES)
class Meta:
verbose_name_plural = "EggNog Functional categories"
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