From 09e3c75c2fca6278fb0885132d1a0029abd64999 Mon Sep 17 00:00:00 2001 From: valentynbez Date: Wed, 5 Jun 2024 22:27:20 +0200 Subject: [PATCH] fix: empty results against PDB --- mDeepFRI/mmseqs.py | 11 ++++++++--- mDeepFRI/pipeline.py | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mDeepFRI/mmseqs.py b/mDeepFRI/mmseqs.py index 8b8d066..4c15452 100644 --- a/mDeepFRI/mmseqs.py +++ b/mDeepFRI/mmseqs.py @@ -341,9 +341,14 @@ def from_best_matches(cls, filepath: str): delimiter="\t", encoding="utf-8", names=True) - - query_file = np.unique(result_arr["query_file"])[0] - database = np.unique(result_arr["database_file"])[0] + try: + query_file = np.unique(result_arr["query_file"])[0] + except IndexError: + query_file = None + try: + database = np.unique(result_arr["database_file"])[0] + except IndexError: + database = None return cls(result_arr, query_file, database) diff --git a/mDeepFRI/pipeline.py b/mDeepFRI/pipeline.py index 7097f3e..1879fe0 100644 --- a/mDeepFRI/pipeline.py +++ b/mDeepFRI/pipeline.py @@ -102,8 +102,13 @@ def hierarchical_database_search(query_file: str, # store the location of the result for the next step db.mmseqs_result = mmseqs_results_path - # logging - unique_hits = np.unique(best_matches["query"]) + # catch error if no matches to database + # a case from phage proteins + try: + unique_hits = np.unique(best_matches["query"]) + except IndexError: + unique_hits = np.array([]) + if "pdb100" in db.name: pdb_hits = unique_hits else: