Commit c48bce70 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Add dbxref to ghostx converter. Adapt to blastp and hmmscan json format (Fixes #19)

parent 152c2c54
......@@ -6,6 +6,9 @@ import argparse
parser = argparse.ArgumentParser(description='Convert ghostx results to json documents')
parser.add_argument('--result', '-r', required=True, help='The ghostx result directory')
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')
parser.add_argument('--acc_split', '-s', required=False, help='The delimiter used to split the subject id (optional)')
parser.add_argument('--acc_position', '-p', type=int, required=False, help='The position of the accession after splitting the subject_id (optional)')
args = parser.parse_args()
result_directory = args.result
......@@ -27,11 +30,22 @@ with open(result_filename) as f:
results = documents[split[0]]['computations'][0]['results']
result = {}
result["dbxref"] = "UniProtKB/Swiss-Prot:"+split[1].split("|")[1]
result["percent_identity"] = float(split[2])
result['qloc'] = split[6] + '-' + split[7]
result['sloc'] = split[8] + '-' + split[9]
result['evalue'] = float(split[10])
accession = split[1]
if args.acc_split and args.acc_position:
accession = accession.split(args.acc_split)[args.acc_position]
elif args.acc_split:
accession = acession.split(args.acc_split)[0]
result['query'] = {
'start': split[6],
'end': split[7]
}
result['target'] = {
'dbxref': args.dbxref + ':' + accession,
'start': split[8],
'end': split[9],
'evalue': float(split[10]),
'percent_identity': float(split[2])
}
results.append(result)
......
......@@ -17,4 +17,7 @@ analysis:
# result file from the analysis_script
converter:
script: 'convert_ghostx.py'
parameters:
dbxref: 'UniProtKB/Swiss-Prot'
acc_split: '|'
acc_position: '1'
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