visualize

Interfaces for molecular viewers

The viewers defined here are meant to be used for quick interactive structure and trajectory display. All viewer functions are actually callable instances of ViewFactory, and thus have the same call signature:

ViewFactory.__call__(obj, logfile=None, structfile=None, disp=False, keepfiles=False, tmpdir='/tmp', wait=True, bg=False, options='')[source]

Call viewer.

The executed shell command is:

<cmd> <options> <structfile> > <logfile>
Parameters:
  • obj (Structure or Trajectory)

  • logfile (str, optional) – Filename of a logfile for the viewer’s text output.

  • structfile (str, optional) – Filename of a file to write the structure to.

  • disp (bool) – Display text output (i.e. logfile’s content).

  • keepfiles (bool) – Keep structfile and logfile on disk.

  • tmpdir (str, optional) – Directory where temp files are written to.

  • wait (bool, optional) – wait passed to common.system(), wait (or not) for command to exit

  • bg (bool) – Background mode. If True then this is an alias for wait=False + keepfiles=True. The latter is needed b/c with just wait=False, temp files will be deleted right after the shell call and the viewer program may complain.

VMD

Use view_vmd_xyz() or view_vmd_axsf(). To execute a tcl script after the struct has loaded (in the shell: vmd -e script.tcl foo.xyz), use:

>>> tr = crys.Trajectory(...)
>>> view_vmd_axsf(tr, options='-e script.tcl')

Note that the viewer (in this case VMD) is simply called like vmd structfile, which can take very long for big MD data b/c the VMD default is to use smth like mol new ... waitfor 1, which is slow. In that case you want to call VMD directly:

$ vmd
vmd > mol new /tmp/foo.axsf type xsf waitfor all
vmd > set molid 0
vmd > source ~/work/vmd/ca_salt.tcl

The trick here is ... waitfor all. See the VMD manual for the mol command. Or you place these lines in a script and use:

$ vmd script_to_execute.tcl

ViewFactory([cmd, assert_cmd, suffix, writer])

Factory for creating interface functions to external molecular viewers.

assert_struct(obj)

avogadro_cmd

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

view_avogadro

Factory for creating interface functions to external molecular viewers.

view_jmol

Factory for creating interface functions to external molecular viewers.

view_vmd_axsf

Factory for creating interface functions to external molecular viewers.

view_vmd_xyz

Factory for creating interface functions to external molecular viewers.

view_xcrysden

Factory for creating interface functions to external molecular viewers.