pymol_struct

Utilities for pymol <https://pymol.org/> structures.

pdb_prot_align.pymol_struct.color_by_site(cmd, sites_df, color_by, pymol_object=None)[source]

Color residues in a pymol object by site.

Parameters
  • cmd (pymol.cmd module) – Name of pymol.cmd module for current session, typically imported with import pymol.cmd as cmd. The structure(s) must already be loaded into this session.

  • sites_df (pandas.DataFrame or str) – Information on how to color sites. Can either be data frame or name of CSV file with data frame. Must have columns named ‘pdb_chain’ and ‘pdb_site’ as well as the column specified by color_by.

  • color_by (str or 2-tuple) – How to color the sites. Can either specify as a str the name of a column in sites_df that has the name of a color for each site, or can be the 2-tuple (val_col, color_map). In this case, val_col is name of column with numerical values, and color_map is a pdb_prot_align.colorschemes.ValueToColorMap that maps the numbers in this column to colors. If colors are specified as str and are hex, then they need to be like this ‘0x25828e’, not like this ‘#25828e’

  • pymol_object (None or str) – Name of pymol object to which chains and sites belong. If None, color all residues in current session with specified chains / sites.