Scripting Vortex 10
In the sixth tutorial on scripting Vortex I described how to use filter-it from silicos-it to categorise input molecules into 1) a set of molecules that fulfil all criteria as defined in the filter definition file (passed molecules), and 2) a set of molecules that do not fulfil at least one of the defined filter criteria (failed molecules).
- Physicochemical parameters, such as logP, topological polar surface area criteria, number of hydrogen bond acceptors and donors, and Lipinski’s rule-of-five.
- Graph-based properties, including ring-based parameters and rotatable bond criteria.
- Selection criteria by means of smarts patterns; o Similarity criteria.
- Three-dimensional distances between user-definable fragments.
It is also possible to use filter-it to simply calculate a wide range of descriptors that are used in the filtering process, by including --tab
without defining an output file the tabulated properties are sent to stdout and in the second tutorial I showed how to use the “Leadlike” filter to calculate properties. The exact descriptors that are calculated depends on the criterion defined in the filter file used. Silicos-it provide four ready made filters, Druglike, Leadlike, CMClike and Clean which flags unacceptable functional groups, and users may want to define their own filters.
Druglike
NAME
ONLYELEMENTS
AROMATICRINGS
ATOMS
ATOMSINLARGESTRING
ATOMSINLARGESTRINGSYSTEM
ATOMSINSMALLESTRING
ATOMSINSMALLESTRINGSYSTEM
CARBONS
CHIRALCENTERS FORMALCHARGES
HALIDES HBONDACCEPTORS
HBONDDONORS HETEROATOMS
LIPINSKIACCEPTORS
LIPINSKIDONORS
LIPINSKIVIOLATIONS
NONAROMATICRINGS
RIGIDBONDS RINGS
RINGSINLARGESTRINGSYSTEM
RINGSINSMALLESTRINGSYSTEM
RINGSYSTEMS
ROTATABLEBONDS
TOTALFORMALCHARGE
HETEROCARBONRATIO
HALIDEFRACTION
LOGP
MOLWT
TPSA
Leadlike
NAME
ONLYELEMENTS
AROMATICRINGS ATOMS
ATOMSINCORE
ATOMSINLARGESTBRIDGE
ATOMSINLARGESTRING
ATOMSINLARGESTRINGSYSTEM
ATOMSINLARGESTSIDECHAIN
ATOMSINSMALLESTBRIDGE
ATOMSINSMALLESTRING
ATOMSINSMALLESTRINGSYSTEM
ATOMSINSMALLESTSIDECHAIN
BRIDGES CARBONS
CHIRALCENTERS CORES
FORMALCHARGES
HALIDES HBONDACCEPTORS
HBONDDONORS HETEROATOMS
LIPINSKIACCEPTORS
LIPINSKIDONORS
LIPINSKIVIOLATIONS
NONAROMATICRINGS
RIGIDBONDS RINGS
RINGSINLARGESTRINGSYSTEM
RINGSINSMALLESTRINGSYSTEM
RINGSYSTEMS
ROTATABLEBONDS
SIDECHAINS TOTALFORMALCHARGE
ANDREWSENERGY
BRIDGEFRACTION
COREFRACTION
HETEROCARBONRATIO
HALIDEFRACTION
LOGP
LOGS
MOLWT
SIDECHAINFRACTION
TPSA
CMClike
NAME
ONLYELEMENTS
ABSORPTION
ATOMS
ATOMSINCORE
ATOMSINLARGESTBRIDGE
ATOMSINLARGESTRINGSYSTEM
ATOMSINLARGESTSIDECHAIN
ATOMSINSMALLESTBRIDGE
ATOMSINSMALLESTRING
ATOMSINSMALLESTRINGSYSTEM
ATOMSINSMALLESTSIDECHAIN
BRIDGES CARBONS
CHIRALCENTERS
CORES
FORMALCHARGES
HALIDES HBONDACCEPTORS
HBONDDONORS
HETEROATOMS
LIPINSKIACCEPTORS
LIPINSKIDONORS
LIPINSKIVIOLATIONS
RIGIDBONDS RINGSYSTEMS
ROTATABLEBONDS
SIDECHAINS
TOTALFORMALCHARGE
ANDREWSENERGY
FLEXIBILITY
BRIDGEFRACTION
COREFRACTION
HETEROCARBONRATIO
HALIDEFRACTION
LIGANDEFFICIENCY
LOGP
LOGS
MOLWT
RINGFRACTION
SIDECHAIN_FRACTION
TPSA
Clean
NAME ONLYELEMENTS Carboxylate Ester Acetal Acyclic-NCN AcylCyanide AcylHalide AcylImidazole AcylSulfide AcylTriazole Aldehyde Aldoxime AlkylHalide1 AlkylHalide2 AlkylHalide3 Allene AminaAnhydride Anionic-C Azide Aziridine Azo AzoCarbonylBeta AzoCyanamide Azoxy Bunte Carbamate CarbamicAcid CarbodiImide Carbonate Cationic-Br Cationic-C Cationic-Cl Cationic-I Cationic-O Cationic-P Cationic-S Chloramine Cyanate Cyanohydrin Diazo Diazonium Dichloramine Disulfide Dithioacetal Epoxide Enamine EnolEther HaloAmine HaloAmineAlfa HaloAmineBeta HaloAlkene HaloCarbamate HaloCarbonate HaloCarbonyl HaloCarbonylAlfa HaloCarbonylBeta HaloMethylEther HaloMethylThioether HaloPyrimidine HaloSulfide HaloSulfideAlfa HaloSulfideBeta HemiAcetal HemiAminal HemiKetal Hydrazide Hydrazine Hydrazone Hydroxylamine Hydroxytriazolester Imidoyl Imine Iodoso Iodoxy IsoCyanate IsoNitrile IsoThiocyanate Ketal Ketene Ketoxime Lactone LawessonsReagent MichaelAcceptor N-Halide Nitrate1 Nitrate2 Nitro1 Nitro2 Nitroso N-Methoyl NOxide1 NOxide2 NOxide3 Oxalyl Oxaziridine Oxetane P-Halide Pentafluorophenylester PerhaloketonePeroxide Phosphine Phosphinite1 Phosphonite2 Phosphite PhosphineOxide Phosphinate Phosphonate Phosphate Phosphorane Polyene QuatenaryAmmonium QuatenaryNitrogenCarbonylBeta SchiffBase SCN2 S-Halides SulfenicAcid SulfenicEster SulfinicAcid SulfinicEster SulfinylImine SulfinylHalide SulfinylNitrile SulfinylThio SulfonicAcid SulfonicEster Sulfone SulfonImine SulfonylAnhydride Sulfoxide TerminalVinylThietane ThiIrane ThioAmide ThioAcetal ThioCarbamate ThioEster-01 ThioEster-02 ThioKetal Thiol Thion ThioUrea Triazene Triflate Urea Adamantane Aminotriazole Aniline Aryl-4H-Pyridine Barbitarate Benzodioxolane Benzylhalogenide Clozapine DeltaLactam Dioxine Dibenzofurane Hydantoin Naphthylamine1 Naphthylamine_2 PosChargedNHeterocycle Psoralen Quinone tBOC CBZ Fmoc TBDMS TBDPS TIPS TMS
Providing user interaction.
With the possibility of multiple filters the original script is limited because the path to the filter file is hard coded into the script, also if users want to keep filters in a place of their own choosing or create their own filters then the script breaks. Much of this script is very similar to previous scripts, but in this script we start to explore providing the user with the opportunity to choose a file from the local file system.
file = vortex.getFile("Choose a filter file", [".sieve"], 0)
Pops up a dialog box asking the user to choose a filter file that has the extension .sieve, when the user chooses a file this is returned as a file path.
/Applications/Silicos/filter-it-1.0.0/filters/Leadlike.sieve
We then need to coerce it into a format Python understands.
sieveFile=file.getAbsolutePath()
returns
u'/Applications/Silicos/filter-it-1.0.0/filters/Leadlike.sieve'
Which we can now use in constructing the command line options.
'/usr/local/bin/filter-it', '--input='+sdfFile, '--filter='+sieveFile, '--tab'
The rest of the script runs the command and captures the output, this is then parsed to extract the first line to provide the column headers, and the rest of the output to provide the data.
The Vortex Script
import sys
sys.path.append(vortex.getVortexFolder() + '/modules/jythonlib')
import subprocess
# Open a dialog to choose a file
# getFile(title, extensions, 0 = Open, 1 = Save)
# vortex will keep track of the last folder you looked in etc
file = vortex.getFile("Choose a filter file", [".sieve"], 0)
if file:
vortex.alert(str(file))
# Need to coerce file path
sieveFile=file.getAbsolutePath()
# Get the path to the currently open sdf file
sdfFile = vortex.getFileForPropertyCalculation(vtable)
# http://silicos-it.com/tools/filter-it/filter-it.html
# Run filter-it on the file
# p = subprocess.Popen(['/usr/local/bin/filter-it', '--input='+sdfFile, '--filter=/Applications/Silicos/filter-it-1.0.0/filters/Druglike.sieve', '--tab'], stdout=subprocess.PIPE)
p = subprocess.Popen(['/usr/local/bin/filter-it', '--input='+sdfFile, '--filter='+sieveFile, '--tab'], stdout=subprocess.PIPE)
output = p.communicate()[0]
# Create new columns in table if needed
lines = output.split('\n')
colName = lines[0].split('\t')
for c in colName:
column = vtable.findColumnWithName(c, 1)
vtable.fireTableStructureChanged()
keys = []
for i in lines:
words = i.split('\t')
if len(words) == 2:
keys.append(words[0])
# Parse the output
rows = lines[1:len(lines)]
for r in range(0, vtable.getRealRowCount()):
vals = rows[r].split('\t')
for j in range(0, len(vals)):
column = vtable.findColumnWithName(colName[j], 0)
column.setValueFromString(r, vals[j])
The vortex script can be downloaded from here filterit.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
I’ve now created Vortex script exchange that users can use to download or share scripts. Other Hints, Tips and Tutorials
Last Updated 18 September 2012