Skip to content

Commit

Permalink
Adaptations for SDRF file creation from MetabolLights studies mention…
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshoffmann committed Jan 30, 2024
1 parent a793cc2 commit da0bd61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from PIL import Image
import base64
import io

max_samples = 350

st.set_page_config(
page_title="lesSDRF",
layout="wide",
Expand Down Expand Up @@ -105,12 +108,12 @@ def load_data():
Upload your intermediate SDRF file here:""")

upload_df = st.file_uploader(
"Upload intermediate SDRF file", type=["tsv"], accept_multiple_files=False, help='Upload a previously saved SDRF file. It should be in tsv format and should not contain more than 250 samples'
"Upload intermediate SDRF file", type=["tsv"], accept_multiple_files=False, help=f'Upload a previously saved SDRF file. It should be in tsv format and should not contain more than {max_samples} samples'
)
if upload_df is not None:
template_df = pd.read_csv(upload_df, sep='\t')
if template_df.shape[0]>250:
st.error('Too many samples, please upload a maximum of 250 samples')
if template_df.shape[0]>max_samples:
st.error(f'Too many samples, please upload a maximum of {max_samples}')
else:
st.write(template_df)
st.session_state["template_df"] = template_df
Expand Down Expand Up @@ -150,8 +153,8 @@ def load_data():
#remove trailing and leading spaces
uploaded_names = [name.strip() for name in uploaded_names]
filenames.append(uploaded_names)
if len(filenames[0]) > 250:
st.error('Too many samples, please upload a maximum of 250 samples')
if len(filenames[0]) > max_samples:
st.error(f'Too many samples, please upload a maximum of {max_samples} samples')
else:
st.write(f"Added filenames: {filenames[0]}")
## Store filenames in the dataframe
Expand Down
6 changes: 4 additions & 2 deletions pages/1_1. Mapping_local_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_base64_image(image):
"""If you have a local metadata file available, you can use this file to map the data to the required SDRF information. """
)
st.markdown(
"""**Important:** you can upload the file in csv, tsv or xlsx format.
"""**Important:** you can upload the file in csv, tsv, txt (tab-separated), or xlsx format.
The order of your raw file names should match the order in which you inputted them in the previous step"""
)

Expand All @@ -77,14 +77,16 @@ def get_base64_image(image):
*The experimental metadata has been generated using lesSDRF and is available through ProteomeXchange with the dataset identifier [PXDxxxxxxx]*""")
# Ask the user to upload their own metadata file and to map it to the columns of the template file
metadata_sheet = st.file_uploader(
"Upload your local metadata file (.csv, .tsv or .xls)", type=["csv", "tsv", "xlsx"]
"Upload your local metadata file (.csv, .tsv, .txt (tab-separated), or .xls)", type=["csv", "tsv", "txt", "xlsx"]
)
if metadata_sheet is not None:
file_extension = metadata_sheet.name.split(".")[-1]
if file_extension == "csv":
metadata_df = pd.read_csv(metadata_sheet)
elif file_extension == "tsv":
metadata_df = pd.read_csv(metadata_sheet, sep="\t")
elif file_extension == "txt":
metadata_df = pd.read_csv(metadata_sheet, sep="\t")
elif file_extension == "xlsx":
metadata_df = pd.read_excel(metadata_sheet)
st.write("Your metadata file:")
Expand Down

0 comments on commit da0bd61

Please sign in to comment.