![]() |
Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
|
Public Member Functions | |
| __init__ (self, Dict input_json, str update_flags_file, str output_json_path) | |
| List[Dict] | parse_update_flags_file (self) |
| Dict | add_update_panel_gui_json (self, List[Dict] flag_entries) |
| generate (self) | |
Protected Member Functions | |
| str | _escape_for_python_string (self, Optional[str] s) |
Inject an "Update Panel" into an existing GUI JSON.
This reads an `update_area_flags.txt`-style file where each line describes a
parameter to expose in the Update Panel:
-w, Label, Description
Each entry becomes a row composed of an Entry (labeled), plus an info icon
(ⓘ) that shows the description. An "Update Results" button is appended to
the bottom to re-run post-analysis with the new parameters.
Attributes:
input_json: GUI JSON (may include a Frame labeled "Update Panel").
update_flags_file: Path to a file containing update-area flags with format: flag, label, description.
output_json_path: Destination path for the augmented JSON.
Inject an "Update Panel" into an existing GUI JSON. Reads an update_area_flags.txt-style file and adds corresponding widgets.
| __init__ | ( | self, | |
| Dict | input_json, | ||
| str | update_flags_file, | ||
| str | output_json_path ) |
Initialize the update panel generator.
Args:
input_json: The base GUI JSON to modify in-place.
update_flags_file: File path containing lines of the form
`-flag, Label, Description` (commas separate the 3 fields).
output_json_path: Destination JSON file path for the result.
|
protected |
Escape quotes, backslashes, and control chars for safe embedding.
Parameters
----------
s : str | None
Raw string to escape; ``None`` yields an empty string.
Returns
-------
str
Escaped representation suitable for inclusion in JSON or generated
Python code.
| Dict add_update_panel_gui_json | ( | self, | |
| List[Dict] | flag_entries ) |
Inject widgets and an Update button into the "Update Panel" frame.
For each flag entry, creates a Label + Entry + Info Icon (ⓘ) with tooltip.
Finally, adds an "Update Results" button.
Args:
flag_entries: List of flag dictionaries with `flag`, `label`, and `description`.
Returns:
The modified GUI JSON dictionary (same object, mutated in place).
Side effects:
- Mutates `self.input_json` by replacing the children of the "Update Panel".
| generate | ( | self | ) |
Run the full process and write the resulting JSON to disk. Steps: 1. Parse update-area flags from file. 2. Mutate `input_json` via `add_update_panel_gui_json`. 3. Write the final JSON to `output_json_path`. Prints user-friendly warnings for recoverable issues and returns early if no valid flags are found.
| List[Dict] parse_update_flags_file | ( | self | ) |
Parse the update-area flags file to extract flag entries.
Expected format per line: `-flag, Label, Description`.
Returns:
A list of dicts with keys: `flag`, `label`, `description`.
Error handling:
- Ignores blank lines and lines starting with `#`.
- Prints a warning for malformed lines and continues.
- Prints a warning if the file cannot be found.