Commit 1e084c41 authored by hmueller's avatar hmueller
Browse files

Write "no match found" for results list when query had no matches.

parent 6a80c032
......@@ -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')
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"
documents = {}
tool = {'name': None, 'version': None, 'database': None}
......@@ -30,7 +35,11 @@ with open(filename) as f:
query_id = split[3]
if not query_id in documents:
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 present among initial queries!')
results = documents[query_id]['computations'][0]["results"]
results.append({
'target': {
......@@ -48,6 +57,13 @@ with open(filename) as f:
}
})
# Include queries with no matches in results
for query_id in queries:
print("In list: " + query_id)
if not query_id in documents:
print("Recording: " + query_id)
documents[query_id] = {"id": query_id, "computations": [{'tool': tool, 'results':"no match found"}]}
output_filename = args.output
with open(output_filename, 'w') as o:
json.dump(documents, o)
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