From: Eduardo Cruz-Chu (chucruz_at_ks.uiuc.edu)
Date: Mon Apr 27 2009 - 10:50:01 CDT

you can also use "measure" command.

set all [ atomselect top all ]
measure sumweights $all weight charge

On Mon, 27 Apr 2009, DimitryASuplatov wrote:

> Hello,
>
> I want to calculate net system charge of my system given pdb and psf
> files. I also want to be able to do it automatically via script.
>
> I tried using something like:
>
> mol load psf $fname.psf pdb $fname.pdb
>
> set ev [atomselect top all]
> set indices [$ev get index]
>
> set netcharge 0
>
> foreach ind $indices {
> set at [atomselect top "index $ind"]
> set charge [$at get charge]
> set netcharge [ expr $netcharge + $charge ]
> $charge delete
> }
>
> puts "$netcharge"
>
> It works and outputs the correct value though it works some 5-10
> seconds compared to autoioize plugin which does the complete job
> including ionization in less then 5 seconds.
>
> So my question is
> Is there a one-word command to quickly
> calculate system net charge give charmm topology and pdb coordinates?
>
> Thank you for your time.
> SDA
>