From 120c3e1fc7d6418c9a7b6d05f96708f951e28bc4 Mon Sep 17 00:00:00 2001 From: YoungKrug <31873199+YoungKrug@users.noreply.github.com> Date: Tue, 22 Aug 2023 17:05:49 -0400 Subject: [PATCH 1/4] Added unit test for convert functionality --- tests/test_convert_key_translations.py | 121 +++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 tests/test_convert_key_translations.py diff --git a/tests/test_convert_key_translations.py b/tests/test_convert_key_translations.py new file mode 100644 index 0000000..fe5dcb6 --- /dev/null +++ b/tests/test_convert_key_translations.py @@ -0,0 +1,121 @@ +import uparma +import pytest +import json +import os +from pathlib import Path + +test_input_dict = { + "allow_multiple_variable_mods_on_residue": False, + "mass_diff_to_variable_mod": False, +} + +test_parameter_list = [ + { + "input": { + ("general", "parameters"): [ + { + "default_value": False, + "description": " Put mass difference as a variable modification.", + "key_translations": { + "msfragger_style_3": "mass_diff_to_variable_mod", + "ursgal_style_1": "mass_diff_to_variable_mod" + }, + "name": "write_mass_diff_to_variable_mod", + "tag": [], + "triggers_rerun": True, + "value_translations": { + "msfragger_style_3": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ] + }, + "value_type": "bool" + }, + { + "default_value": False, + "description": " Static mods are not considered ", + "key_translations": { + "mascot_style_1": "MULTI_SITE_MODS", + "msfragger_style_1": "allow_multiple_variable_mods_on_residue", + "msfragger_style_2": "allow_multiple_variable_mods_on_residue", + "msfragger_style_3": "allow_multiple_variable_mods_on_residue", + "ursgal_style_1": "allow_multiple_variable_mods_on_residue" + }, + "name": "allow_multiple_variable_mods_on_residue", + "tag": [ + "modifications" + ], + "triggers_rerun": True, + "value_translations": { + "mascot_style_1": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "msfragger_style_1": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "msfragger_style_2": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "msfragger_style_3": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "ursgal_style_1": [ + [ + False, + False + ], + [ + True, + True + ] + ] + }, + "value_type": "bool" + } + ] + } + } +] + +@pytest.mark.parametrize("test_parameters", test_parameter_list) +def test_load_data(test_parameters): + up = uparma.UParma(refresh_jsons=False, parameter_data=test_parameter_list[0]["input"]) + translation = up.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") + assert translation["allow_multiple_variable_mods_on_residue"]["was_translated"] + assert translation["allow_multiple_variable_mods_on_residue"]["translated_value"] == 0 + assert translation["write_mass_diff_to_variable_mod"]["was_translated"] + assert translation["write_mass_diff_to_variable_mod"]["translated_value"] == 0 \ No newline at end of file From 6c9fc4323800bb83e6fe4bccf79ab5de233613fd Mon Sep 17 00:00:00 2001 From: YoungKrug <31873199+YoungKrug@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:07:30 -0400 Subject: [PATCH 2/4] Added more test cases --- tests/test_convert_key_translations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_convert_key_translations.py b/tests/test_convert_key_translations.py index fe5dcb6..4306c40 100644 --- a/tests/test_convert_key_translations.py +++ b/tests/test_convert_key_translations.py @@ -1,5 +1,6 @@ import uparma import pytest +import pprint import json import os from pathlib import Path @@ -7,6 +8,7 @@ test_input_dict = { "allow_multiple_variable_mods_on_residue": False, "mass_diff_to_variable_mod": False, + "enzyme_specificity": "full" } test_parameter_list = [ @@ -110,11 +112,13 @@ } } ] - @pytest.mark.parametrize("test_parameters", test_parameter_list) def test_load_data(test_parameters): up = uparma.UParma(refresh_jsons=False, parameter_data=test_parameter_list[0]["input"]) translation = up.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") + up_with_parameter_json = uparma.UParma(refresh_jsons=False) + translation_params = up_with_parameter_json.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") + assert translation_params["enzyme_specificity"]["was_translated"] assert translation["allow_multiple_variable_mods_on_residue"]["was_translated"] assert translation["allow_multiple_variable_mods_on_residue"]["translated_value"] == 0 assert translation["write_mass_diff_to_variable_mod"]["was_translated"] From 565835aab883288b5eaaf5b547b6775ed6f0427d Mon Sep 17 00:00:00 2001 From: YoungKrug <31873199+YoungKrug@users.noreply.github.com> Date: Thu, 24 Aug 2023 12:37:33 -0400 Subject: [PATCH 3/4] Slight changes --- tests/test_convert_key_translations.py | 68 +++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/tests/test_convert_key_translations.py b/tests/test_convert_key_translations.py index 4306c40..ea46787 100644 --- a/tests/test_convert_key_translations.py +++ b/tests/test_convert_key_translations.py @@ -8,7 +8,8 @@ test_input_dict = { "allow_multiple_variable_mods_on_residue": False, "mass_diff_to_variable_mod": False, - "enzyme_specificity": "full" + "enzyme_specificity": "full", + "localize_delta_mass": True } test_parameter_list = [ @@ -107,6 +108,65 @@ ] }, "value_type": "bool" + }, + { + "default_value": True, + "description": " Generate and use mass difference fragment index in addition to the regular fragment index for search. This allows shifted fragment ions - fragment ions with mass increased by the calculated mass difference, to be included in scoring. ", + "key_translations": { + "msfragger_style_1": "localize_delta_mass", + "msfragger_style_2": "localize_delta_mass", + "msfragger_style_3": "localize_delta_mass", + "ursgal_style_1": "localize_delta_mass" + }, + "name": "localize_delta_mass", + "tag": [ + "scoring", + "spectrum" + ], + "triggers_rerun": True, + "value_translations": { + "msfragger_style_1": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "msfragger_style_2": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "msfragger_style_3": [ + [ + False, + 0 + ], + [ + True, + 1 + ] + ], + "ursgal_style_1": [ + [ + False, + False + ], + [ + True, + True + ] + ] + }, + "value_type": "bool" } ] } @@ -116,10 +176,6 @@ def test_load_data(test_parameters): up = uparma.UParma(refresh_jsons=False, parameter_data=test_parameter_list[0]["input"]) translation = up.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") - up_with_parameter_json = uparma.UParma(refresh_jsons=False) - translation_params = up_with_parameter_json.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") - assert translation_params["enzyme_specificity"]["was_translated"] - assert translation["allow_multiple_variable_mods_on_residue"]["was_translated"] + assert translation["localize_delta_mass"]["translated_value"] == 1 assert translation["allow_multiple_variable_mods_on_residue"]["translated_value"] == 0 - assert translation["write_mass_diff_to_variable_mod"]["was_translated"] assert translation["write_mass_diff_to_variable_mod"]["translated_value"] == 0 \ No newline at end of file From 0c3dc083b2467c1ee4616ef3b5a181c2fca47ba7 Mon Sep 17 00:00:00 2001 From: YoungKrug <31873199+YoungKrug@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:17:37 -0400 Subject: [PATCH 4/4] Update to the convert_key_translation_test --- tests/test_convert_key_translations.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_convert_key_translations.py b/tests/test_convert_key_translations.py index ea46787..6add5b5 100644 --- a/tests/test_convert_key_translations.py +++ b/tests/test_convert_key_translations.py @@ -6,10 +6,9 @@ from pathlib import Path test_input_dict = { - "allow_multiple_variable_mods_on_residue": False, - "mass_diff_to_variable_mod": False, - "enzyme_specificity": "full", - "localize_delta_mass": True + "allow_multiple_variable_mods_on_residue": True, + "mass_diff_to_variable_mod": True, + "localize_delta_mass": False } test_parameter_list = [ @@ -176,6 +175,7 @@ def test_load_data(test_parameters): up = uparma.UParma(refresh_jsons=False, parameter_data=test_parameter_list[0]["input"]) translation = up.convert(param_dict=test_input_dict, translated_style="msfragger_style_3") - assert translation["localize_delta_mass"]["translated_value"] == 1 - assert translation["allow_multiple_variable_mods_on_residue"]["translated_value"] == 0 - assert translation["write_mass_diff_to_variable_mod"]["translated_value"] == 0 \ No newline at end of file + assert translation["allow_multiple_variable_mods_on_residue"]["translated_value"] == 1 + assert translation["allow_multiple_variable_mods_on_residue"]["was_translated"] + assert translation["write_mass_diff_to_variable_mod"]["translated_value"] == 1 + assert translation["write_mass_diff_to_variable_mod"]["was_translated"]