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

Merge branch 'hmmscan-empty-results' into 'develop'

Hmmscan empty results

See merge request SOaAS/psot!4
parents f67b0373 f404a49c
...@@ -9,6 +9,11 @@ parser.add_argument('--output', '-o', required=True, help='The converted results ...@@ -9,6 +9,11 @@ parser.add_argument('--output', '-o', required=True, help='The converted results
parser.add_argument('--dbxref', '-d', required=True, help='The dbxref prefix that will be prepended to the accession or id') parser.add_argument('--dbxref', '-d', required=True, help='The dbxref prefix that will be prepended to the accession or id')
args = parser.parse_args() args = parser.parse_args()
query_file = args.result + "/queries.json"
queries = []
with open(query_file) as f:
queries = json.load(f)
filename = args.result + "/domtblout.tsv" filename = args.result + "/domtblout.tsv"
documents = {} documents = {}
tool = {'name': None, 'version': None, 'database': None} tool = {'name': None, 'version': None, 'database': None}
...@@ -30,7 +35,11 @@ with open(filename) as f: ...@@ -30,7 +35,11 @@ with open(filename) as f:
query_id = split[3] query_id = split[3]
if not query_id in documents: if not query_id in documents:
documents[query_id] = {"id": query_id, "computations": [{'tool': tool, 'results':[]}]} documents[query_id] = {"id": query_id, "computations": [{'tool': tool, 'results':[]}]}
results = documents[query_id]['computations'][0]["results"] try:
queries.remove(query_id)
except ValueError:
print('HMMER converter: Query ID "' + query_id + '" not found among initial queries!')
results = documents[query_id]['computations'][0]["results"]
results.append({ results.append({
'target': { 'target': {
...@@ -48,6 +57,10 @@ with open(filename) as f: ...@@ -48,6 +57,10 @@ with open(filename) as f:
} }
}) })
for query_id in queries:
if not query_id in documents:
documents[query_id] = {"id": query_id, "computations": [{'tool': tool, 'results':[]}]}
output_filename = args.output output_filename = args.output
with open(output_filename, 'w') as o: with open(output_filename, 'w') as o:
json.dump(documents, o) json.dump(documents, o)
#!/usr/bin/env python3 #!/usr/bin/env python3
import env import env
import argparse import argparse
import json
from psot import config from psot import config
from os import system, makedirs from os import system, makedirs
...@@ -17,8 +18,20 @@ makedirs(args.output, exist_ok=True) ...@@ -17,8 +18,20 @@ makedirs(args.output, exist_ok=True)
system(hmmscan_tool + system(hmmscan_tool +
" -E " + args.evalue + " -E " + args.evalue +
" -o " +args.output+ "/hmmscan.out " + " -o " + args.output + "/hmmscan.out " +
" --tblout " + args.output + "/tblout.tsv " + " --tblout " + args.output + "/tblout.tsv " +
" --domtblout " + args.output + "/domtblout.tsv " + " --domtblout " + args.output + "/domtblout.tsv " +
" --pfamtblout " + args.output + "/pfamtblout.tsv " + " --pfamtblout " + args.output + "/pfamtblout.tsv " +
args.database + " " + args.fasta) args.database + " " + args.fasta)
# Provide a list of all query sequence names for conversion process
queries = []
with open(args.fasta) as f:
for line in f:
if line.startswith('>'):
queries.append(line.split()[0].strip().lstrip('>'))
query_file = args.output + '/queries.json'
with open(query_file, 'w') as o:
json.dump(queries, 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