Vortex script using Openbabel for similarity searching

An earlier script showed how to calculate molecular similarity between the first molecule in the file and all the other molecules using OpenBabel as shown below.

This is fine for examples where the first structure is perhaps the active lead structure and the other molecules are potential compounds for evaluation derived from a substructure, pharmacophore searches, docking etc. However on many occasions you may want to simply calculate the similarity to a probe structure that is not part of the file. To do this in Vortex we can capture the structural query from the in built sketcher. Vortex supports a variety of 3rd party chemical drawing packages as well as their own in house package Elemental, however by capturing the content of the structural query box we can simply ignore which package was used to generate the content.

This command will capture MolFile 

whilst this will get the structure in SMARTS format

Unfortunately if you run this from the console you get are rather unexpected result.

It seems the coordinates are put inline with the SMARTS, but you can fix it with the following one liner

(remember to import re at the top)

OpenBabel provides two programs obabel and babel which are cross-platform programs designed to interconvert between many file formats used in molecular modelling and computational chemistry and related areas. They can also be used for filtering molecules and for simple manipulation of chemical data. Whilst there are many similarities between the programs essentially obabel is a modern version of babel with additional capabilities and a more standard interface. Over time, obabel will replace babel.

Specifically, the differences are as follows:

  • obabel requires that the output file be specified with a -O option. This is closer to the normal Unix convention for commandline programs, and prevents users accidentally overwriting the input file.
  • obabel is more flexible when the user needs to specify parameter values on options. For instance, the –unique option can be used with or without a parameter (specifying the criteria used). With babel, this only works when the option is the last on the line; with obabel, no such restriction applies. Because of the original design of babel, it is not possible to add this capability in a backwards-compatible way.
  • obabel has a shortcut for entering SMILES strings. Precede the SMILES by -: and use in place of an input file. The SMILES string should be enclosed in quotation marks. 

More than one can be used, and a molecule title can be included if enclosed in quotes:

  • obabel cannot use concatenated single-character options.

So the babel command we need is 

We can add the -: and the query SMARTS becomes

The rest of the script is very similar to the previous scripts, we run the process and capture the output. Create two new columns, you can pass a third argument to the findColumnWithName which will set the type for the column if it gets created, the value 3 will set it to string, 1 is double.

We then parse the output and populate the columns. One minor issue is the fireTableStructureChanged() call triggers a reset of all the filter cells including the structure query which means you will need to redraw the query if you want to modify it.

The Vortex Script

In this example I’ve used the FP2 fingerprint but OpenBabel supports several different fingerprints

In a similar way to the first script it is straight-forward to choose an alternative fingerprint. The results should look like the image shown below.

If you just want to compare the similarity with a structure in the worksheet, simply right-click on the structure and select Copy to ChemLink from the drop down menu, the structure will then be copied to the chemical query box.

The script can be downloaded here SimqueryFP2.vpy.zip

Last Updated 7 Feb 2011

Related Posts