Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
9d65ac11
Commit
9d65ac11
authored
Nov 14, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
add endpoint to obtain detailed info from kegg through togows
parent
db3e5157
Pipeline
#18235
passed with stages
in 2 minutes and 26 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/api/external/urls.py
View file @
9d65ac11
from
django.
conf.
urls
import
url
from
django.urls
import
path
from
metagenedb.api.external.views
.togows
import
ListUser
s
from
metagenedb.api.external.views
import
KeggInfoTogow
s
urlpatterns
=
[
url
(
r
'
^
togows/
$'
,
ListUsers
.
as_view
()
),
path
(
r
'togows/
<kegg_id>'
,
KeggInfoTogows
.
as_view
(),
name
=
'kegg-info'
),
]
backend/metagenedb/api/external/views/__init__.py
View file @
9d65ac11
from
.togows
import
KeggInfoTogows
# noqa
backend/metagenedb/api/external/views/togows.py
View file @
9d65ac11
from
bioapi.togows
import
TogoWSEntryAPI
from
requests.exceptions
import
HTTPError
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
django.contrib.auth.models
import
User
from
rest_framework.status
import
(
HTTP_200_OK
,
HTTP_404_NOT_FOUND
)
class
ListUser
s
(
APIView
):
class
KeggInfoTogow
s
(
APIView
):
"""
View to list all users in the system
.
Obtain detailed information about KEGG orthology entry
.
"""
def
get
(
self
,
request
,
format
=
None
):
def
get
(
self
,
request
,
kegg_id
=
None
):
"""
Return a list of all users.
"""
usernames
=
[
user
.
username
for
user
in
User
.
objects
.
all
()]
return
Response
(
usernames
)
kegg_api
=
TogoWSEntryAPI
(
"kegg-orthology"
)
try
:
content
=
kegg_api
.
get
(
kegg_id
)[
0
]
status
=
HTTP_200_OK
except
HTTPError
as
http_err
:
content
=
[{
'error'
:
str
(
http_err
)}]
status
=
HTTP_404_NOT_FOUND
return
Response
(
content
,
status
=
status
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment