Commit 8e3b1456 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Refactor gene ontology retriever into an internal retriever

parent bb6b8a52
......@@ -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: 'external'
location: 'scripts/retrieve_gene_ontology.py'
type: 'internal'
location: 'dbxref.retrieve.gene_ontology'
- name: HTTP
prefixes: ["http", "https"]
resources:
......
#!/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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment