Macs in Chemistry

Insanely great science

 

Scripting Vortex 9

I recently wrote a review of ForgeV10 in which I imported the results into Vortex for analysis. This works fine the only issue being the resulting structures are 3D which makes interpretation of the structure sometimes difficult to discern, as shown in the image below.

forge_in_Vortex

One of the really nice features of Vortex is that if you import a SMILES structure it has an excellent 2D depiction. This script uses OpenBabel to convert the structures from a 3D sdf format into a SMILES string and then imports the SMILES and Vortex renders them as 2D images. The result of running the script is shown below.

smilesdepict

An added bonus is that you can use the 2D depiction as the popup or tooltip on plots.

tooltips

Open the Edit pot setting dialog and choose SMILES as the filed to be displayed, if you want to multiple structures click on the Show on Selected checkbox, it will now display the 2D depiction on plots rather than the 3D.

2D_smiles

The Vortex Script

The first part is the same as all the other scripts getting the sdf file, we then construct the shell script for OpenBabel and since no file is specified the output is sent to stdout, this is captured. Then create a column called SMILES and then fill it with the SMILES strings, Vortex then automagically depicts in 2D!

import sys

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

# Uncomment the following 2 lines if running in console
#vortex = console.vortex
#vtable = console.vtable

sys.path.append(vortex.getVortexFolder() + '/modules/jythonlib')

import subprocess

# Get the path to the currently open sdf file
sdfFile = vortex.getFileForPropertyCalculation(vtable)

# use obabel to convert sdf to SMILES
p = subprocess.Popen(['/usr/local/bin/obabel','-isdf', sdfFile,'-osmi'], stdout=subprocess.PIPE)
output = p.communicate()[0]

# Create new columns in table if needed

column = vtable.findColumnWithName('SMILES', 1, 3)
vtable.fireTableStructureChanged()

# Parse data one line per SMILES
lines = output.split('\n')
for i in range(0, vtable.getRealRowCount()):
    column = vtable.findColumnWithName('SMILES', 0)
    column.setValueFromString(i, lines[i])

The vortex script can be downloaded from here ob_sdf2smi.vpy.zip

Scripting Vortex Using OpenBabel
Scripting Vortex 2 Using filter-it
Scripting Votrex 3 Using cxcalc
Scripting Vortex 4 Using MOE
Scripting Vortex 5 Calculating similarities using OpenBabel
Scripting Vortex 6 Filtering compounds
Scripting Vortex 7 Using MayaChemTools
Scripting Vortex 8 Molecular Shape matching
Scripting Vortex 9 Getting a 2D depiction
Scripting Vortex 10 Interacting with the user
Scripting Vortex 11 Interacting with a web service
Scripting Vortex 12 JSON import
Scripting Vortex 13 Using OpenBabel fastsearch

Other Hints, Tips and Tutorials

Last Updated 11 September 2012