Vortex Script Interacting with MOE using SOAP

In a earlier script we looked at using the command line tool sddesc from Chemical Computing Group to calculate a number of molecular descriptors and then import them into Vortex. However there a couple of issues with doing this not the least ensuring all the environment variables are set correctly. An alternative is to use MOE as a web service and access the tools using the SOAP protocol (Simple Object Access Protocol). This protocol provides a specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on XML Information Set for its message format.

The MOE Web Server

You can start the MOE web server using the following command in a Terminal window

You should get a list of information including the IP address of the server and the port you need to address (usually port 8888)

You should also get a list of very useful web pages

If you now open a web browser and go to

You will get a web page giving a list of the available functions.

If like me you are not particularly familiar with constructing SOAP queries then these pages are invaluable. Select the SMILESToMol hyperlink and you should get the page below. Fill in a valid SMILES string and click on the “Preview SOAP Request” button and you can see the syntax of the expected SOAP request and this is what we will be included in the Vortex script as the SOAP request.

The MolToSMILES script

To start with I thought I’d create a script that retrieves the SMILES string from the web server, mainly because it avoids the complication of trying to parse the returned XML if there are multiple properties. We do however need to import an XML parsing library. The Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary, XML is an inherently hierarchical data format, and the most natural way to represent it is with a tree.

The first part just allows the user to confirm that they are not posting proprietary information to an external web service. We then get the structure as a MOL file.

Then we construct the SOAP request, we need the URL we are posting to and the data wrapped in the SOAP request format taken from the appropriate MOE SOAP function web page.

We then perform the request

We then need to create a column in Vortex, and then parse the data, since there is only the SMILES string returned this is fairly straight-forward with help from Matt. The XML response from the MOE server is parsed using the python ElementTree module. This module parses an XML string using ET.fromstring()into a hierarchical tree data structure that allows us to easily pick out various values in the response. In this case, the desired value is just the text within a tag named “smiles”, which can be found using a relatively simple XPath query:

   mysmiles = root.find(‘.//smiles’)

This query recursively searches through the tree and returns the first element with the tag “smiles” that it finds. The text contents of that element is given by mysmiles.text

The result of running this script is a new column called SMILES, and because Vortex is smart enough to realise what the contents are the SMILES strings get automatically rendered as 2D images.

You can download the script from here

Last updated May 2013

Related Posts