Commit 1a710984 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Added configurable dbxref database for blastp converter script

parent ab4892f2
......@@ -6,6 +6,7 @@ import argparse
parser = argparse.ArgumentParser(description='Convert blast results to json documents')
parser.add_argument('--result', '-r', required=True, help='The blast result file in outfmt 7 format (tsv with headers)')
parser.add_argument('--output', '-o', required=True, help='The converted results json file')
parser.add_argument('--dbxref', '-d', required=True, help='The dbxref prefix that will be prepended to the accession or id')
args = parser.parse_args()
filename = args.result
......@@ -36,7 +37,17 @@ with open(filename) as f:
results = documents[split[0]]['computations'][0]['results']
result = {'target':{}, 'query':{}}
result['target']["dbxref"] = "UniProtKB/Swiss-Prot:"+split[header['subject id']].split("|")[1]
# check if subject id or accession exists
sid = ''
if 'subject id' in header:
sid = header['subject id']
elif 'subject acc.ver' in header:
sid = header['subject acc.ver']
else:
raise Exception('No subject id found')
result['target']["dbxref"] = args.dbxref + ':' + split[sid]
if '% identity' in header:
result['target']["percent_identity"] = float(split[header['% identity']])
if 'q. start' in header and 'q. end' in header:
......
......@@ -19,3 +19,4 @@ analysis:
converter:
script: 'convert_blastp.py'
parameters:
dbxref: UniProtKB/Swiss-Prot
Supports Markdown
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