I’m finding that I using Vortex more and more in my day job, it is an excellent application for displaying and exploring large or complex datasets. In fact the only issue is getting data into Vortex. It is possible to save the dataset in sdf format and then use other applications to generate addition fields and then use the rather nice merge function within Vortex, but I end up with multiple copies of the datasets as I use different applications to calculate descriptors or properties, and it would be nicer to be able to choose an option and have all the columns of data added automatically. Since all the applications I want to use have a command line interface I thought this might be an ideal opportunity to try scripting Vortex to send the structures to an external application and import the results.

Vortex contains a powerful scripting facility built on Jython a java implementation of the Python programming language and allows access to the key components of Vortex, Python and Java. Whilst it is possible to build a Swing JPanel to provide a GUI the scripts I have in mind will not need a user interface. Scripts in Vortex can be accessed via the scripts menu. This menu is dynamically built from the content of a users local files folder (On Mac you will find the vortex folder in a users home area (addressable via ~/vortex)). I created a sub folder inside the Script folder and called it “My Scripts”. Vortex scripts can also be executed by running a .vpy file from the system explorer.

These first four scripts use some of the tools provided by OpenBabel a free opensource Chemistry Toolbox, one of these tools is the obprop program a tool to print a set of standard molecular properties for all molecules in a file, the output includes:-

The obprop tool can be accessed from the Terminal, and the output for the first molecule in the file is shown below where $$$$ is the delimiter between molecule records.

The Vortex script

The script starts by getting the path of the sdf that was imported into Vortex, we then construct the obprop command and pipe the output into a variable “output”. The next part creates the columns and uses the names from the obprop output to name them. The last part is used to parse the output “$$$$” is the divider between molecule records, each line is then a name and value pair.

One advantage of this approach is that if further properties are added to obprop the script will automatically add further columns.

The result looks like this, I’ve hidden the “sequence” and “num residues” columns).

Similarity Calculation Scripts

The next three scripts calculate molecular similarity. One of the tasks I regularly undertake is to take an active lead structure and run a series of searches in order to identify potential compounds for evaluation (substructure, pharmacophore searches, docking etc.) and it is useful to be able to compare the results with similarity measures.

OpenBabel supports four different fingerprints

These fingerprints can be used for similarity searches, for example the following command gives you the Tanimoto coefficient between a SMILES string in mysmiles.smi and all the molecules in mymols.sdf:

If you don’t specify a query file babel will just use the first molecule in the sdf file as the query as shown below

The default fingerprint used is the FP2 fingerprint. You change the fingerprint using the “f” output option, the example below shows the command and the output.

The Similarity script

Again the first part gets the path to the sdf file imported into Vortex (the file has the active lead structure as the first record), the next part constructs and runs the babel script. The results are piped into output. The columns are created if needed (note occasionally you may get “Possible superstructure”). Each record is separated by a linefeed “\n” and each line is parsed to get the similarity score, the exception being if a line is “Possible superstructure”.

The script above uses the MACCS fingerprints if you want to use one of the other fingerprints just alter -xfMACCS and Sim_MACCS

Updated 31 October 2011

Related Posts

One thought on “Scripting Vortex and OpenBabel

Comments are closed.