Skip to content
Snippets Groups Projects
Commit ded79224 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Adapted blast json document to the signalp document structure

parent 184e0d46
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,8 @@ import json
filename = sys.argv[1]
documents = {}
with open(filename) as f:
header = {}
header = None
tool = None
for line in f:
line = line.strip()
if line.startswith('#'):
......@@ -14,10 +15,19 @@ with open(filename) as f:
header = {}
for idx, key in enumerate(header_entries):
header[key] = idx
if line.startswith('# BLASTP'):
split = line.split()
tool = {'name': 'blastp',
'version': split[2]}
if line.startswith('# Database'):
split = line.split()
tool['database'] = split[2]
else:
split = line.split("\t")
if not split[0] in documents:
documents[split[0]] = {"id": split[0], "results": []}
documents[split[0]] = {"id": split[0], "computations": [{'tool':tool, 'results':[]}]}
results = documents[split[0]]['computations'][0]['results']
result = {}
result["dbxref"] = "UniProtKB/Swiss-Prot:"+split[header['subject id']].split("|")[1]
......@@ -32,7 +42,7 @@ with open(filename) as f:
if 'BTOP' in header:
result['btop'] = split[header['BTOP']]
documents[split[0]]["results"].append(result)
results.append(result)
for key in documents:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment