This script is no longer needed since you can now add SMILES from the “Calculate Properties” option from the Tools menu. However, it is a simple example of getting data from another application.
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.
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.
An added bonus is that you can use the 2D depiction as the popup or tooltip on plots.
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.
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 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')
# 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()
# Create new columns in table if needed
column = vtable.findColumnWithName('SMILES', 1, 3)
# Parse data one line per SMILES
lines = output.split('\n')
for i in range(0, vtable.getRealRowCount()):
column = vtable.findColumnWithName('SMILES', 0)
The vortex script can be downloaded from here.