Commit f2096889 authored by lmueller's avatar lmueller
Browse files

bundle dbxrefs before retrieving them => fewer calls

parent c0db9a40
......@@ -7,7 +7,6 @@ import sys
parser = argparse.ArgumentParser(description='Resolve dbxrefs from json file')
parser.add_argument('--input', '-i', required=True, help='The json input document')
parser.add_argument('--retriever', '-s', required=True, help='Location of retriever')
#parser.add_argument('--output', '-o', required=True, help='Name of the output document')
args = parser.parse_args()
basename = args.retriever.replace('scripts/', '')
......@@ -18,16 +17,19 @@ from retriever import retrieve
json_file = open(args.input).read()
j = json.loads(json_file)
#di = []
refs = []
for c in j['computations']:
for r in c['results']:
if 'target'in r and 'dbxref' in r['target']:
di = retrieve([r['target']['dbxref']], basename)
r['target']['dbxref'] = {'dbxref': r['target']['dbxref'], 'informations': di[0]}
refs.append(r['target']['dbxref'])
entries = retrieve(sorted(refs), basename)
for c in j['computations']:
for r in c['results']:
if 'target'in r and 'dbxref' in r['target']:
r['target']['dbxref'] = {'dbxref': r['target']['dbxref'], 'informations': next(entry for entry in entries if entry['id'] == r['target']['dbxref'])}
#output_filename = args.output
#with open(output_filename, 'w') as o:
with open(args.input, 'w') as o:
json.dump(j, o)
This diff is collapsed.
{"id": "seq_10.cds_1", "computations": [{"tool": {"database": "/vol/biodb/ghostx/uniprot_sprot", "version": "1.3.6", "name": "ghostx"}, "results": [{"query": {"end": "111", "start": "97"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:Q4KDI2", "start": "81", "evalue": 63.2141, "end": "95", "percent_identity": 66.6667}}, {"query": {"end": "79", "start": "62"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:O64556", "start": "94", "evalue": 140.826, "end": "111", "percent_identity": 55.5556}}, {"query": {"end": "61", "start": "45"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:Q9CKF7", "start": "695", "evalue": 140.826, "end": "711", "percent_identity": 58.8235}}, {"query": {"end": "112", "start": "79"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:Q9UT11", "start": "129", "evalue": 183.925, "end": "161", "percent_identity": 38.2353}}, {"query": {"end": "111", "start": "97"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:Q4ZRC6", "start": "89", "evalue": 240.213, "end": "103", "percent_identity": 60.0}}, {"query": {"end": "101", "start": "79"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:Q11B48", "start": "9", "evalue": 313.728, "end": "31", "percent_identity": 47.8261}}, {"query": {"end": "63", "start": "2"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:B1XSQ1", "start": "102", "evalue": 409.742, "end": "163", "percent_identity": 27.4194}}, {"query": {"end": "79", "start": "62"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:O65924", "start": "95", "evalue": 409.742, "end": "112", "percent_identity": 50.0}}, {"query": {"end": "48", "start": "31"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:B5RBC1", "start": "201", "evalue": 409.742, "end": "218", "percent_identity": 55.5556}}, {"query": {"end": "79", "start": "62"}, "target": {"dbxref": "UniProtKB/Swiss-Prot:O64483", "start": "94", "evalue": 535.14, "end": "111", "percent_identity": 50.0}}]}, {"tool": {"version": "4.1", "mode": "euk", "name": "SignalP"}, "results": [{"signalpeptide": false}]}, {"tool": {"version": "2.0", "name": "TMHMM"}, "results": {"ExpAA": 0.03, "PredHel": 0, "topology": [{"location": "outside", "end": 115, "start": 1}], "First60": 0.0}}]}
\ No newline at end of file
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