From 720d06900ebf5a57b0dcfe221701fcc64bb9787d Mon Sep 17 00:00:00 2001 From: Micha Birklbauer Date: Thu, 11 Jan 2024 13:44:04 +0100 Subject: [PATCH] finalize tests --- tests/tests.py | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/tests.py b/tests/tests.py index 099655f..a785db1 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -74,3 +74,105 @@ def test5_msannika_fdr(): # check nr of grouped crosslinks assert result[0].shape[0] == 3192 + +# csms file with fdr should validate +def test6_msannika_fdr(): + + import pandas as pd + from msannika_fdr import main + from msannika_fdr import MSAnnika_CSM_Validator as csm_val + + result = main(["DSSO_CSMs.xlsx", "-fdr", "0.01"]) + + # check nr of results + assert len(result) == 3 + + #### crosslinks #### + + # check nr of grouped crosslinks + assert result[0].shape[0] == 3192 + + #### validated crosslinks #### + + # check nr of validated crosslinks + assert result[2].shape[0] == 714 + + # check fdr of validated crosslinks + assert result[2][result[2]["Decoy"] == True].shape[0] / result[2][result[2]["Decoy"] == False].shape[0] < 0.01 + + #### validated csms #### + + # check nr of validated csms + assert result[1].shape[0] == 3021 + + # check fdr of validated csms + results[1]["Class"] = pd.apply(lambda row: csm_val.get_class(row), axis = 1) + assert result[1][result[1]["Class"] == "Decoy"].shape[0] / result[1][result[1]["Class"] == "Target"].shape[0] < 0.01 + +# csms file with fdr should validate +def test7_msannika_fdr(): + + import pandas as pd + from msannika_fdr import main + from msannika_fdr import MSAnnika_CSM_Validator as csm_val + + result = main(["DSSO_CSMs.xlsx", "-fdr", "1"]) + + # check nr of results + assert len(result) == 3 + + #### crosslinks #### + + # check nr of grouped crosslinks + assert result[0].shape[0] == 3192 + + #### validated crosslinks #### + + # check nr of validated crosslinks + assert result[2].shape[0] == 714 + + # check fdr of validated crosslinks + assert result[2][result[2]["Decoy"] == True].shape[0] / result[2][result[2]["Decoy"] == False].shape[0] < 0.01 + + #### validated csms #### + + # check nr of validated csms + assert result[1].shape[0] == 3021 + + # check fdr of validated csms + results[1]["Class"] = pd.apply(lambda row: csm_val.get_class(row), axis = 1) + assert result[1][result[1]["Class"] == "Decoy"].shape[0] / result[1][result[1]["Class"] == "Target"].shape[0] < 0.01 + +# csms file with fdr should validate +def test8_msannika_fdr(): + + import pandas as pd + from msannika_fdr import main + from msannika_fdr import MSAnnika_CSM_Validator as csm_val + + result = main(["DSSO_CSMs.xlsx", "-fdr", "0.05"]) + + # check nr of results + assert len(result) == 3 + + #### crosslinks #### + + # check nr of grouped crosslinks + assert result[0].shape[0] == 3192 + + #### validated crosslinks #### + + # check nr of validated crosslinks + assert result[2].shape[0] == 807 + + # check fdr of validated crosslinks + assert result[2][result[2]["Decoy"] == True].shape[0] / result[2][result[2]["Decoy"] == False].shape[0] < 0.01 + + #### validated csms #### + + # check nr of validated csms + assert result[1].shape[0] == 3331 + + # check fdr of validated csms + results[1]["Class"] = pd.apply(lambda row: csm_val.get_class(row), axis = 1) + assert result[1][result[1]["Class"] == "Decoy"].shape[0] / result[1][result[1]["Class"] == "Target"].shape[0] < 0.01