schrodinger.utils.pymol module

Utilities to load Maestro projects into PyMOL.

Example:

>>> cmd = PymolInstance("/path/to/pymol")
>>> pt = maestro.project_table_get()
>>> process_prj(cmd, pt)

Copyright Schrodinger LLC, All rights reserved.

Author: Thomas Holder

class schrodinger.utils.pymol.Mapping

Mappings from Maestro codes to PyMOL representations and settings

ramp_colors = {'redwhiteblue': '[red, white, blue]', 'rainbow': '[red, yellow, green, cyan, blue, magenta]', 'whitered': '[white, red]', 'whiteblue': '[white, blue]'}
stereomethods = {'crosseyed': 'crosseye', 'anaglyph': 'anaglyph', 'walleyed': 'walleye', 'hardware': 'quadbuffer', 'chromadepth': 'off', 'interlaced': 'byrow'}
surface_cmd = {0: 'isosurface', 1: 'isomesh', 2: 'isodot'}
class schrodinger.utils.pymol.PymolInstance(pymol_command='pymol')

Bases: object

Represents a remote PyMOL instance (controlled via a one-way pipe)

Acts like a proxy to the cmd module, without return values on function calls (which would actually be very usefull).

See also: PyMOL XMLRPC server (pymol -R)

close()

Quit PyMOL

do(cmmd)

Send command to PyMOL

Parameters:cmmd (str) – PyMOL command
Returns:True on success and False on error
Return type:bool

Replacement for cmd.get_legal_name

Parameters:name (str) – name candidate
Returns:legal PyMOL object name
Return type:str
get_unused_name(name, alwaysnumber=1)

Replacement for cmd.get_unused_name, does not talk back to PyMOL but maintains it’s own set of already used names.

This is only necessary because the the pipe cannot return values.

Parameters:
  • name (str) – name candidate
  • alwaysnumber (bool) – if False, only append a number if name already exists
Returns:

unused legal PyMOL object name

Return type:

str

sendVersionCheck()

Print a warning on the PyMOL log window if PyMOL version is too old.

class schrodinger.utils.pymol.PymolScriptInstance(pymol_command='pymol')

Bases: schrodinger.utils.pymol.PymolInstance

Represents a PyMOL script for deferred execution.

close(args='-cqk')

Close file handle and execute script in PyMOL

Parameters:args (str) – extra command line arguments for pymol
class schrodinger.utils.pymol.RowProxy(row, cmd)

Bases: schrodinger.project.ProjectRow

Proxy for project table row to attach additional data.

doGroup(name)

Put name in PyMOL group, if row is in a Maestro group.

Parameters:name (str) – PyMOL object name
class schrodinger.utils.pymol.VisRecord(row, idx)

Bases: object

Represents a surface entry in a “vis_list” file

Variables:
  • name_pymol (str) – PyMOL object name
  • visfile (str) – filename of vis file
class schrodinger.utils.pymol.VisRecordVol(row, idx)

Bases: schrodinger.utils.pymol.VisRecord

Represents a volume entry in a “vis_list” file

Volume gets auto-loaded when accessing name_pymol.

class schrodinger.utils.pymol.WorkspaceIdMapper(prj_handle)

Bases: object

Maps workspace atom indices to (row.index, ID)

schrodinger.utils.pymol.get_font_id(font_name, font_style)

Get the PyMOL label_font_id which best matches the given font name and style.

Return type:int
schrodinger.utils.pymol.get_measurement_items(key, mmprojadmin)

Get workspace atom ids from the measurements table. If not running from Maestro, read the .tab files from the .mmproj-admin directory.

Parameters:key (str) – one of distance, angle or dihedral
Return type:list(int)
Returns:List of lists of atom ids (workspace)
schrodinger.utils.pymol.process_highlights(cmd, prj_handle)

Send “highlights” (label+arrow annotation) to PyMOL

Parameters:
schrodinger.utils.pymol.process_hypothesis(cmd, row, mae)

Import Phase pharmacophores as CGOs into PyMOL.

Parameters:
  • cmd (PymolInstance) – PyMOL API proxy
  • row (schrodinger.project.ProjectRow) – project table row
  • mae (str) – reference mae filename
schrodinger.utils.pymol.process_measurements(cmd, prj_handle)

Send workspace measurements to PyMOL

Parameters:
schrodinger.utils.pymol.process_prj(cmd, prj_handle, limit='all', with_surf=True, mimic=True)

Send maestro project to PyMOL. By default send everything, optional filters may apply.

Parameters:
  • cmd (PymolInstance) – PyMOL API proxy
  • prj_handle (schrodinger.project.Project) – project handle
  • limit (str) – all, included or selected. The latter will not send workspace items like measurements and text highlights.
  • with_surf (bool) – send surfaces and maps (volumes)
  • mimic (bool) – use PyMOL settings to match style as close as possible
schrodinger.utils.pymol.process_row(cmd, row, limit_included=False, with_surf=True, mimic=True)

Send a row from the project table to PyMOL.

Parameters:
  • cmd (PymolInstance) – PyMOL API proxy
  • row (schrodinger.project.ProjectRow) – project table row
  • limit_included (bool) – limit surface export to workspace
  • with_surf (bool) – send surfaces
  • mimic (bool) – use PyMOL settings to match style as close as possible
schrodinger.utils.pymol.process_surface(cmd, row, e_surf)

Send a surface to PyMOL

Parameters:
  • cmd (PymolInstance) – PyMOL API proxy
  • row (RowProxy) – project table row
  • e_surf (schrodinger.project.EntrySurface) – surface
schrodinger.utils.pymol.select_surf_asl(row, surf_handle, name='')

Make a PyMOL selection for surface ASL.

Returns:PyMOL selection name
schrodinger.utils.pymol.send_maestro_settings(cmd)

Map Maestro settings to closest matching PyMOL settings.

Parameters:cmd (PymolInstance) – PyMOL API proxy
Return type:bool
Returns:True on success and False if Maestro is not available