[Chimera-users] Problem with charges when writing mol2 file with a python script.
Eric Pettersen
pett at cgl.ucsf.edu
Mon Apr 21 13:46:05 PDT 2014
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 at 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 at cgl.ucsf.edu
> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20140421/c5943abf/attachment.html>
More information about the Chimera-users
mailing list