<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Javier,<div><span class="Apple-tab-span" style="white-space:pre"> </span>If you are running this script with the Chimera graphical interface showing (i.e. <i>not</i> by running Chimera from a shell command line with the '--nogui' flag), then what's happening is that you are getting the "formal charge confirmation" dialog but since it's not a modal dialog the rest of Chimera keeps running, <i>including</i> your script. So your log_out.mol2 file has already been written (with 0.0 charges for the ligand atoms) before you can even click the OK button on the dialog.</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>So, to get the result you want you either have to run your script in nogui mode, or you have to call the Python addcharge code directly. Here's code that would do that:</div><div><br></div><div>from AddCharge import initiateAddCharges</div><div>initiateAddCharges(method='am1-bcc', nogui=True)</div><div><br></div><div>--Eric</div><div><div><br> Eric Pettersen<br> UCSF Computer Graphics Lab<br> <a href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a><br><br></div></div><div><div><div>On Apr 21, 2014, at 9:59 AM, <a href="mailto:jiserte@unq.edu.ar">jiserte@unq.edu.ar</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
<div style="font-family:Arial;font-size:14px"><p>I'm trying to write a simple python script to open a mol2 file with a ligand, add hydrogens, add charges and write it into another mol2.<br>
The script is this:<br>
-----------------------------------------<br>
<span style="font-family:courier new,courier,monospace;">import chimera #1<br>
from chimera import runCommand #2<br>
runCommand('open ligands/lig_in.mol2') #3<br>
runCommand('addh') #4<br>
runCommand('addcharge') #5<br>
runCommand('write format mol2 #0 lig_out.mol2') #6</span><br>
------------------------------------------<br>
The result mol2 file does no contain any charges.<br>
However, if a run another script that is exactly like this but does not contain the last line (#6), and then<br>
execute the command '<span style="font-family:courier new,courier,monospace;">write format mol2 #0 lig_out.mol2'</span> manually, the mol2 file contains charges.<br>
I don't understand why there is a difference with both methods.<br>
best regards.<br>
javier<br>
<br></p>
</div>
_______________________________________________<br>Chimera-users mailing list<br><a href="mailto:Chimera-users@cgl.ucsf.edu">Chimera-users@cgl.ucsf.edu</a><br>http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users<br></blockquote></div><br></div><br><br></body></html>