<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 26, 2010, at 8:15 AM, Nancy wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Elaine,<br><br>I need to convert a large number of PubChem SDF files into Mol2 format. When I convert an SDF file into Mol2 format, I add partial charges and run energy minimisation on the molecule, as this is necessary for the program I am inputting the files into. So far, I have only used Chimera in this method to convert individual files. Is there a way to convert a large number of SDF files to Mol2 format at once, and also preserve the filenames?<br> <br>Thanks in advance,<br><br>Nancy<br></blockquote></div><br><div>Hi Nancy,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>There are several possibilities here. Probably the most straightforward is to use either the 1.4 or 1.4.1 release in conjunction with a script to process your files. Let's assume your files are all in one directory and have names of the form <i>moleculeName</i>.sdf . The following csh-style script would accomplish the task:</div><div><br></div><div><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">#!/bin/tcsh -f</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">foreach sdf (*.sdf)</span></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;"> </span></font></span><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">echo $sdf</span></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;"> </span></font></span><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">chimera --nogui $sdf processSDF.cmd</span></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;"> </span></font></span><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">mv output.mol2 $sdf:r.mol2</span></font></div><div><font class="Apple-style-span" face="'Courier New'">end</font></div><div><br></div><div>and where the contents of "processSDF.cmd" is just:</div><div><br></div><div><font class="Apple-style-span" face="'Courier New'" size="4"><span class="Apple-style-span" style="font-size: 16px;">minimize</span></font></div><div><font class="Apple-style-span" face="'Courier New'">write format mol2 0 output.mol2</font></div><div><br></div><div>You would want to put the csh script in a file (<i>e.g.</i> processSDF.csh) which you would want to make executable (chmod +x processSDF.csh). You would want to run the script <i>in</i> the directory with the SDF files, where the processSDF.cmd file would also be located. If you are familiar with shell scripting you can of course add paths to the various script names to change these requirements.</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>The above, though simple, may be a little slow due to starting one instance of Chimera per SDF file. You can get Chimera to run through your directory of SDF files, but you have to use a Python script instead of a Chimera command script. Like this:</div><div><br></div><div><span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 16px; ">chimera --nogui processSDF.py</span></div><div><br></div><div>with the contents of processSDF.py being:</div><div><br></div><div><span class="Apple-style-span" style="font-family: 'Courier New'; ">from os import chdir, listdir</span></div><div><font class="Apple-style-span" face="'Courier New'">from chimera import runCommand</font></div><div><font class="Apple-style-span" face="'Courier New'">chdir("/path/to/SDF-file-dir") # change to the SDF file directory</font></div><div><font class="Apple-style-span" face="'Courier New'">for sdf in listdir("."):</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>if not sdf.endswith(".sdf"):</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>continue</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>runCommand("open " + sdf)</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>runCommand("minimize")</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>runCommand("write format mol2 0 " + sdf[:-4] + ".mol2")</font></div><div><font class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" style="white-space:pre"> </span>runCommand("close all")</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 16px; "></span><span class="Apple-tab-span" style="white-space:pre"> </span>You could do all the above in the 1.5 release but the issue is that the 1.5 branch now uses the 1.3 version of AmberTools/Antechamber which relies on the program <i>sqm</i> to compute charges rather than <i>mopac</i>. While the charges computed by sqm are theoretically more precise than mopac, they take considerably longer to compute. We intend to add options for using less strict charge-convergence criteria in order to speed things up, but that work still is yet to be done. So whereas moieties involving ~35 or less atoms (including hydrogens) don't take excessive amounts of time (30 seconds or less), the compute time scales with the cube of the number of atoms(!) so a system of 72 atoms took more than 13 minutes and a system of 84 atoms took more than 21 minutes. I've also found that <i>sqm</i> fails to converge sometimes. The only structure I've had this happen with is ATP (at -4 charge), but it happened for a variety of conformers of ATP.</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>A final possibility is to use the PubChem3D (<a href="http://pubchem.ncbi.nlm.nih.gov/release3d.html">PubChem3D release note</a>) files and convert them directly to Mol2 files. This would require the 1.5 release (the 1.4 series doesn't read the charges in the SDF file) and assumes that the included MMFF charges are sufficient for your needs and that the conformer provided is good enough for your purposes without minimization. Using minimization would defeat the purpose here since Chimera's minimization needs to know GAFF atom types which requires non-standard residues to be processed by Antechamber which will add charges in addition to assigning types.</div><div><br></div><div>--Eric</div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> <span class="Apple-converted-space"> </span></span>Eric Pettersen</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> <span class="Apple-converted-space"> </span></span>UCSF Computer Graphics Lab</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> </span><a href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a></font></p><br class="Apple-interchange-newline"></div></span> </div><br></body></html>