function.py 1.13 KB
Newer Older
1
from rest_framework import serializers
2
from metagenedb.apps.catalog.models import EggNog, Function, KeggOrthology
3

4
5
6
7
8
9
10
11
from .bulk_list import BulkListSerializer


class FunctionListSerializer(BulkListSerializer):

    class Meta:
        model = Function

12
13

class FunctionSerializer(serializers.ModelSerializer):
14

15
16
    class Meta:
        model = Function
17
        list_serializer_class = FunctionListSerializer
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
18
        fields = ('function_id', 'source', 'name')
19
20
21
22
23
24
25
26
27
28
29
30
31


class EggNogListSerializer(BulkListSerializer):

    class Meta:
        model = EggNog


class EggNogSerializer(serializers.ModelSerializer):

    class Meta:
        model = EggNog
        list_serializer_class = EggNogListSerializer
32
        fields = ('function_id', 'name', 'functional_categories')
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


class KeggOrthologyListSerializer(BulkListSerializer):

    class Meta:
        model = KeggOrthology


class KeggOrthologySerializer(serializers.ModelSerializer):
    ec_number = serializers.CharField(required=False)

    class Meta:
        model = KeggOrthology
        list_serializer_class = KeggOrthologyListSerializer
        fields = ('function_id', 'name', 'long_name', 'ec_number')