Commit 5ea07f52 authored by lmueller's avatar lmueller
Browse files

got resolve_dbxrefs.py working, still unstable

parent 89c7cfc7
......@@ -4,24 +4,46 @@ import json
import argparse
import os
import sys
sys.path.insert(0, '../../dbxref/dbxref')
sys.path.insert(0, '../../dbxref')
import retriever
import subprocess
parser = argparse.ArgumentParser(description='Resolve dbxrefs from json file')
parser.add_argument('--input', '-i', required=True, help='The json input document')
#parser.add_argument('--output', '-o', required=True, help='The name of the output document')
parser.add_argument('--scripts', '-s', required=True, help='Location of the retriever scripts')
parser.add_argument('--output', '-o', required=True, help='Name of the output document')
args = parser.parse_args()
joined = {}
json_file = open(args.input).read()
json = json.loads(json_file)
j = json.loads(json_file)
for c in json['computations']:
li = c['results']['informations']
di = retriever.retrieve(li)
def sort_refs(ref_list):
refs = {}
for ref in ref_list:
ble = ref.split(':')
if ble[0] in refs:
refs[ble[0]].append(ble[0] + ":" + ble[1])
else:
refs[ble[0]] = [ble[0] + ":" + ble[1]]
return (refs)
#output_filename = args.output
#with open(output_filename, 'w') as o:
# json.dump(joined, o)
script_dir = args.scripts
di = []
for c in j['computations']:
for r in c['results']:
refs = sort_refs(r['informations'])
if 'EC' in refs:
di.append(json.loads(str(subprocess.check_output(script_dir + "retrieve_enzyme.py " + " ".join(refs['EC']), shell=True).rstrip())[2:-1]))
if 'GO' in refs:
di.append(json.loads(str(subprocess.check_output(script_dir + "retrieve_gene_ontology.py " + " ".join(refs['GO']), shell=True).rstrip())[2:-1]))
# if 'PFAM' in refs:
# di = json.loads(str(subprocess.check_output(script_dir + "retrieve_pfam.py " + " ".join(refs['PFAM']), shell=True).rstrip())[2:-1])
if 'SO' in refs:
di.append(json.loads(str(subprocess.check_output(script_dir + "retrieve_sequence_ontology.py " + " ".join(refs['SO']), shell=True).rstrip())[2:-1]))
if 'UniProtKB/Swiss-Prot' in refs:
di.append(json.loads(str(subprocess.check_output(script_dir + "retrieve_uniprot.py " + " ".join(refs['UniProtKB/Swiss-Prot']), shell=True).rstrip())[2:-1]))
# print (json.dumps(di))
output_filename = args.output
with open(output_filename, 'w') as o:
json.dump(di, o)
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