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

start Function and Kegg models

parent 60bb9b65
from django.contrib import admin
from .models import Gene
from .models import Gene, Function
@admin.register(Gene)
class GeneAdmin(admin.ModelAdmin):
list_display = ('gene_id', 'gene_length', 'taxonomic_genus', 'taxonomic_phylum')
list_display = ('gene_id', 'gene_length')
search_fields = ('gene_id',)
@admin.register(Function)
class FunctionAdmin(admin.ModelAdmin):
list_display = (('function_id', 'source'))
search_fields = ('function_id',)
from django.db import models
class Function(models.Model):
UNDEFINED = 'undef'
KEGG = 'kegg'
EGGNOG = 'eggnog'
SOURCE_CHOICES = [
(UNDEFINED, 'Undefined'),
(KEGG, 'KEGG'),
(EGGNOG, 'EggNOG')
]
function_id = models.CharField(max_length=100, unique=True, db_index=True)
name = models.CharField(max_length=100)
source = models.CharField(max_length=10, choices=SOURCE_CHOICES, default=UNDEFINED)
def __str__(self):
return self.function_id
class KeggFunctionManager(models.Manager):
SOURCE = 'kegg'
def create_kegg(self, *args, **kwargs):
return self.create(source=self.SOURCE, **kwargs)
class KeggFunction(Function):
objects = KeggFunctionManager()
class Gene(models.Model):
gene_id = models.CharField(max_length=100, unique=True, db_index=True)
gene_length = models.IntegerField()
functions = models.ManyToManyField(Function)
def __str__(self):
return self.gene_id
return self.gene_id
\ No newline at end of file
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