Skip to content

Commit c15697d

Browse files
committed
Warning added for missing metadata file
1 parent 8d9e68b commit c15697d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pages/1_Data_Preparation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
st.session_state["ft_gnps"], st.session_state["md_gnps"] = load_from_gnps(task_id, cmn= cmn_flag)
5454

5555
if not st.session_state["ft_gnps"].empty and st.session_state["md_gnps"].empty:
56-
st.warning("Meta data is empty. Please upload one.")
56+
st.warning("⚠️ **Metadata file is missing.** The metadata is essential for performing statistical analysis and understanding the context of your data. Please upload one.")
5757

5858
md_file = st.file_uploader("Meta Data Table")
5959
if md_file:

src/fileselection.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ def load_from_gnps(task_id, cmn=False):
7878
an_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={task_id}&file=DB_result/&block=main"
7979

8080
ft = pd.read_csv(ft_url)
81-
md = pd.read_csv(md_url, sep="\t", index_col="filename")
82-
an = pd.read_csv(an_url, sep = "\t")[["#Scan#", "Compound_Name"]].set_index("#Scan#")
81+
try:
82+
md = pd.read_csv(md_url, sep="\t", index_col="filename")
83+
except (urllib.error.HTTPError, FileNotFoundError, KeyError, pd.errors.EmptyDataError):
84+
md = pd.DataFrame()
85+
86+
try:
87+
an = pd.read_csv(an_url, sep="\t")[["#Scan#", "Compound_Name"]].set_index("#Scan#")
88+
except (pd.errors.EmptyDataError, FileNotFoundError, KeyError):
89+
an = pd.DataFrame()
8390

84-
if md.empty: # Handle empty metadata
91+
if not isinstance(md, pd.DataFrame): # Handle empty metadata
8592
md = pd.DataFrame()
8693

8794
if cmn:

0 commit comments

Comments
 (0)