function.py 1.13 KB
Newer Older
1
from rest_framework import serializers
2
from metagenedb.apps.catalog.models import EggNOGv5, 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
class EggNOGListSerializer(BulkListSerializer):
22
23

    class Meta:
24
        model = EggNOGv5
25
26


27
class EggNOGSerializer(serializers.ModelSerializer):
28
29

    class Meta:
30
31
        model = EggNOGv5
        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')