Skip to content

Commit 8336132

Browse files
committed
docs: add parameter presets documentation
Document the new presets feature in three locations: - docs/user_guide.md: User-facing guide on how to use preset buttons - docs/build_app.md: Developer guide on presets.json format and structure - docs/toppframework.py: Interactive TOPP framework docs with st.help() https://claude.ai/code/session_01BnipAqTf16J7kJVfnzah2U
1 parent 2636bdb commit 8336132

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

docs/build_app.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,73 @@ value=params["example-y-dimension"], step=1, key="example-y-dimension")
2222
save_params()
2323
```
2424

25+
- **Parameter Presets**
26+
: Presets provide quick configuration options for workflows. Define presets in `presets.json` at the repository root. Presets are automatically displayed as buttons in the parameter section when defined for a workflow.
27+
28+
## Parameter Presets
29+
30+
Presets allow users to quickly apply optimized parameter configurations. They are defined in `presets.json` at the repository root.
31+
32+
### presets.json Format
33+
34+
```json
35+
{
36+
"workflow-name": {
37+
"Preset Name": {
38+
"_description": "Tooltip description shown on hover",
39+
"TOPPToolName": {
40+
"algorithm:section:param_name": value
41+
},
42+
"_general": {
43+
"custom_param_key": value
44+
}
45+
}
46+
}
47+
}
48+
```
49+
50+
### Structure Details
51+
52+
| Key | Description |
53+
|-----|-------------|
54+
| `workflow-name` | Must match the workflow name (lowercase, hyphens instead of spaces). E.g., "TOPP Workflow" → "topp-workflow" |
55+
| `Preset Name` | Display name for the preset button |
56+
| `_description` | Optional tooltip text (keys prefixed with `_` are metadata) |
57+
| `TOPPToolName` | Dictionary of TOPP tool parameters to override |
58+
| `_general` | Dictionary of general workflow parameters (custom `input_widget` keys) |
59+
60+
### Example
61+
62+
```json
63+
{
64+
"topp-workflow": {
65+
"High Sensitivity": {
66+
"_description": "Optimized for detecting low-abundance features",
67+
"FeatureFinderMetabo": {
68+
"algorithm:common:noise_threshold_int": 500.0,
69+
"algorithm:common:chrom_peak_snr": 2.0
70+
}
71+
},
72+
"Fast Analysis": {
73+
"_description": "Quick processing with relaxed parameters",
74+
"FeatureFinderMetabo": {
75+
"algorithm:common:noise_threshold_int": 2000.0
76+
},
77+
"FeatureLinkerUnlabeledKD": {
78+
"algorithm:link:rt_tol": 60.0
79+
}
80+
}
81+
}
82+
}
83+
```
84+
85+
### How It Works
86+
87+
1. Preset buttons automatically appear in `parameter_section()` via `StreamlitUI.preset_buttons()`
88+
2. Only presets matching the current workflow name are displayed
89+
3. Clicking a preset updates `params.json` and refreshes the UI
90+
4. If no `presets.json` exists or no presets match the workflow, no buttons are shown
91+
2592
## Code structure
2693
- The main file `app.py` defines page layout.
2794
- **Pages** must be placed in the `content` directory.

docs/toppframework.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from src.workflow.StreamlitUI import StreamlitUI
44
from src.workflow.FileManager import FileManager
55
from src.workflow.CommandExecutor import CommandExecutor
6+
from src.workflow.ParameterManager import ParameterManager
67
from inspect import getsource
78

89
def content():
@@ -136,6 +137,52 @@ def content():
136137
st.help(StreamlitUI.select_input_file)
137138
st.help(StreamlitUI.input_TOPP)
138139
st.help(StreamlitUI.input_python)
140+
141+
st.markdown(
142+
"""
143+
## Parameter Presets
144+
145+
Presets provide a way to offer users quick parameter configuration options for common analysis scenarios.
146+
147+
### Enabling Presets
148+
149+
1. Create a `presets.json` file at the repository root
150+
2. Add preset definitions for your workflow (workflow name must be normalized: lowercase with hyphens)
151+
3. Presets automatically appear in the parameter section via `self.ui.preset_buttons()`
152+
153+
### presets.json Structure
154+
155+
```json
156+
{
157+
"your-workflow-name": {
158+
"Preset Display Name": {
159+
"_description": "Tooltip text for the button",
160+
"TOPPToolName": {
161+
"algorithm:param:path": value
162+
},
163+
"_general": {
164+
"custom_widget_key": value
165+
}
166+
}
167+
}
168+
}
169+
```
170+
171+
### Key Points
172+
173+
- **Workflow matching**: Workflow name is normalized (lowercase, hyphens for spaces). "TOPP Workflow" → "topp-workflow"
174+
- **TOPP parameters**: Use the full parameter path (e.g., `algorithm:common:noise_threshold_int`)
175+
- **General parameters**: Use `_general` for custom `input_widget` parameters
176+
- **Descriptions**: Keys prefixed with `_` are metadata (not applied as parameters)
177+
- **Opt-in feature**: No `presets.json` = no buttons shown (backward compatible)
178+
"""
179+
)
180+
181+
with st.expander("**Code documentation**", expanded=True):
182+
st.help(StreamlitUI.preset_buttons)
183+
st.help(ParameterManager.load_presets)
184+
st.help(ParameterManager.apply_preset)
185+
139186
st.markdown(
140187
"""
141188
## Building the Workflow

docs/user_guide.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,23 @@ To get started:
5555
4. Run the analysis.
5656
5. View and download your results.
5757

58-
For more detailed information on each step, refer to the specific sections of this guide.
58+
For more detailed information on each step, refer to the specific sections of this guide.
59+
60+
## Parameter Presets
61+
62+
Parameter presets allow you to quickly apply optimized parameter configurations for common analysis scenarios. When available, preset buttons appear on the parameter configuration page.
63+
64+
### Using Presets
65+
66+
1. Navigate to the parameter configuration page
67+
2. Look for the **Parameter Presets** section below the "Show advanced parameters" toggle
68+
3. Hover over a preset button to see its description
69+
4. Click a preset to apply its optimized parameters
70+
5. A confirmation message will appear when the preset is applied
71+
72+
### What Presets Do
73+
74+
- Presets override specific tool parameters with pre-configured values
75+
- Only the parameters defined in the preset are changed; other parameters remain at their current values
76+
- You can still modify individual parameters after applying a preset
77+
- Use **Load default parameters** to reset all parameters to their original defaults

0 commit comments

Comments
 (0)