Interfacing with VMD
The University of Illinois at Urbana-Champaign produces great biomolecular simulation software such as the molecular dynamics engine NAMD and the visualization/analysis package VMD. There is no plan in our toolkit, LLTK, to tackle molecular visualization; VMD already does this expertly. Don't fear — instead of missing out on visualization, a port to VMD has been written into LLTK.
This port is found in the LLTK.external subpackage. With it, we can launch a local installation of VMD and use our Python prompt to control it, i.e., send via TCL any commands we could in VMD's shell. We can also (somewhat) directly load LLTK.structure.Structure objects into VMD without any hassle. Let's take a look at some examples.
# Import LLTK
# Read structure into LLTK
# Initialize VMD and connect
# Upload structure to VMD
# Run VMD commands on structure
vmd.execute('set sel [atomselect top "all"]')
center=vmd.execute('measure center $sel')
vmd.execute('mol delete all')
# Terminate VMD and close connection
We accomplish these feats by launching VMD as a socket server. This server assumes that any information sent to it is a command, which is then executed. There are some security concerns about opening up command-friendly sockets to the Internet; we recommend using these types of commands only behind a firewall. In principle, the LLTK.external.VMD class could be used to connect to VMD servers that exist outside of local networks. In fact, anyone could connect to this socket. Please keep use of this functionality restricted to localhost.
I find the ability to communicate with VMD rather cool. It extends the analysis possible within LLTK to everything possible within VMD. This gives users the opportunities to run redundant checks on similar pieces of code written in either package. Furthermore, with VMD, users can leverage its ability to create beautiful and publication-ready visualizations.