Skip to content

Shortcuts

The shortcuts module extends PyMOL's command language with REvoDesign-specific commands via cmd.extend(), sets up CLI autocompletion via cmd.auto_arg, and provides the DialogWrapperRegistry system for wrapping functions with interactive dialog popups.

PyMOL Command Registration

Commands are registered in REvoDesign.shortcuts.__init__ and receive autocompletion through cmd.auto_arg.

Registered commands

Command Function Arguments
pssm2csv shortcut_pssm2csv arg0: pssm file path
real_sc shortcut_real_sc arg0: selection, arg1: representation, arg2: hydrogen (0/1)
color_by_mutation shortcut_color_by_mutation arg0: target object, arg1: reference object, arg2: waters (0/1), arg3: labels (0/1)
color_by_plddt shortcut_color_by_plddt arg0: selection (default "all"), arg1: align_target (0/1), arg2: chain
find_interface shortcut_find_interface arg0: selection (default "all"), arg1: interact_dist
dump_sidechains shortcut_dump_sidechains arg0: sele, arg1: enabled_only, arg2: save_dir, ..., arg10: recenter
visualize_conformer_sdf visualize_conformer_sdf arg0: sdf_file_path, arg1: show_conformer
getbox getbox --
get_pca_box get_pca_box --
showbox showbox --
rmhet rmhet --
movebox movebox --
showaxes showaxes --
enlargebox enlargebox --

Dialog Wrapper Registry

REvoDesign.shortcuts.utils.DialogWrapperRegistry

Loads YAML config and dynamically builds & calls dialog-wrapped functions.

register(func_id, func, use_thread=False, has_dynamic_values=False, use_progressbar=True, kwargs=None)

Register the raw Python function under a given ID.

Arguments: func_id (str): The ID to register the function under. func (Callable): The function to register. use_thread (bool): Whether to run the function in a separate thread. has_dynamic_values (bool): Whether the function accepts dynamic values. use_progressbar (bool): Whether to use a progress bar. kwargs (Optional[Dict]): Additional keyword arguments to pass to the function.

Returns either: - A callable accepting dynamic values (if has_dynamic_values=True) - A callable with no arguments (if has_dynamic_values=False)

unregister(func_id)

Unregister the function with the given ID.

Parameters:

Name Type Description Default
func_id str

The ID of the function to unregister.

required

call(func_id, dynamic_values=None)

Wrap and call the function with a dialog built from YAML config.

Parameters:

Name Type Description Default
func_id str

The ID of the function to call.

required
dynamic_values Optional[List[dict]]

Dynamic values to pass to the function.

None

Returns:

Name Type Description
Any

The result of the function call.

Raises: ValueError: If the function ID is not registered. ValueError: If the function ID is not found in the YAML config.

Utility Functions

REvoDesign.shortcuts.utils.resolve_choice_from(choice_from_str)

Interprets an input string and dynamically returns a corresponding value based on its prefix.

The function supports three types of input:

  1. Range Parsing:
  2. If the input starts with 'range:', it parses the rest of the string as integers to create a range() object.
  3. Accepts formats like range:1,10 or range:1,10,2.
  4. Raises InvalidInputError if parsing fails.

  5. Callable Resolution:

  6. If the input starts with "REvoDesign.", it resolves a callable using resolve_dotted_function.
  7. Invokes and returns the result of the resolved callable.

  8. Configuration Value Retrieval:

  9. If the input starts with "CFG:", it retrieves a configuration value via ConfigBus().get_value(...).

If none of the prefixes match, it raises a [ConfigurationError].

Parameters:

Name Type Description Default
input_str str

The input string that determines what value or object to return.

required

Returns:

Type Description

range | Any | Callable: - A range() object if input starts with 'range:'. - The result of a resolved callable if input starts with "REvoDesign.". - A configuration value if input starts with "CFG:".

Raises:

Type Description
InvalidInputError

If the input format for 'range:' or 'CFG:' is invalid.

ConfigurationError

If the input doesn't match any known pattern or expected type.

REvoDesign.shortcuts.utils.resolve_default_from(default_from_str)

Resolves a dotted configuration string to retrieve the corresponding default value.

Parameters:

Name Type Description Default
default_from_str str

The dotted configuration string to resolve.

required

Returns:

Name Type Description
Any Any

The default value retrieved from the specified configuration.

REvoDesign.shortcuts.function_utils.visualize_conformer_sdf(sdf_file_path, show_conformer)

Visualize a ligand conformer file (SDF) in a new PyMOL window.

Parameters:

Name Type Description Default
sdf_file_path str

Path to the SDF file containing the conformers.

required

REvoDesign.shortcuts.function_utils.smiles_conformer_batch(smi, num_conformer, save_dir, n_jobs=1)

Generates 3D conformers for a SMILES string using RDKit.

Parameters:

Name Type Description Default
smi Dict[str, str]

Dictionary containing the name of the molecule as the key and the SMILES string as the value.

required
num_conformer int

Number of conformers to generate for each molecule.

required
save_dir str

Directory to save the generated conformer files.

required
n_jobs int

Number of parallel jobs to run. Defaults to 1.

1

REvoDesign.shortcuts.function_utils.smiles_conformer_single(ligand_name, smiles, num_conformer, save_dir)

Generates 3D conformers for a single SMILES string using RDKit.

Parameters:

Name Type Description Default
ligand_name str

Name of the ligand.

required
smiles str

SMILES string of the ligand.

required
num_conformer int

Number of conformers to generate.

required
save_dir str

Directory to save the generated conformer file.

required

REvoDesign.shortcuts.dialog_hooks.get_fasta_writer_choices()

REvoDesign.shortcuts.dialog_hooks.get_designable_chain_ids()

REvoDesign.shortcuts.dialog_hooks.get_selections()

REvoDesign.shortcuts.dialog_hooks.find_all_small_molecules_in_protein()

REvoDesign.shortcuts.dialog_hooks.get_all_chain_ids()

REvoDesign.shortcuts.dialog_hooks.get_all_object_names()

REvoDesign.shortcuts.dialog_hooks.get_all_selections()

REvoDesign.shortcuts.dialog_hooks.get_all_objects()

REvoDesign.shortcuts.dialog_hooks.get_pymol_plugin_paths()

Retrieve the list of PyMOL plugin startup paths

Returns:

Name Type Description
list

A list of PyMOL plugin startup paths, or an empty list if PyMOL is running in headless mode

Raises:

Type Description
AttributeError

Caught when PyMOL is running in headless mode

REvoDesign.shortcuts.shortcuts_on_menu.menu_dump_sidechains(dump_all=False)

Prepares and launches the sidechain dumping menu.

Parameters:

Name Type Description Default
dump_all bool

If True, preselects all groups for sidechain dumping.

False