Skip to content
GitLab
Menu
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
bf4feb29
Commit
bf4feb29
authored
Aug 10, 2020
by
Kenzo-Hugo Hillion
♻
Browse files
use KEGGAPI instead of TOGOWS from dabeplech to retrieve KEGG details
parent
7f8fbe98
Pipeline
#35410
passed with stages
in 3 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/common/utils/external_api/test_togows.py
View file @
bf4feb29
...
...
@@ -14,11 +14,11 @@ class TestGetFunctionExternalInfo(TestCase):
external_info_retriever
.
get_details
()
def
test_get_details_kegg
(
self
):
with
mock
.
patch
(
'metagenedb.common.utils.external_api.togows.
TogoWSEntry
API'
)
as
Mock
TogoWSEntry
API
:
Mock
TogoWSEntry
API
.
return_value
.
get
.
return_value
=
[
{
"info"
:
"some_info"
}
]
with
mock
.
patch
(
'metagenedb.common.utils.external_api.togows.
KEGG
API'
)
as
Mock
KEGG
API
:
Mock
KEGG
API
.
return_value
.
get
.
return_value
.
dict
.
return_value
=
{
"info"
:
"some_info"
}
test_url
=
"http://test.com/"
test_id
=
"test_kegg_id"
Mock
TogoWSEntry
API
.
return_value
.
url
=
test_url
Mock
KEGG
API
.
return_value
.
url
=
test_url
expected_dict
=
{
'info'
:
'some_info'
,
settings
.
API_KEY_ADDITIONAL_INFO
:
{
...
...
backend/metagenedb/common/utils/external_api/togows.py
View file @
bf4feb29
...
...
@@ -2,7 +2,7 @@ import logging
from
django.conf
import
settings
from
dabeplech
.togows
import
TogoWSEntry
API
from
dabeplech
import
KEGG
API
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -21,8 +21,9 @@ class GetFunctionExternalInfo:
"""
Get detailed information from KEGG orthology through Togows.
"""
kegg_api
=
TogoWSEntryAPI
(
"kegg-orthology"
)
response
=
kegg_api
.
get
(
self
.
function_id
)[
0
]
logger
.
info
(
"Retrieving information from KEGG API"
)
kegg_api
=
KEGGAPI
()
response
=
kegg_api
.
get
(
self
.
function_id
).
dict
()
response
[
settings
.
API_KEY_ADDITIONAL_INFO
]
=
{
'comment'
:
f
"Information retrieved from external source:
{
kegg_api
.
url
}
"
,
'url'
:
f
"
{
kegg_api
.
url
}{
self
.
function_id
}
"
...
...
@@ -30,5 +31,4 @@ class GetFunctionExternalInfo:
return
response
def
get_details
(
self
):
logger
.
info
(
"Retrieving information from KEGG through togows"
)
return
getattr
(
self
,
f
"_get_
{
self
.
source
}
"
,
self
.
_get_unknown_source
)()
frontend/src/components/keggcard/keggcard.js
View file @
bf4feb29
...
...
@@ -69,7 +69,6 @@ export default {
this
.
buildPathways
(
response
),
this
.
buildDiseases
(
response
),
this
.
buildModules
(
response
),
this
.
buildReferences
(
response
),
];
},
buildPathways
(
response
)
{
...
...
@@ -78,17 +77,19 @@ export default {
icon
:
'
fas fa-bezier-curve
'
,
content
:
[],
};
Object
.
entries
(
response
.
data
.
pathways
).
forEach
(([
key
,
value
])
=>
{
pathways
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/kegg-bin/show_pathway?
${
key
}
+
${
this
.
keggId
}
`
,
url_label
:
"
Open in KEGG
"
,
fetch
:
true
,
},
);
});
if
(
response
.
data
.
pathways
)
{
Object
.
entries
(
response
.
data
.
pathways
).
forEach
(([
key
,
value
])
=>
{
pathways
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/kegg-bin/show_pathway?
${
key
}
+
${
this
.
keggId
}
`
,
url_label
:
"
Open in KEGG
"
,
fetch
:
true
,
},
);
});
}
return
pathways
;
},
buildModules
(
response
)
{
...
...
@@ -97,16 +98,18 @@ export default {
icon
:
'
fas fa-bezier-curve
'
,
content
:
[],
};
Object
.
entries
(
response
.
data
.
modules
).
forEach
(([
key
,
value
])
=>
{
modules
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/kegg-bin/show_module?
${
key
}
+
${
this
.
keggId
}
`
,
url_label
:
"
Open in KEGG
"
},
);
});
if
(
response
.
data
.
modules
)
{
Object
.
entries
(
response
.
data
.
modules
).
forEach
(([
key
,
value
])
=>
{
modules
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/kegg-bin/show_module?
${
key
}
+
${
this
.
keggId
}
`
,
url_label
:
"
Open in KEGG
"
},
);
});
}
return
modules
;
},
buildDiseases
(
response
)
{
...
...
@@ -115,15 +118,17 @@ export default {
icon
:
'
fas fa-laptop-medical
'
,
content
:
[],
};
Object
.
entries
(
response
.
data
.
diseases
).
forEach
(([
key
,
value
])
=>
{
diseases
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/dbget-bin/www_bget?ds:
${
key
}
`
,
},
);
});
if
(
response
.
data
.
diseases
)
{
Object
.
entries
(
response
.
data
.
diseases
).
forEach
(([
key
,
value
])
=>
{
diseases
.
content
.
push
(
{
id
:
key
,
name
:
value
,
url
:
`https://www.genome.jp/dbget-bin/www_bget?ds:
${
key
}
`
,
},
);
});
}
return
diseases
;
},
buildReferences
(
response
)
{
...
...
@@ -132,16 +137,18 @@ export default {
icon
:
'
fas fa-book-open
'
,
content
:
[],
};
for
(
let
i
=
0
;
i
<
response
.
data
.
references
.
length
;
i
++
)
{
references
.
content
.
push
(
{
id
:
response
.
data
.
references
[
i
].
title
,
name
:
`
${
response
.
data
.
references
[
i
].
authors
[
0
]}
et al.
${
response
.
data
.
references
[
i
].
journal
}
`
,
url
:
`https://www.ncbi.nlm.nih.gov/pubmed/
${
response
.
data
.
references
[
i
].
pubmed
}
`
,
url_label
:
"
Open in Pubmed
"
},
);
};
if
(
response
.
data
.
references
)
{
for
(
let
i
=
0
;
i
<
response
.
data
.
references
.
length
;
i
++
)
{
references
.
content
.
push
(
{
id
:
response
.
data
.
references
[
i
].
title
,
name
:
`
${
response
.
data
.
references
[
i
].
authors
[
0
]}
et al.
${
response
.
data
.
references
[
i
].
journal
}
`
,
url
:
`https://www.ncbi.nlm.nih.gov/pubmed/
${
response
.
data
.
references
[
i
].
pubmed
}
`
,
url_label
:
"
Open in Pubmed
"
},
);
};
}
return
references
;
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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