Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uploaded filename display in Jupyter Notebook #138

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 19 additions & 15 deletions pgfinder_interactive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
" # This widget returns a dictionary of details of uploaded files\n",
" # However, the widget is restricted to allow only one file\n",
" # Hence `.value[0]`\n",
" uploaded_df = pgio.ms_upload_reader(data_uploader.value[0])\n",
" uploaded_df = pgio.ms_upload_reader(data_uploader.children[0].value[0])\n",
" \n",
" # Load mass list\n",
" if rb_masses.value == 'Upload Custom':\n",
" theo_masses = pgio.theo_masses_upload_reader(mass_uploader.value[0])\n",
" theo_masses = pgio.theo_masses_upload_reader(mass_uploader.children[0].value[0])\n",
" else:\n",
" csv_filepath = os.path.join(mass_lists_path, rb_masses.value)\n",
" theo_masses = pgio.theo_masses_reader(csv_filepath)\n",
Expand Down Expand Up @@ -98,19 +98,28 @@
" \n",
"# Define widgets\n",
"\n",
"# A composite widget for picking a file and displaying its name\n",
"def named_file_upload(accept, description):\n",
" file_upload = widgets.FileUpload(\n",
" accept = accept, \n",
" description = description,\n",
" multiple = False,\n",
" layout = big_button\n",
" )\n",
" file_name = widgets.Label(value=\"No file selected...\")\n",
" def handle_file_upload(file):\n",
" file_name.value = file[\"new\"][0][\"name\"]\n",
" file_upload.observe(handle_file_upload, names='value')\n",
" return widgets.HBox([file_upload, file_name])\n",
"\n",
"# Layout for a bigger button\n",
"big_button = widgets.Layout(width='auto')\n",
"\n",
"# Style for wider description\n",
"wide_style = {'description_width': 'initial'}\n",
"\n",
"# Deconvoluted Data file upload\n",
"data_uploader = widgets.FileUpload(\n",
" accept = '.txt,.ftrs', \n",
" description = 'Upload Deconvoluted Data',\n",
" multiple = False,\n",
" layout = big_button\n",
") \n",
"data_uploader = named_file_upload('.txt,.ftrs', 'Upload Deconvoluted Data')\n",
"\n",
"# Modifcation selector\n",
"selector_mods = widgets.SelectMultiple(\n",
Expand All @@ -127,12 +136,7 @@
")\n",
"\n",
"# Mass library file upload\n",
"mass_uploader = widgets.FileUpload(\n",
" accept = '.csv', \n",
" description = 'Upload Mass Library',\n",
" multiple = False,\n",
" layout = big_button\n",
")\n",
"mass_uploader = named_file_upload('.csv', 'Upload Mass Library')\n",
"\n",
"# Set PPM tolerance\n",
"ppm_tol = widgets.BoundedFloatText(\n",
Expand Down Expand Up @@ -348,7 +352,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down