Skip to content

Commit

Permalink
Merge pull request #49 from Mesnage-Org/dataframe_error_ftrs_reader
Browse files Browse the repository at this point in the history
Added ppm and time delta widgets
  • Loading branch information
Ankur-AVP-Patel committed May 20, 2021
2 parents f18ba89 + 45434cc commit 84a7475
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pgfinder/validation.py
Expand Up @@ -16,6 +16,10 @@ def validate_raw_data_df(raw_data_df):

if not isinstance(raw_data_df, pd.DataFrame):
raise ValueError('raw_data_df must be a DataFrame.')

if isinstance(raw_data_df, pd.DataFrame):
print("File is okay")


colnames = ['ID',
'rt',
Expand All @@ -24,6 +28,7 @@ def validate_raw_data_df(raw_data_df):
'inferredStructure',
'maxIntensity']


if not set(colnames).issubset(set(raw_data_df.columns.to_list())):
raise('raw_data_df column names are incorrect')

Expand Down
83 changes: 79 additions & 4 deletions pgfinder_interactive.ipynb
Expand Up @@ -88,7 +88,13 @@
" else:\n",
" csv_filepath = os.path.join(mass_lists_path, rb_masses.value)\n",
" theo_masses = matching.theo_masses_reader(csv_filepath)\n",
" \n",
"\n",
" # Load ppm value\n",
" user_ppm = ppm_tol.value\n",
"\n",
" # Load time delta value\n",
" user_time_delta = time_delta.value\n",
"\n",
" # Make sure mod list is a list\n",
" mod_list = list(selector_mods.value)\n",
" \n",
Expand All @@ -97,7 +103,7 @@
" validation.validate_theo_masses_df(theo_masses)\n",
" validation.validate_enabled_mod_list(mod_list)\n",
"\n",
" results = matching.data_analysis(uploaded_df, theo_masses, 0.5, mod_list, 10)\n",
" results = matching.data_analysis(uploaded_df, theo_masses, user_time_delta, mod_list, user_ppm)\n",
" \n",
" # Make the download button\n",
" results_csv_str = results.to_csv()\n",
Expand Down Expand Up @@ -125,6 +131,9 @@
"# 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",
Expand Down Expand Up @@ -153,7 +162,29 @@
" description = 'Upload Mass Library',\n",
" multiple = False,\n",
" layout = big_button\n",
") \n",
")\n",
"\n",
"# Set PPM tolerance\n",
"ppm_tol = widgets.BoundedFloatText(\n",
" value = 10.0,\n",
" min = 1,\n",
" max = 100,\n",
" step = 0.1,\n",
" description = 'Set ppm tolerance',\n",
" disabled = False,\n",
" style = wide_style\n",
" )\n",
"\n",
"# Set time delta for in source clean up\n",
"time_delta = widgets.BoundedFloatText(\n",
" value = 0.5,\n",
" min = 0,\n",
" max = 100,\n",
" step = 0.01,\n",
" description = 'Set time delta value',\n",
" disabled = False,\n",
" style = wide_style\n",
")\n",
"\n",
"# Analysis button\n",
"button = widgets.Button(description=\"Run Analysis\")\n",
Expand Down Expand Up @@ -268,7 +299,51 @@
"hidePrompt": true
},
"source": [
"## Step 4: Run Analysis\n",
"## Step 4: Set PPM tolerance"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": true,
"hidePrompt": true
},
"outputs": [],
"source": [
"display(ppm_tol)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": true,
"hidePrompt": true
},
"source": [
"## Step 5: Set time window for in-source decay and salt adduct clean up"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": true,
"hidePrompt": true
},
"outputs": [],
"source": [
"display(time_delta)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": true,
"hidePrompt": true
},
"source": [
"## Step 6: Run Analysis\n",
"Click run analysis.\n",
"After the analysis is complete, a download button will appear."
]
Expand Down

0 comments on commit 84a7475

Please sign in to comment.