moleculekit.vmdviewer module#

class moleculekit.vmdviewer.VMD(vmd=None, host=None, dispdev='win')#

Bases: object

A handle to a VMD molecular viewer subprocess.

Each instance launches a VMD process and communicates with it by sending tcl commands through the send() method. The constructor is not meant to be called directly; obtain a handle through the viewer() or getCurrentViewer() functions instead.

Parameters:
  • vmd (str | None) – Path to the VMD executable. If None the bundled VMD wrapper for the current platform is located automatically.

  • host (str | None) – Hostname passed to VMD with the --host argument. If None no host is specified.

  • dispdev (str) – The graphical display device to use, passed to VMD with the --dispdev argument (e.g. 'win' or 'text').

close()#

Close the viewer by sending the VMD exit command.

completed()#

Check if the viewer has been closed

Returns:

comp – Returns True if the VMD viewer has closed

Return type:

bool

copy()#

Return a copy of the viewer handle.

Returns:

copy – Viewer handles are not copyable, so None is returned.

Return type:

None

loadMol(mol, name=None)#

Load a Molecule object into VMD

Parameters:
  • mol (Molecule) – The Molecule to load into VMD

  • name (str | None) – The name to give to the Molecule

movie_reps()#

Add default settings and representations for creating movies with Tachyon in VMD.

Clears the existing representations of the top molecule and sets up depth cueing, shadows, ambient occlusion, depth of field and a white background, together with VDW representations for the protein and the non-protein heavy atoms.

render(outfile, renderer='TachyonInternal', resolution=None, aasamples=None, skylight=None, tachyon=None, convert=None, trim=False)#

Renders the current VMD scene into a file.

Parameters:
  • outfile (str) – File to which to render image

  • renderer (str) – Which renderer to use

  • resolution (tuple | None) – X,Y resolution of the output image i.e. (1920, 1080). Only used with the renderer=’tachyon’ option.

  • aasamples (int | None) – Number of anti-aliasing samples. Only used with the renderer=’tachyon’ option.

  • skylight (float | None) – Add a skylight. Only used with the renderer=’tachyon’ option.

  • tachyon (str | None) – Path to tachyon renderer executable. Only used with the renderer=’tachyon’ option.

  • convert (bool | None) – Attempts to convert the image to the datatype of the outfile extension

  • trim (bool) – Trims the whitespace of the image

rep(mode, sel='resname MOL', color=0)#

Modify representations for the top molecule in VMD

Parameters:
  • mode (str) – If set to ‘protein’, it will show a single conformation of the protein with sequence coloring If set to ‘ligand’, it will show all ligands in the specified color and the protein in teal

  • sel (str) – Atom selection string for the ligand mode. See more here

  • color (int) – Color for the ligand. Use color numbers of VMD

send(command)#

Send a tcl command to VMD

Parameters:

command (str) – The tcl command which to send

moleculekit.vmdviewer.getCurrentViewer(dispdev='win')#

Get the handle to the current molecular viewer

Parameters:

dispdev (str) – Specify the type of graphical display to use. The possible display devices include: win: a standard graphics display window. text: do not provide any graphics display window. cave: use the CAVE virtual environment for display, forms are disabled. caveforms: use the CAVE virtual environment for display and with forms enabled. This is useful with -display machine:0 for remote display of the forms when the CAVE uses the local screen.

Returns:

viewer – Returns a handle to the current viewer

Return type:

VMD object

moleculekit.vmdviewer.getVMDpath(vmd=None)#
Return type:

str

moleculekit.vmdviewer.viewer(dispdev='win')#

Start a new molecular viewer

Parameters:

dispdev (str) – Specify the type of graphical display to use. The possible display devices include: win: a standard graphics display window. text: do not provide any graphics display window. cave: use the CAVE virtual environment for display, forms are disabled. caveforms: use the CAVE virtual environment for display and with forms enabled. This is useful with -display machine:0 for remote display of the forms when the CAVE uses the local screen.

Returns:

viewer – Returns a handle to a new viewer

Return type:

VMD object