function.py 1.99 KB
Newer Older
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
1
2
3
from django.db import models


4
5
6
7
8
9
10
11
12
13
class Function(models.Model):
    UNDEFINED = 'undef'
    KEGG = 'kegg'
    EGGNOG = 'eggnog'
    SOURCE_CHOICES = [
        (UNDEFINED, 'Undefined'),
        (KEGG, 'KEGG'),
        (EGGNOG, 'EggNOG')
    ]

14
    function_id = models.CharField(max_length=100, db_index=True, unique=True)
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
15
    name = models.CharField(max_length=500, blank=True)
16
17
18
19
20
    source = models.CharField(max_length=10, choices=SOURCE_CHOICES, default=UNDEFINED)

    def __str__(self):
        return self.function_id

21
22
23
    class Meta:
        ordering = ['-function_id']

24

Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
25
class KeggOrthology(Function):
26
27
    SOURCE = 'kegg'

Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
28
29
    ec_number = models.CharField(max_length=200, default='', blank=True)
    long_name = models.CharField(max_length=500)
30

Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
31
32
    def __init__(self, *args, **kwargs):
        super(KeggOrthology, self).__init__(source=self.SOURCE, *args, **kwargs)
33

Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
34
    class Meta:
35
36
        verbose_name = "KEGG orthology"
        verbose_name_plural = "KEGG orthologies"
37
38


39
class EggNOGFunctionalCategory(models.Model):
40
41
42
43
44
45
46
47
48
49
50
    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)

51
52
53
    def __str__(self):
        return f"{self.category_id} ({self.name})"

54
    class Meta:
55
56
57
58
        verbose_name = "EggNOG functional category"
        verbose_name_plural = "EggNOG functional categories"


59
class EggNOGv5(Function):
60
61
    SOURCE = 'eggnog'

62
    functional_categories = models.ManyToManyField(EggNOGFunctionalCategory)
63
64

    def __init__(self, *args, **kwargs):
65
        super(EggNOGv5, self).__init__(source=self.SOURCE, *args, **kwargs)
66
67

    class Meta:
68
69
        verbose_name = "EggNOG v5.0"
        verbose_name_plural = "EggNOGs v5.0"