From: Athanassios Stavrakoudis (
Date: Mon Apr 27 2009 - 05:12:18 CDT

Dear Dimitry,

you do not need the coordinates file for this type of calculation.
A simple awk command can do the trick:

awk '$2=="A" {S+=$7} END {print S}' fname.psf

Where "A" is the chain id (second column in the psf file).
You can add more chains using the OR operator if you have big systems:
awk '$2=="A" || $2=="B" {S+=$7} END {print S}' fname.psf
or do some tricky thinks with awk for more complicated situations.
It takes ~0.04 sec on my (2 years old) Linux Box to compute
the sum of a system with ~6500 atoms.

All the best,

> 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.

Athanassios Stavrakoudis
University of Ioannina web:
Department of Economics e-mail:
GR-45110, Ioannina tel: +30 651 095 935
GREECE fax: +30 651 095 039