diff --git a/Data/cached/example_1/metabolomics/calculated_now.pkl b/Data/cached/example_1/metabolomics/calculated_now.pkl new file mode 100644 index 0000000..7ffbad9 Binary files /dev/null and b/Data/cached/example_1/metabolomics/calculated_now.pkl differ diff --git a/Source/case_study.py b/Source/case_study.py index c2f22ac..079b5d4 100644 --- a/Source/case_study.py +++ b/Source/case_study.py @@ -27,6 +27,8 @@ path_case_study_viz = os.path.join( path_case_study_root_data, 'visualizations') +CALCULATED_DATA_SET_NAME = 'calculated.pkl' +CALCULATED_NOW_DATA_SET_NAME = 'calculated_now.pkl' path_case_study_genomics_fasta = os.path.join( path_case_study_genomics, 'rmags_filtered') path_case_study_genomics_kegg = os.path.join(path_case_study_genomics, 'KEGG') @@ -34,11 +36,15 @@ path_case_study_genomics_depths = os.path.join( path_case_study_genomics, 'MG_Depths') path_case_study_transcriptomics_depths = os.path.join( - path_case_study_genomics, 'MT_Depths') + path_case_study_transcriptomics, 'MT_Depths') path_case_study_proteomics_fasta = os.path.join( path_case_study_proteomics, 'set_of_78') -path_case_study_metabolomics_precalculated = os.path.join( - path_case_study_metabolomics, 'fig4.tsv') +path_case_study_metabolomics_prec_1 = os.path.join( + path_case_study_metabolomics, CALCULATED_DATA_SET_NAME) +path_case_study_metabolomics_prec_2 = os.path.join( + path_case_study_metabolomics, CALCULATED_NOW_DATA_SET_NAME) +path_case_study_phy_che_prec_1 = os.path.join( + path_case_study_phy_che, CALCULATED_DATA_SET_NAME) def upload_multiple(key_suffix): @@ -53,8 +59,10 @@ def upload_multiple(key_suffix): 'Metatranscriptomics': { 'Depth-of-coverage': 'DEPTH'}, 'Metabolomics': { - 'Processed data set 1': 'PR1', - 'Processed data set 2': 'PR2'} + 'Processed data set 1': 'CALC', + 'Processed data set 2': 'CALC'}, + 'Physico-chemical': { + 'Processed data set 1': 'CALC'} } selected_data_set_type = st.selectbox( @@ -65,12 +73,10 @@ def upload_multiple(key_suffix): if key_suffix == 'Metagenomics': if selected_data_set_type == 'Raw FASTA files': return_path = path_case_study_genomics_fasta - # elif selected_data_set_type == 'KEGG annotation files': # return_path = path_case_study_genomics_kegg elif selected_data_set_type == 'Depth-of-coverage': return_path = path_case_study_genomics_depths - else: return_path = path_case_study_genomics_bins @@ -80,16 +86,19 @@ def upload_multiple(key_suffix): elif key_suffix == 'Metatranscriptomics': return_path = path_case_study_transcriptomics_depths - # TODO: Add calculated 1 and calculated 2 data sets here and maybe remove - # TODO: upload introand move everything here elif key_suffix == 'Metabolomics': if selected_data_set_type == 'Processed data set 1': - return_path = path_case_study_genomics_fasta + return_path = path_case_study_metabolomics_prec_1 + elif selected_data_set_type == 'Processed data set 2': + return_path = path_case_study_metabolomics_prec_2 + else: + pass - # elif selected_data_set_type == 'KEGG annotation files': - # return_path = path_case_study_genomics_kegg - elif selected_data_set_type == 'Depth-of-coverage': - return_path = path_case_study_genomics_depths + elif key_suffix == 'Physico-chemical': + if selected_data_set_type == 'Processed data set 1': + return_path = path_case_study_phy_che_prec_1 + else: + pass else: pass @@ -102,28 +111,20 @@ def upload_intro(folder_path, key_suffix): st.header(key_suffix + ' data') st.markdown('') - df = None - - if key_suffix in ['Metabolomics', 'Physico-chemical']: - CALCULATED_DATA_SET_NAME = 'calculated.pkl' - CALCULATED_DATA_SET_PATH = os.path.join( - folder_path, CALCULATED_DATA_SET_NAME) + return_path = None + return_path, data_set_type = upload_multiple(key_suffix) - if os.path.exists(CALCULATED_DATA_SET_PATH): - df = common.get_cached_dataframe(CALCULATED_DATA_SET_PATH) - else: - st.error('Wrong cache path') - st.stop() - - return df + if return_path is None: + st.warning('Upload your data set') + # We return DataFrame if we work with tabular data format or precalculated + # We return folder_path and data_set_type if we work with archived data + if data_set_type == 'CALC': + return_path_or_df = common.get_cached_dataframe(return_path) else: - df, data_set_type = upload_multiple(key_suffix) - - if df is None: - st.warning('Upload your data set') + return_path_or_df = return_path - return df, data_set_type + return return_path_or_df, data_set_type def case_study_genomics(): @@ -152,9 +153,11 @@ def case_study_metabolomics(): key_suffix = 'Metabolomics' cache_folder_path = path_case_study_metabolomics - df = upload_intro(cache_folder_path, key_suffix) + folder_path_or_df, data_set_type = upload_intro( + cache_folder_path, key_suffix) - return common.work_with_csv(df, cache_folder_path, key_suffix) + return common.work_with_csv( + folder_path_or_df, cache_folder_path, key_suffix) def case_study_transcriptomics(): @@ -172,9 +175,11 @@ def case_study_phy_che(): key_suffix = 'Physico-chemical' cache_folder_path = path_case_study_phy_che - df = upload_intro(cache_folder_path, key_suffix) + folder_path_or_df, data_set_type = upload_intro( + cache_folder_path, key_suffix) - return common.work_with_csv(df, cache_folder_path, key_suffix) + return common.work_with_csv( + folder_path_or_df, cache_folder_path, key_suffix) def create_main_case_study(): diff --git a/Source/upload.py b/Source/upload.py index 66ba04f..ef4ddc5 100644 --- a/Source/upload.py +++ b/Source/upload.py @@ -123,7 +123,6 @@ def upload_csv(key_suffix): return None else: - # Checking file extension for the first file only imported_file_extension = os.path.splitext( imported_files[0].name)[1][1:].strip().lower()