Hi Javier,
If you are running this script with the Chimera graphical interface showing (i.e. not 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, including 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.
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:

from AddCharge import initiateAddCharges
initiateAddCharges(method='am1-bcc', nogui=True)

--Eric

                        Eric Pettersen
                        UCSF Computer Graphics Lab
                        http://www.cgl.ucsf.edu

On Apr 21, 2014, at 9:59 AM, jiserte@unq.edu.ar wrote:

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.
The script is this:
-----------------------------------------
import chimera                                     #1
from chimera import runCommand                     #2
runCommand('open ligands/lig_in.mol2')             #3
runCommand('addh')                                 #4
runCommand('addcharge')                            #5
runCommand('write format mol2 #0 lig_out.mol2')    #6

------------------------------------------
The result mol2 file does no contain any charges.
However, if a run another script that is exactly like this but does not contain the last line (#6),  and then
execute the command 'write format mol2 #0 lig_out.mol2' manually, the mol2 file contains charges.
I don't understand why there is a difference with both methods.
best regards.
javier

_______________________________________________
Chimera-users mailing list
Chimera-users@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users