From ffe805dd595ced4bb7e420f2657ceee40798507f Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Wed, 7 Aug 2024 12:54:42 +0200 Subject: [PATCH 1/2] Added test, to detect bug. --- tests/test_add_classifier_annotations.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_add_classifier_annotations.py b/tests/test_add_classifier_annotations.py index f6852cdf..8b05b8f2 100644 --- a/tests/test_add_classifier_annotations.py +++ b/tests/test_add_classifier_annotations.py @@ -23,3 +23,10 @@ def test_add_classifier_annotation(spectra): result = select_compound_classes(spectra) assert sorted(result) == [['WRIPSIKIDAUKBP', 'Organic compounds', 'Phenylpropanoids and polyketides', 'Macrolactams', '', 'Macrolactams', '', '', 'Alkaloids', 'False'], ['WXDBUBIFYCCNLE', 'Organic compounds', 'Organoheterocyclic compounds', 'Oxepanes', '', 'Oxepanes', 'Lipopeptides', 'Oligopeptides', 'Amino acids and Peptides', 'False']] + + +def test_add_classifier_annotation_unknown_inchikey(spectra): + """This tests that when no compound class annotation is found, that it is correctly filled with empty strings""" + spectra[1].set("inchikey", "AAAAAAAAAAAAAA") + result = select_compound_classes(spectra) + assert len(result[0]) == len(result[1]) From 64824e747134b3df638ea67e3a832cfc67ab5d73 Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Wed, 7 Aug 2024 12:54:54 +0200 Subject: [PATCH 2/2] Fixed bug --- ms2query/create_new_library/add_classifire_classifications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ms2query/create_new_library/add_classifire_classifications.py b/ms2query/create_new_library/add_classifire_classifications.py index e28f3ef8..587f2a54 100644 --- a/ms2query/create_new_library/add_classifire_classifications.py +++ b/ms2query/create_new_library/add_classifire_classifications.py @@ -115,7 +115,7 @@ def select_compound_classes(spectra): break if cf_classes is None: print(f"no classyfire annotation was found for inchikey {inchikey14}") - inchikey_results_list[i].append([inchikey14, "", "", "", "", ""]) + inchikey_results_list[i] += ["", "", "", "", ""] # select NPC classes npc_results = None