-
Notifications
You must be signed in to change notification settings - Fork 1
Add FLASHIda Support #8
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
base: develop
Are you sure you want to change the base?
Changes from 15 commits
24fab38
ba12395
ea2c197
d7f38e8
ab83f5f
c9d4b34
117c883
620ec30
c8e8725
fb0023f
6c505a0
ec82253
4aa74b2
c455a48
3395328
fabecf5
95d89cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import streamlit as st | ||
|
|
||
| from src.Workflow import IdaSimulatorWorkflow | ||
| from src.common.common import page_setup | ||
|
|
||
|
|
||
| params = page_setup() | ||
|
|
||
| wf = IdaSimulatorWorkflow() | ||
|
|
||
| st.title('FLASHIda - Intelligent Data Acquisition') | ||
|
|
||
| t = st.tabs(["📁 **File Upload**", "⚙️ **Configure**", "🚀 **Run**"]) | ||
| with t[0]: | ||
| wf.show_file_upload_section() | ||
|
|
||
| with t[1]: | ||
| wf.show_parameter_section() | ||
|
|
||
| with t[2]: | ||
| wf.show_execution_section() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import streamlit as st | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from src.common.common import page_setup, save_params | ||
| from src.workflow.FileManager import FileManager | ||
| from src.render.render import render_grid | ||
|
|
||
| DEFAULT_LAYOUT = [['ms1_deconv_heat_map']] | ||
|
|
||
| def select_experiment(): | ||
| st.session_state.selected_experiment0_ida = st.session_state.selected_experiment_dropdown_ida | ||
| print(st.session_state.selected_experiment0_ida) | ||
| if len(layout) > 1: | ||
| for exp_index in range(1, len(layout)): | ||
| if st.session_state[f'selected_experiment_dropdown_{exp_index}_ida'] is None: | ||
| continue | ||
| st.session_state[f"selected_experiment{exp_index}_ida"] = st.session_state[f'selected_experiment_dropdown_{exp_index}_ida'] | ||
|
|
||
| def validate_selected_index(file_manager, selected_experiment): | ||
| results = file_manager.get_results_list(['simulation_dfs']) | ||
| if selected_experiment in st.session_state: | ||
| if st.session_state[selected_experiment] in results: | ||
| return name_to_index[st.session_state[selected_experiment]] | ||
| else: | ||
| del st.session_state[selected_experiment] | ||
| return None | ||
|
Comment on lines
+20
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix global variable dependency in validation function. The -def validate_selected_index(file_manager, selected_experiment):
+def validate_selected_index(file_manager, selected_experiment, name_to_index):
results = file_manager.get_results_list(['simulation_dfs'])
if selected_experiment in st.session_state:
if st.session_state[selected_experiment] in results:
return name_to_index[st.session_state[selected_experiment]]
else:
del st.session_state[selected_experiment]
return None🤖 Prompt for AI Agents |
||
|
|
||
| # page initialization | ||
| params = page_setup() | ||
|
|
||
| # Get available results | ||
| file_manager = FileManager( | ||
| st.session_state["workspace"], | ||
| Path(st.session_state['workspace'], 'flashidasimulator', 'cache') | ||
| ) | ||
|
|
||
| results = file_manager.get_results_list(['simulation_dfs']) | ||
|
|
||
| if file_manager.result_exists('layout', 'layout'): | ||
| layout = file_manager.get_results('layout', 'layout')['layout'] | ||
| side_by_side = layout['side_by_side'] | ||
| layout = layout['layout'] | ||
|
|
||
| else: | ||
| layout = [DEFAULT_LAYOUT] | ||
| side_by_side = False | ||
|
|
||
| ### if no input file is given, show blank page | ||
| if len(results) == 0: | ||
| st.error('No results to show yet. Please run a workflow first!') | ||
| st.stop() | ||
|
|
||
| # Map names to index | ||
| name_to_index = {n : i for i, n in enumerate(results)} | ||
|
|
||
| if len(layout) == 2 and side_by_side: | ||
| c1, c2 = st.columns(2) | ||
| with c1: | ||
| st.selectbox( | ||
| "choose experiment", results, | ||
| key="selected_experiment_dropdown_ida", | ||
| index=validate_selected_index(file_manager, 'selected_experiment0_ida'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update function calls to pass required parameters. Since the helper functions now need additional parameters, update the function calls accordingly. - index=validate_selected_index(file_manager, 'selected_experiment0_ida'),
- on_change=select_experiment
+ index=validate_selected_index(file_manager, 'selected_experiment0_ida', name_to_index),
+ on_change=lambda: select_experiment(layout)Apply similar changes to other function calls. Also applies to: 75-75, 91-91, 114-114 🤖 Prompt for AI Agents |
||
| on_change=select_experiment | ||
| ) | ||
| if 'selected_experiment0_ida' in st.session_state: | ||
| render_grid( | ||
| st.session_state.selected_experiment0_ida, layout[0], file_manager, | ||
| 'flashidasimulator', "selected_experiment0_ida", 'flash_viewer_grid_0_ida' | ||
| ) | ||
| with c2: | ||
| st.selectbox( | ||
| "choose experiment", results, | ||
| key=f'selected_experiment_dropdown_1_ida', | ||
| index=validate_selected_index(file_manager, 'selected_experiment1_ida'), | ||
| on_change=select_experiment | ||
| ) | ||
| if f"selected_experiment1_ida" in st.session_state: | ||
| with st.spinner('Loading component...'): | ||
| render_grid( | ||
| st.session_state["selected_experiment1_ida"], layout[1], | ||
| file_manager, 'flashidasimulator', 'selected_experiment1_ida', | ||
| 'flash_viewer_grid_1_ida' | ||
| ) | ||
|
|
||
| else: | ||
| ### for only single experiment on one view | ||
| st.selectbox( | ||
| "choose experiment", results, | ||
| key="selected_experiment_dropdown_ida", | ||
| index=validate_selected_index(file_manager, 'selected_experiment0_ida'), | ||
| on_change=select_experiment | ||
| ) | ||
|
|
||
|
|
||
| if 'selected_experiment0_ida' in st.session_state: | ||
| print('Lets go!') | ||
| render_grid( | ||
| st.session_state.selected_experiment0_ida, layout[0], file_manager, | ||
| 'flashidasimulator', 'selected_experiment0_ida' | ||
| ) | ||
|
|
||
| ### for multiple experiments on one view | ||
| if len(layout) > 1: | ||
|
|
||
| for exp_index, exp_layout in enumerate(layout): | ||
| if exp_index == 0: continue # skip the first experiment | ||
|
|
||
| st.divider() # horizontal line | ||
|
|
||
| st.selectbox( | ||
| "choose experiment", results, | ||
| key=f'selected_experiment_dropdown_{exp_index}_ida', | ||
| index=validate_selected_index(file_manager, f'selected_experiment{exp_index}_ida'), | ||
| on_change=select_experiment | ||
| ) | ||
| # if #experiment input files are less than #layouts, all the pre-selection will be the first experiment | ||
| if f"selected_experiment{exp_index}_ida" in st.session_state: | ||
| render_grid( | ||
| st.session_state["selected_experiment%d_ida" % exp_index], | ||
| layout[exp_index], file_manager, 'flashidasimulator', | ||
| "selected_experiment%d_ida" % exp_index, | ||
| 'flash_viewer_grid_%d_ida' % exp_index | ||
| ) | ||
|
|
||
| save_params(params) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import streamlit as st | ||
|
|
||
| from src.Workflow import IdaWorkflow | ||
| from src.common.common import page_setup | ||
|
|
||
|
|
||
| params = page_setup() | ||
|
|
||
| wf = IdaWorkflow() | ||
|
|
||
| st.title('FLASHIda - Intelligent Data Acquisition') | ||
|
|
||
| t = st.tabs(["⚙️ **Configure**", "🚀 **Run**"]) | ||
|
|
||
|
|
||
| with t[0]: | ||
| wf.show_parameter_section() | ||
|
|
||
| with t[1]: | ||
| wf.show_execution_section() |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import xml.etree.ElementTree as ET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ############################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # default paramter values # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ########################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Mandatory keys for each parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # key: a unique identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # value: the default value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional keys for each parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # name: the name of the parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # hide: don't show the parameter in the parameter section (e.g. for input/output files) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # options: a list of valid options for the parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # min: the minimum value for the parameter (int and float) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # max: the maximum value for the parameter (int and float) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # step_size: the step size for the parameter (int and float) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # help: a description of the parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # widget_type: the type of widget to use for the parameter (default: auto) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # advanced: whether or not the parameter is advanced (default: False) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEFAULTS = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {"key": "in", "value": [], "help": "Input files for Python Script.", "hide": True}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'TopN', 'name': 'TopN', 'value': 3}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Duration', 'name': 'Duration', 'value': 67}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'MS1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Analyzer', 'name': 'Analyzer', 'value': 'Orbitrap'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'FirstMass', 'name': 'FirstMass', 'value': 400}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'LastMass', 'name': 'LastMass', 'value': 2000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'OrbitrapResolution', 'name': 'OrbitrapResolution', 'value': 120000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'AGCTarget', 'name': 'AGCTarget', 'value': 800000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MaxIT', 'name': 'MaxIT', 'value': 50}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Microscans', 'name': 'Microscans', 'value': 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'DataType', 'name': 'DataType', 'value': 'Centroid'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'RFLens', 'name': 'RFLens', 'value': 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'SourceCID', 'name': 'SourceCID', 'value': 0}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'MS2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Analyzer', 'name': 'Analyzer', 'value': 'Orbitrap'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'FirstMass', 'name': 'FirstMass', 'value': 200}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'OrbitrapResolution', 'name': 'OrbitrapResolution', 'value': 60000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'AGCTarget', 'name': 'AGCTarget', 'value': 500000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MaxIT', 'name': 'MaxIT', 'value': 118}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Microscans', 'name': 'Microscans', 'value': 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'DataType', 'name': 'DataType', 'value': 'Centroid'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Activation', 'name': 'Activation', 'value': 'HCD'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'CollisionEnergy', 'name': 'CollisionEnergy', 'value': 29}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'IDA', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MaxMs2CountPerMs1', 'name': 'MaxMs2CountPerMs1','value': 4}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'QScoreThreshold', 'name': 'QScoreThreshold', 'value': 0.2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'TQScoreThreshold', 'name': 'TQScoreThreshold', 'value': 0.99}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MinCharge', 'name': 'MinCharge', 'value': 4}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MaxCharge', 'name': 'MaxCharge', 'value': 50}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MinMass', 'name': 'MinMass', 'value': 500}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'MaxMass', 'name': 'MaxMass', 'value': 50000}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'Tolerances', 'name': 'Tolerances', 'value': [10.0, 10.0]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'TargetLogs', 'name': 'TargetLogs', 'value': [r'C:\Users\KyowonJeong\Desktop\FLASHIdaTmp\test1.log']}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'RTWindow', 'name': 'RTWindow', 'value': 180}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'TargetMode', 'name': 'TargetMode', 'value': 0}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'UseFAIMS', 'name': 'UseFAIMS', 'value': False}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'UseCVQScore', 'name': 'UseCVQScore', 'value': False}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'CycleTime', 'name': 'CycleTime', 'value': 180}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {'key': 'CVValues', 'name': 'CVValues', 'value': [-10.0, -30.0, -40.0, -50.0, -60.0]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix DEFAULTS structure and formatting issues. There are several issues with the DEFAULTS list:
{"key": "in", "value": [], "help": "Input files for Python Script.", "hide": True},
{'key': 'TopN', 'name': 'TopN', 'value': 3},
{'key': 'Duration', 'name': 'Duration', 'value': 67},
- 'MS1',
+ 'MS1',
{'key': 'Analyzer', 'name': 'Analyzer', 'value': 'Orbitrap'},
{'key': 'FirstMass', 'name': 'FirstMass', 'value': 400},
{'key': 'LastMass', 'name': 'LastMass', 'value': 2000},
{'key': 'OrbitrapResolution', 'name': 'OrbitrapResolution', 'value': 120000},
{'key': 'AGCTarget', 'name': 'AGCTarget', 'value': 800000},
{'key': 'MaxIT', 'name': 'MaxIT', 'value': 50},
{'key': 'Microscans', 'name': 'Microscans', 'value': 1},
{'key': 'DataType', 'name': 'DataType', 'value': 'Centroid'},
{'key': 'RFLens', 'name': 'RFLens', 'value': 30},
{'key': 'SourceCID', 'name': 'SourceCID', 'value': 0},
'MS2',
{'key': 'Analyzer', 'name': 'Analyzer', 'value': 'Orbitrap'},
{'key': 'FirstMass', 'name': 'FirstMass', 'value': 200},
{'key': 'OrbitrapResolution', 'name': 'OrbitrapResolution', 'value': 60000},
{'key': 'AGCTarget', 'name': 'AGCTarget', 'value': 500000},
{'key': 'MaxIT', 'name': 'MaxIT', 'value': 118},
{'key': 'Microscans', 'name': 'Microscans', 'value': 1},
{'key': 'DataType', 'name': 'DataType', 'value': 'Centroid'},
{'key': 'Activation', 'name': 'Activation', 'value': 'HCD'},
{'key': 'CollisionEnergy', 'name': 'CollisionEnergy', 'value': 29},
'IDA',
- {'key': 'MaxMs2CountPerMs1', 'name': 'MaxMs2CountPerMs1','value': 4},
+ {'key': 'MaxMs2CountPerMs1', 'name': 'MaxMs2CountPerMs1', 'value': 4},
🧰 Tools🪛 Flake8 (7.2.0)[error] 52-52: missing whitespace after ',' (E231) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_params(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(sys.argv) > 1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with open(sys.argv[1], "r") as f: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return json.load(f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add proper function spacing and improve function design. The function lacks proper spacing and could be more robust. +
def get_params():
if len(sys.argv) > 1:
with open(sys.argv[1], "r") as f:
return json.load(f)
else:
return {}
+📝 Committable suggestion
Suggested change
🧰 Tools🪛 Flake8 (7.2.0)[error] 68-68: expected 2 blank lines, found 1 (E302) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params = get_params() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_xml = params.pop('input_xml') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create method.xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| root = ET.Element("MethodParameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subsections = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for key, value in params.items(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ':' in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| section, param = key.split(':') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if section not in subsections: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subsections[section] = ET.SubElement(root, section) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| section = subsections[section] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag = ET.SubElement(section, param) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag = ET.SubElement(root, key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Handle list inputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if key in ['IDA:Tolerances', 'IDA:CVValues']: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for item in value.split('\n'): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| element = ET.SubElement(tag, 'double') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| element.text = item.strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif key in ['IDA:TargetLogs']: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for item in value.split('\n'): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| element = ET.SubElement(tag, 'string') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| element.text = item.strip().replace('\\\\', '\\') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif isinstance(value, bool): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag.text = str(value).lower() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tag.text = str(value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tree = ET.ElementTree(root) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ET.indent(tree, space=" ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tree.write(input_xml, encoding="utf-8", xml_declaration=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+75
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add proper spacing and improve error handling. The main execution block needs better spacing and error handling for missing keys. +
if __name__ == "__main__":
params = get_params()
- input_xml = params.pop('input_xml')
+ if 'input_xml' not in params:
+ raise ValueError("Missing required 'input_xml' parameter")
+ input_xml = params.pop('input_xml')
# Create method.xml
root = ET.Element("MethodParameters")
subsections = {}
for key, value in params.items():
if ':' in key:
section, param = key.split(':')
if section not in subsections:
subsections[section] = ET.SubElement(root, section)
section = subsections[section]
tag = ET.SubElement(section, param)
else:
tag = ET.SubElement(root, key)
# Handle list inputs
if key in ['IDA:Tolerances', 'IDA:CVValues']:
for item in value.split('\n'):
element = ET.SubElement(tag, 'double')
element.text = item.strip()
elif key in ['IDA:TargetLogs']:
for item in value.split('\n'):
element = ET.SubElement(tag, 'string')
element.text = item.strip().replace('\\\\', '\\')
else:
tag.text = str(value)
tree = ET.ElementTree(root)
ET.indent(tree, space=" ")
tree.write(input_xml, encoding="utf-8", xml_declaration=True)📝 Committable suggestion
Suggested change
🧰 Tools🪛 Flake8 (7.2.0)[error] 75-75: expected 2 blank lines after class or function definition, found 1 (E305) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix global variable dependencies in function.
The
select_experimentfunction referenceslayoutand other variables from the global scope, which makes it non-reusable and harder to test.📝 Committable suggestion
🤖 Prompt for AI Agents