From 1b29fcc0d2a1898be69f19b96d71451be8185770 Mon Sep 17 00:00:00 2001 From: bkieft-usa Date: Tue, 27 Aug 2024 09:12:14 -0700 Subject: [PATCH] Fix check for unlabeled/labeled compounds so ISTD atlas compounds are in the correct order --- metatlas/io/metatlas_get_data_helper_fun.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metatlas/io/metatlas_get_data_helper_fun.py b/metatlas/io/metatlas_get_data_helper_fun.py index 66e58f33..b32c32bc 100644 --- a/metatlas/io/metatlas_get_data_helper_fun.py +++ b/metatlas/io/metatlas_get_data_helper_fun.py @@ -41,8 +41,9 @@ def sort_atlas_csv(input_csv: str, column1: str, column2: str, istd_atlas: bool) # Sort the DataFrame based on the specified columns in ascending order if istd_atlas == True: if 'label' in df.columns: - if 'unlabeled' not in df['label'].values: - logger.info("Warning: The designation 'unlabeled' does not appear in the 'label' column. Only set 'istd_atlas' to True if this is an internal standard atlas with isotopic labeling.") + if not df['label'].str.contains('unlabeled').any(): + logger.info("Warning: The designation 'unlabeled' does not appear in the 'label' column. Only set 'istd_atlas' to True if this is an internal standard atlas with isotopic labeling. Exiting!") + sys.exit(1) df['rt_peak'] = df.apply(lambda row: row['rt_peak'] + 0.1 if 'unlabeled' in row['label'] else row['rt_peak'], axis=1) sorted_df = df.sort_values(by=[column1, column2], ascending=[True, True]) sorted_df['rt_peak'] = sorted_df.apply(lambda row: row['rt_peak'] - 0.1 if 'unlabeled' in row['label'] else row['rt_peak'], axis=1)