# [gmx-users] g_covar average.pdb calculation

Deniz Aydin denizaydin at ku.edu.tr
Fri Sep 20 14:26:05 CEST 2013

```Dear All,

I would like to get information on how g_covar calculates the average
structure file (average.pdb)

My aim was actually to get a covariance matrix (<deltaR*deltaR>) so I
started off by writing my own code, I use MDAnalysis package, so I give psf
and traj files as an input and I generate the coordinates for each frame,
and if I have 3 frames, I take the average of each coordinate element for 3
frames. So for the 1st CA atom, I have x, y, z values for 3 frames. So I add
x1, x2, x3 values and divide by the number of frames. So this gives me the
average x coordinate of the 1st CA atom. I do the same for y and z and then
for all CA atoms. So if x1, x2, x3 for CA1 is 49.5 49.0 and 49.4 for 3
frames, the average x i get is 49.3. This is what I call an average
structure.

After doing this, I wanted to compare this with what g_covar gives me
(average.pdb) but found out that the result that I get from my own
calculations and the result I get from g_covar are very very different. The
g_covar command that I use is the following:

g_covar -f traj.xtc -s topol.tpr -ascii covar.dat -xpm covar.xpm -noref

Here I use -noref because I already use trjconv on my initial trajectory to
generate a new trajectory so I do -pbc mol and center and -fit rot+trans to
remove translation, rotation and to fit the structure. So I thought I could
use -nofit in g_covar to not to fit to the reference structure again.

So, coming back to my question, why would g_covar give me a very different
result than what I find with my simple code? What does g_covar do to
calculate this average structure? I thought maybe it does some fitting or
additional stuff to what I'm doing in my code or changes the units, that in
the end it doesn't give me the same coordinates for the average.pdb.

-----
Deniz Aydin, BSc.