Sharing a script smiles -> to 2D -> protonate -> generate 3D conformers -> mol2

18 views
Skip to first unread message

Andrew Orry

unread,
Feb 11, 2025, 10:16:05 PMFeb 11
to MolSoft ICM Knowledge Base
Sharing a script—please feel free to adapt it to your needs or suggest improvements.

This script reads a CSV file containing SMILES, converts them to 2D, protonates the molecules, generates 3D conformers, and writes them out in MOL2 format.
You can save the script as a text file, for example, smiles_to_mol2.icm, and then specify the path to your CSV file (e.g., myDB.csv).

To run:
icm smiles_to_mol2.icm /path/to/example/myDB.csv

l_commands = no
# get arguments
if (Nof(Getarg(list)) != 1) quit " Error> input file is not provided"

s_inputFile = Getarg(list)[1]
s_inputSDF = s_tempDir + Name(s_inputFile) + ".sdf"
s_outputSDF = s_tempDir + Name(s_inputFile) + "_conf.sdf"

# read csv
read table separator="," s_inputFile name="t"
# smiles to 2d
add column t Chemical(t.A) index=1
# protonate
# set charge formal auto Xdict.mol 7.0 -> -C argument in _confGen
# write sdf file for _confGen
write table mol t s_inputSDF delete

# generate conformers
s_cmd = Path( macro "-P" + s_icmhome //  "_confGen" // "-C" // "-f" // s_inputSDF // s_outputSDF // "mnconf=1" )
unix $s_cmd

# read conformers and convert to mol2
read table mol s_outputSDF name="t"
for i=1,Nof(t)
  read mol t.mol[i]
  write mol2 delete a_ Name(s_inputFile) + "_conf_" + String(i)
  delete a_
endfor

# remove teporary files
delete system s_inputSDF // s_outputSDF

quit
Reply all
Reply to author
Forward
0 new messages