Macs in Chemistry

Insanely great science


Scripting Vortex (and MOE) 17

One of the new features in the latest version of MOE from Chemical Computing Group is the Listener. The MOE socket listener provides an alternative to MOE/web for executing functions remotely on a running instance of MOE. These special functions must follow a naming convention in which each name is prefixed by the string listen_. Furthermore, each such function is permitted only a single argument in the form of a tagged vector. It is the responsibility of the function author to validate the number and type of arguments, and any other constraints. The function should simply exit with an error if called with invalid arguments. Once such functions are loaded into an instance of MOE and the listener is activated, they can be executed from a web browser or any other application by providing an appropriately constructed URL.

The listenfunctions must be loaded into a running instance of MOE using the SVL load command before they can be called. To make use of these functions, the listener (i.e. server) must first be started. This is accomplished using the SVL listenport command from the SVL command window.

svl> listen_port 8989

In the tutorial Scripting Vortex 15 I showed how it is possible to create a contextual script for Vortex that downloaded a specific PDB file, then a FlexAlign Vortex script first identifies the structure column and then get the SMILES string of the selected molecule generates a 3D structure and uses Flex Align to do a one-shot Flexalign between the ligand in the system in MOE, and the incoming ligand.

While this is useful if you have similar structures (perhaps analogues in a series) there will certainly be situations where it may be preferable to dock the new ligand into the binding site. The relevant SVL code to create the MOE listener to do the docking was supplied by Simon Grimshaw from CCG and is shown below.

// create a new molecule in MOE based on SMILES. 
// dock into site using existing ligand as reference
global function listen_docklig_smiles arg
    local smiles = first cat sread [string arg.smiles, '{t:*|,}'];

    // switch to a private system, create the molecule from SMILES
    // then use conf_Embed3D to generate an unstrained conformation
    // then extract the db mol vector and return to the main system
 local [sk1, sk2] = SystemPush [];
 local atoms = sm_Build smiles;
    conf_Embed3D atoms;
    local mol = mol_Extract atoms;
 SystemPop [sk1, sk2];

    // check for a ligand, and if one is found, align the incoming 
    // molecule to the reference ligand
 local site = _Atoms'$$ligand';
    local rec = _Atoms'$$receptor';
 if alltrue app length [site, rec] then
    local lig = cat cAtoms mol_Create mol;
    local tempout = fnametemp '$TMP/*.mdb';
    DockAtoms [
        rec, site, lig, tempout,
        [maxpose: 10, refine:'Forcefield', rescoring:'GBVI/WSA dG']
    mol = cat db_ReadFields [tempout, first db_Entries tempout, 'mol'];
    Warning 'Could not identify site - please load reference ligand';

    oDestroy uniq aChain lig;
 fdelete tempout;
/   / create the new molecule and set the view point to look at 
    // new molecule
    ViewObj mol_Create mol;


The portion of the script that controls the docking is :-

[maxpose: 10, refine:'Forcefield', rescoring:'GBVI/WSA dG']

Where maxpose is the number of poses undertaken, and GBVI/WSA dG is a forcefield-based scoring function which estimates the free energy of binding of the ligand from a given pose. It has been trained using the MMFF94x and AMBER99 forcefield on the 99 protein-ligand complexes of the SIE training set (Naim et al.; J. Chem. Inf. Model. 47 (2007) 122–133). You can of course change these if needed.

I’ve combined this portion of SVL with previously detailed listener script and it can be downloaded here

The Vortex Script

This script follows a similar format to that described in Vortex script 15, we first identify the structure column and then get the SMILES string of the selected molecule, we then get all the variables needed by MOE and pass them to the docklig_smiles listener.

# Using MOE via a web service this uses a local copy of MOE

import sys
import com.dotmatics.vortex.util.Util as Util

if Util.getPlatform() == Util.PlatformIsWindows:
 sys.path.append(vortex.getVortexFolder() + '\\modules\\jythonconsole')
sys.path.append(vortex.getVortexFolder() + '\\modules\\jythonlib')
sys.path.append(vortex.getVortexFolder() + '/modules/jythonconsole')
sys.path.append(vortex.getVortexFolder() + '/modules/jythonlib')

import urllib2
import urllib

smiles = ''

col = vtable.findColumnWithName('Structure', 0)

if (col == None):
col = vtable.findColumnWithName('SMILES', 0)
 if (col == None):
    vortex.alert('Load a workspace with a Structure or SMILES column please.')
    smiles = col.getValueAsString(cell_row)
smiles = vortex.getMolProperty(vtable.getMolFileManager().getMolFileAtRow(cell_row), 'SMILES')

vortex.alert('SMILES = '+smiles)

url = "http://localhost:8989/exec/docklig_smiles"   
data = urllib.urlencode(values)
headers = {'Content-type': 'application/x-www-form-urlencoded'}
req = urllib2.Request(url, data, headers)
response = urllib2.urlopen(req)
the_page =

You can download the script from here, this script need to be stored in the “context” folder which is inside the “Vortex_Add-ons” folder.

It is probably easier to see this in action, if it appears rather small click on the YouTube icon in the bottom right corner of the video.

There are a number of other similar scripts in the Other Hints, Tips and Tutorials

Page Updated 27 January 2014