Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
dbxref
Commits
8e3b1456
Commit
8e3b1456
authored
Jan 22, 2018
by
Lukas Jelonek
Browse files
Refactor gene ontology retriever into an internal retriever
parent
bb6b8a52
Changes
2
Hide whitespace changes
Inline
Side-by-side
dbxref/providers.yaml
View file @
8e3b1456
...
...
@@ -94,8 +94,8 @@
json
:
[
"
https://www.ebi.ac.uk/QuickGO/services/ontology/go/terms/GO:%i/complete"
]
check_existence
:
"
http://purl.obolibrary.org/obo/GO_%i"
retriever
:
type
:
'
ex
ternal'
location
:
'
scripts/
retrieve
_
gene_ontology
.py
'
type
:
'
in
ternal'
location
:
'
dbxref.
retrieve
.
gene_ontology'
-
name
:
HTTP
prefixes
:
[
"
http"
,
"
https"
]
resources
:
...
...
scripts
/retrieve
_
gene_ontology.py
→
dbxref
/retrieve
/
gene_ontology.py
View file @
8e3b1456
#!/usr/bin/env python3
import
env
import
dbxref.config
import
dbxref.resolver
import
requests
import
logging
...
...
@@ -18,8 +15,14 @@ def main():
args
=
parser
.
parse_args
()
if
not
args
.
basic
and
not
args
.
relations
:
args
.
basic
=
True
args
.
relations
=
True
resolved
=
dbxref
.
resolver
.
resolve
(
args
.
dbxrefs
,
check_existence
=
False
)
args
.
relations
=
False
dbxrefs
=
dbxref
.
resolver
.
convert_to_dbxrefs
(
args
.
dbxrefs
)
documents
=
retrieve
(
dbxrefs
,
basic
=
args
.
basic
,
relations
=
args
.
relations
)
print
(
json
.
dumps
(
documents
))
def
retrieve
(
dbxrefs
,
basic
=
True
,
relations
=
False
):
resolved
=
dbxref
.
resolver
.
resolve
(
dbxrefs
,
check_existence
=
False
)
documents
=
[]
for
entry
in
resolved
:
json_url
=
entry
[
'locations'
][
'json'
][
0
]
...
...
@@ -31,12 +34,12 @@ def main():
if
'messages'
in
d
:
output
[
'message'
]
=
'; '
.
join
(
d
[
'messages'
])
else
:
if
args
.
basic
:
if
basic
:
output
.
update
(
read_basic
(
d
))
if
args
.
relations
:
if
relations
:
output
.
update
(
read_relations
(
d
))
documents
.
append
(
output
)
print
(
json
.
dumps
(
documents
))
return
documents
def
read_basic
(
d
):
out
=
{
'definition'
:
d
[
'results'
][
0
][
'definition'
][
'text'
],
'synonyms'
:
[]}
...
...
@@ -86,4 +89,5 @@ def parse_text(t):
out
[
'type'
]
=
type
return
(
out
)
main
()
if
__name__
==
'__main__'
:
main
()
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