-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
452174f
commit 15524ea
Showing
13 changed files
with
535 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,36 @@ | ||
from rest_framework import serializers | ||
from django.contrib.auth.models import User | ||
from rest_framework.serializers import HyperlinkedModelSerializer, ReadOnlyField, HyperlinkedRelatedField | ||
from app.models import Organism | ||
from blast.models import SequenceType, BlastDb, Sequence, BlastQueryRecord | ||
from blast.models import SequenceType, BlastDb | ||
|
||
class OrganismSerializer(serializers.HyperlinkedModelSerializer): | ||
url = serializers.HyperlinkedIdentityField(view_name='blast:organism-detail', lookup_field='short_name') | ||
|
||
class OrganismSerializer(HyperlinkedModelSerializer): | ||
class Meta: | ||
model = Organism | ||
fields = ('display_name', 'short_name', 'description', 'tax_id') | ||
|
||
|
||
class SequenceTypeSerializer(serializers.HyperlinkedModelSerializer): | ||
url = serializers.HyperlinkedIdentityField(view_name='blast:sequencetype-detail', lookup_field='dataset_type') | ||
|
||
class SequenceTypeSerializer(HyperlinkedModelSerializer): | ||
class Meta: | ||
model = SequenceType | ||
|
||
|
||
class BlastDbSerializer(serializers.HyperlinkedModelSerializer): | ||
url = serializers.HyperlinkedIdentityField(view_name='blast:blastdb-detail', lookup_field='title') | ||
organism = serializers.HyperlinkedRelatedField(view_name='blast:organism-detail', lookup_field='short_name', read_only=True) | ||
type = serializers.HyperlinkedRelatedField(view_name='blast:sequencetype-detail', lookup_field='dataset_type', read_only=True) | ||
sequence_set = serializers.HyperlinkedRelatedField(view_name='blast:blastdb-sequence-set', lookup_field='title', read_only=True) | ||
fasta_file_exists = serializers.Field() | ||
blast_db_files_exists = serializers.Field() | ||
sequence_set_exists = serializers.Field() | ||
db_ready = serializers.Field() | ||
fields = ('molecule_type', 'dataset_type') | ||
|
||
|
||
class BlastDbSerializer(HyperlinkedModelSerializer): | ||
organism = HyperlinkedRelatedField( | ||
view_name='blast:organism-detail', | ||
lookup_field='short_name', | ||
read_only=True) | ||
type = HyperlinkedRelatedField( | ||
view_name='blast:sequencetype-detail', | ||
lookup_field='dataset_type', | ||
read_only=True) | ||
fasta_file_exists = ReadOnlyField() | ||
blast_db_files_exists = ReadOnlyField() | ||
sequence_set_exists = ReadOnlyField() | ||
db_ready = ReadOnlyField() | ||
|
||
class Meta: | ||
model = BlastDb | ||
fields = ('url', 'organism', 'type', 'fasta_file', 'title', 'description', 'is_shown', 'fasta_file_exists', 'blast_db_files_exists', 'sequence_set_exists', 'db_ready', 'sequence_set', ) | ||
|
||
|
||
class SequenceSerializer(serializers.HyperlinkedModelSerializer): | ||
blast_db = serializers.HyperlinkedRelatedField(view_name='blast:blastdb-detail', lookup_field='title', read_only=True) | ||
fasta_seq = serializers.ReadOnlyField() | ||
|
||
class Meta: | ||
model = Sequence | ||
fields = ('blast_db', 'id', 'length', 'seq_start_pos', 'seq_end_pos', 'modified_date', 'fasta_seq', ) | ||
|
||
|
||
class BlastQueryRecordSerializer(serializers.HyperlinkedModelSerializer): | ||
url = serializers.HyperlinkedIdentityField(view_name='blast:blastqueryrecord-detail', lookup_field='task_id') | ||
|
||
class Meta: | ||
model = BlastQueryRecord | ||
|
||
|
||
class UserSerializer(serializers.ModelSerializer): | ||
url = serializers.HyperlinkedIdentityField(view_name='blast:user-detail', lookup_field='pk') | ||
|
||
class Meta: | ||
model = User | ||
fields = ('id', 'url',) | ||
|
||
|
||
class UserBlastQueryRecordSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = BlastQueryRecord | ||
fields = ('task_id', 'enqueue_date', 'result_status') | ||
fields = ('organism', 'type', 'fasta_file', 'title', 'description', | ||
'is_shown', 'fasta_file_exists', 'blast_db_files_exists', | ||
'sequence_set_exists', 'db_ready') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
from django.conf.urls import url, include | ||
from django.conf import settings | ||
from blast import views | ||
from blast.api import OrganismViewSet, SequenceTypeViewSet, BlastDbViewSet, SequenceViewSet, BlastQueryRecordViewSet, UserViewSet | ||
from rest_framework import routers | ||
|
||
router = routers.DefaultRouter() | ||
router.register(r'organism', OrganismViewSet) | ||
router.register(r'seqtype', SequenceTypeViewSet) | ||
router.register(r'blastdb', BlastDbViewSet) | ||
router.register(r'seq', SequenceViewSet) | ||
router.register(r'task', BlastQueryRecordViewSet) | ||
router.register(r'user', UserViewSet) | ||
|
||
urlpatterns = [ | ||
# ex: /blast/ | ||
url(r'^$', views.create, name='create'), | ||
# url(r'^iframe$', views.create, {'iframe': True}, name='iframe'), | ||
# ex: /blast/5/ | ||
url(r'^task/(?P<task_id>[0-9a-zA-Z]+)$', views.retrieve, name='retrieve'), | ||
url(r'^task/(?P<task_id>[0-9a-zA-Z]+)/status$', views.status, name='status'), | ||
url(r'^task/(?P<task_id>[0-9a-zA-Z]+)/status$', | ||
views.status, | ||
name='status'), | ||
# url(r'^read_gff3/(?P<task_id>[0-9a-fA-F]*)/*(?P<dbname>[\w\-\|.]*)/*$', views.read_gff3, name='read_gff3'), | ||
url(r'^api/', include(router.urls)), | ||
# url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), | ||
url(r'^user-tasks/(?P<user_id>[0-9]+)$', views.user_tasks), | ||
url(r'^api/seq/(?P<seq_id>[a-zA-Z0-9_-]+)/', views.get_seq, name='seq'), | ||
] | ||
|
||
if settings.DEBUG: | ||
from blast import test_views | ||
urlpatterns += [ | ||
url(r'^test/$', test_views.test_main) | ||
] | ||
urlpatterns += [url(r'^test/$', test_views.test_main)] |
Oops, something went wrong.