mkt.databases.pymol

Generation of PyMOL visualization scripts for kinase structures.

Provides PyMOLGenerator, which renders parameterized PyMOL scripts for highlighting kinase structure features (see the pymol_viz skill).

Module Attributes

DICT_FILENAME_DEFAULTS

Default filenames for PDB, script, and instructions.

DICT_COLOR_MAP

Fallback color name to hex mapping (CSS3 standard colors).

Classes

PyMOLGenerator(viz, str_attr, dict_filenames)

Generate PDB file with embedded color/style info and standalone PyMOL script.

mkt.databases.pymol.DICT_COLOR_MAP = {'black': '#000000', 'blue': '#0000FF', 'brown': '#A52A2A', 'cornflowerblue': '#6495ED', 'cyan': '#00FFFF', 'darkblue': '#00008B', 'darkgreen': '#006400', 'darkorange': '#FF8C00', 'darkred': '#8B0000', 'darkviolet': '#9400D3', 'gray': '#808080', 'green': '#008000', 'grey': '#808080', 'khaki': '#F0E68C', 'lightblue': '#ADD8E6', 'lightgreen': '#90EE90', 'magenta': '#FF00FF', 'orange': '#FFA500', 'pink': '#FFC0CB', 'purple': '#800080', 'red': '#FF0000', 'white': '#FFFFFF', 'yellow': '#FFFF00'}

Fallback color name to hex mapping (CSS3 standard colors).

Type:

dict

mkt.databases.pymol.DICT_FILENAME_DEFAULTS = {'file_pdb': 'structure.pdb', 'file_script': 'pymol_script.py', 'file_txt': 'instructions.txt'}

Default filenames for PDB, script, and instructions.

Type:

dict

class mkt.databases.pymol.PyMOLGenerator(viz: ~mkt.databases.app.structures.StructureVisualizer, str_attr: str, dict_filenames: dict = <factory>)[source]

Bases: object

Generate PDB file with embedded color/style info and standalone PyMOL script.

__init__(viz: ~mkt.databases.app.structures.StructureVisualizer, str_attr: str, dict_filenames: dict = <factory>) None
_convert_color_to_hex(color: str) str[source]

Convert named color to hex, with fallback options.

Parameters:

color (str) – Color name or hex string.

Returns:

Hex color string.

Return type:

str

_get_color_and_style_mapping() tuple[dict[int, str], list[int], dict[int, str]][source]

Generate residue-to-color mapping, stick residue list, and label mapping.

Uses the get_highlight_data() from StructureVisualizer which gets data from the config.

Returns:

Dictionary mapping residue numbers to hex colors, list of stick residue numbers, dictionary mapping residue numbers to label strings.

Return type:

tuple[dict[int, str], list[int], dict[int, str]]

dict_filenames: dict

Dictionary of filenames for PDB, script, and instructions.

gene_name: str

Gene name of the structure.

generate_annotated_pdb(output_path: str) str[source]

Generate PDB file with renumbered residues and color/style annotations.

Parameters:

output_path (str) – Path to save the annotated PDB file.

Returns:

Path to the saved annotated PDB file.

Return type:

str

generate_instructions(output_dir: str) str[source]

Generate instructions for manual PyMOL execution.

Parameters:

output_dir (str) – Directory where files are saved

Returns:

Instructions text

Return type:

str

generate_pymol_script(pdb_path: str, output_path: str) str[source]

Generate PyMOL script that reads annotations from PDB and applies styling.

Parameters:
  • pdb_path (str) – Path to the annotated PDB file.

  • output_path (str) – Path to save the PyMOL script.

Returns:

Path to the saved PyMOL script.

Return type:

str

return_filepath_dict(output_dir: str) dict[str, str][source]

Return dictionary of filenames with paths.

Parameters:

output_dir (str) – Directory where files are saved.

Returns:

Dictionary mapping file types to full file paths.

Return type:

dict[str, str]

save_pymol_files(output_dir: str)[source]

Generate PDB file and PyMOL script for manual PyMOL execution.

Parameters:

output_dir (str) – Directory to save files

str_attr: str

Granular attribute name of the structure visualization (e.g., KLIFS_IMPORTANT not just KLIFS).

viz: StructureVisualizer

StructureVisualizer object with loaded structure and config.