Skip to content

Commit

Permalink
Add endpoint to fetch sequence using md5 field
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosribas committed Jul 11, 2024
1 parent eea53fc commit 15cda33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rnacentral/apiv1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,9 @@ def get_ensembl_assembly(self, obj):
"example_start": obj.example_start,
"example_end": obj.example_end,
}


class Md5Serializer(serializers.Serializer):
"""Serializer class to fetch sequence using md5"""

sequence = serializers.CharField(source="get_sequence")
6 changes: 6 additions & 0 deletions rnacentral/apiv1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
cache_page(CACHE_TIMEOUT)(views.LncrnaTargetsView.as_view()),
name="rna-lncrna-targets",
),
# fetch sequence using md5
url(
r"md5/(?P<md5>.*?)/?$",
cache_page(CACHE_TIMEOUT)(views.Md5SequenceView.as_view({"get": "retrieve"})),
name="md5-sequence",
),
# Information about the qc status for a given sequence
url(
r"^rna/(?P<pk>URS[0-9A-Fa-f]{10})/qc-status/(?P<taxid>\d+)/?$",
Expand Down
9 changes: 9 additions & 0 deletions rnacentral/apiv1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
InteractionsSerializer,
LitSummSerializer,
LncrnaTargetsSerializer,
Md5Serializer,
ProteinTargetsSerializer,
QcStatusSerializer,
RawPublicationSerializer,
Expand Down Expand Up @@ -1102,3 +1103,11 @@ def get_queryset(self):
if primary_id is not None:
queryset = queryset.filter(primary_id=primary_id)
return queryset


class Md5SequenceView(ReadOnlyModelViewSet):
"""API endpoint to fetch sequence using md5 field"""

queryset = Rna.objects.all()
serializer_class = Md5Serializer
lookup_field = "md5"

0 comments on commit 15cda33

Please sign in to comment.