diff --git a/molecular-librarysearch-v2/Makefile b/molecular-librarysearch-v2/Makefile index a1f5f583..bc95ff2a 100644 --- a/molecular-librarysearch-v2/Makefile +++ b/molecular-librarysearch-v2/Makefile @@ -3,5 +3,5 @@ include ../Makefile.deploytemplate WORKFLOW_NAME=molecular-librarysearch-v2 TOOL_FOLDER_NAME=molecularsearch -WORKFLOW_VERSION=release_28 +WORKFLOW_VERSION=release_29 WORKFLOW_DESCRIPTION="One of the major limitations in discovering new chemical entities is determining which metabolites are known compounds within complex biological samples. A way to overcome this limitation is to compare the MS2 spectra of the unknown metabolite with a library of MS/MS spectra generated from structurally characterized metabolites. Herein, this comparison is based upon the similarity cosine scoring of MS/MS spectra." diff --git a/molecular-librarysearch-v2/tools/molecularsearch/group_results_by_annotation.py b/molecular-librarysearch-v2/tools/molecularsearch/group_results_by_annotation.py index 276e1d8f..11ddfdc3 100644 --- a/molecular-librarysearch-v2/tools/molecularsearch/group_results_by_annotation.py +++ b/molecular-librarysearch-v2/tools/molecularsearch/group_results_by_annotation.py @@ -15,6 +15,7 @@ def main(): input_filename = sys.argv[1] output_tsv = sys.argv[2] + # Loading annotations results_list = ming_fileio_library.parse_table_with_headers_object_list(input_filename) results_by_compound_name = defaultdict(list) for result in results_list: @@ -26,9 +27,15 @@ def main(): for compound_name in results_by_compound_name: best_result = sorted(results_by_compound_name[compound_name], key=lambda result: float(result["MQScore"]), reverse=True)[0] - all_RTs = [float(result["RT_Query"]) for result in results_by_compound_name[compound_name]] - all_MZs = [float(result["SpecMZ"]) for result in results_by_compound_name[compound_name]] - all_MZ_ppmerror = [float(result["MZErrorPPM"]) for result in results_by_compound_name[compound_name]] + # Calculating errors, handling errors + try: + all_RTs = [float(result["RT_Query"]) for result in results_by_compound_name[compound_name]] + all_MZs = [float(result["SpecMZ"]) for result in results_by_compound_name[compound_name]] + all_MZ_ppmerror = [float(result["MZErrorPPM"]) for result in results_by_compound_name[compound_name]] + except: + all_RTs = [-1] + all_MZs = [-1] + all_MZ_ppmerror = [-1] rt_mean = statistics.mean(all_RTs) rt_median = statistics.median(all_RTs)