![]() |
Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
|
Public Member Functions | |
| __init__ (self, str app_name, str exe, Dict input_json, str flags_file, str post_script, str output_json_path) | |
| Dict | add_input_gui_json (self, List[str] selected_flags, List[Dict] flag_entries, str header) |
| generate (self) | |
Static Public Member Functions | |
| Optional[Dict] | find_flag_entry (List[Dict] flag_entries, str flag_txt_entry) |
Protected Member Functions | |
| str | _escape_for_python_string (self, str s) |
Inject an input panel into a GUI JSON based on CLI help text.
The generator parses an executable's `--help` output, filters for a selected
set of flags, and adds corresponding widgets (entries/checkboxes/tooltips)
plus a primary **Run** button that uses the help header as a tooltip.
Attributes:
app_name: Display name used for the window title and run button label.
exe: Executable to run with `--help`.
input_json: Base GUI JSON (must include a Frame labeled "Input Panel").
flags_file: Path to a newline-separated file of flags to expose.
post_script: Optional post-analysis script name/path.
output_json_path: Destination path for the augmented JSON.
Inject an input panel into a GUI JSON based on CLI help text. Parses an executable's --help output, filters for a selected set of flags, and adds corresponding widgets (entries/checkboxes/tooltips) plus a primary Run button that uses the help header as a tooltip.
| __init__ | ( | self, | |
| str | app_name, | ||
| str | exe, | ||
| Dict | input_json, | ||
| str | flags_file, | ||
| str | post_script, | ||
| str | output_json_path ) |
Initialize the input panel generator.
Args:
app_name: Display name used for the window title and run button label.
exe: Executable (or script) to interrogate with `--help`.
input_json: Base GUI JSON (must include a Frame labeled "Input Panel").
flags_file: Path to a newline-separated file of flags to expose.
post_script: Optional post-analysis script name/path to store in metadata.
output_json_path: Destination path for the augmented JSON to write.
Notes:
- The `generate()` method will run `<exe> --help` to retrieve help text.
- The `input_json` object is mutated in-place when widgets are added.
|
protected |
Escape quotes, backslashes, and control chars for Python string literals. This is used to embed user-facing text (tooltips, labels) inside generated Python source without breaking syntax.
| Dict add_input_gui_json | ( | self, | |
| List[str] | selected_flags, | ||
| List[Dict] | flag_entries, | ||
| str | header ) |
Inject widgets and a Run button into the "Input Panel" frame.
For each selected flag, a checkbox (no-arg) or an entry + chooser button
(arg-taking) is created. Descriptions become tooltips on ⓘ labels.
Finally, an "Additional options" entry and a **Run** button are appended.
Args:
selected_flags: List of flags to expose in the GUI (e.g., `"--input-file"`).
flag_entries: The parsed entries from `parse_help_message`.
header: Header text (typically pulled from the help output) used as
a tooltip on the **Run** button.
Returns:
The modified GUI JSON dictionary (same object, mutated in place).
|
static |
Return the entry dict for a given flag, if present.
Args:
flag_entries: List of dictionaries produced by `parse_help_message`.
flag_txt_entry: A specific flag string to find (e.g., `"--verbose"`).
Returns:
The matching entry dictionary or `None` if not found.
| generate | ( | self | ) |
Run the full process and write the resulting JSON to disk. Steps: 1. Execute `<exe> --help` and parse the output. 2. Read selected flags from `flags_file`. 3. Mutate `input_json` via `add_input_gui_json`. 4. Write the final JSON to `output_json_path`. Prints warnings for recoverable issues (e.g., unknown flags), and raises no exceptions for help execution errors to keep CLI usage ergonomic.