Re: [AMBER] CpptrajPairDist

From: Daniel Roe <>
Date: Tue, 17 Dec 2013 14:44:32 -0700


The CpptrajPairDist file is binary; the exact format depends on what
version of cpptraj generated the file (since earlier versions had no
concept of 'sieve'). The CpptrajPairDist file starts with a 4 byte header
containing the characters 'C' 'T' 'M' followed by the version number. A
quick way to figure out the version is to use the linux 'od' command to
output the first 4 bytes as hexadecimal, e.g.:

$ od -t x1 -N 4 CpptrajPairDist
0000000 43 54 4d 02

So the CpptrajPairDist file version in the above example is 2.

The next few numbers describe the matrix size and depend on the version.

Version 0: Two 4-byte integers: # of rows and # of elements.
Version 1: Two 8-byte unsigned integers (equivalent to size_t on most
systems): # of rows and # of elements.
Version 2: Three 8 byte unsigned integers: original # of rows, actual # of
rows, and sieve value.

This is followed by the actual matrix data, stored as a single array of
floats (4 bytes). For versions 1 and 2 the number of elements is explicitly
stored. For version 2, to calculate the number of matrix elements you need
to read:

Elements = (actual_rows * (actual_rows - 1)) / 2

The cluster pair-distance matrix is an upper-right triangle matrix without
the diagonal (in row-major order), so the first element is the distance
between elements 0 and 1, the second is between elements 0 and 2, etc.

In version 2 files, if the sieve value is greater than 1 that means
original_rows > actual_rows and there is an additional array of characters
original_nrows long, with 'T' if the row is being ignored (i.e. it was
sieved out) and 'F' if the row is active (i.e. is active in the actual
pairwise-distance matrix).

The code that cpptraj uses to read in CpptrajPairDist files is in
ClusterMatrix::LoadFile() (ClusterMatrix.cpp). Let me know if you have more


On Tue, Dec 17, 2013 at 12:37 PM, JAIME RUBIO MARTINEZ

> I want to use the CpptrajPairDist file from the cluster savepairdist
> command of cpptraj
> to analyse the RMSD distance matrix, but I do not know how to extract the
> data.
> can anyone give me info on the format of this file?
> Thanks
> Jaime
> Aquest correu electrònic i els annexos poden contenir informació
> confidencial o protegida legalment i està adreçat exclusivament a la
> persona o entitat destinatària. Si no sou el destinatari final o la persona
> encarregada de rebre’l, no esteu autoritzat a llegir-lo, retenir-lo,
> modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si heu
> rebut aquest correu electrònic per error, us preguem que n’informeu al
> remitent i que elimineu del sistema el missatge i el material annex que
> pugui contenir. Gràcies per la vostra col·laboració.
> Este correo electrónico y sus anexos pueden contener información
> confidencial o legalmente protegida y está exclusivamente dirigido a la
> persona o entidad destinataria. Si usted no es el destinatario final o la
> persona encargada de recibirlo, no está autorizado a leerlo, retenerlo,
> modificarlo, distribuirlo, copiarlo ni a revelar su contenido. Si ha
> recibido este mensaje electrónico por error, le rogamos que informe al
> remitente y elimine del sistema el mensaje y el material anexo que pueda
> contener. Gracias por su colaboración.
> This email message and any documents attached to it may contain
> confidential or legally protected material and are intended solely for the
> use of the individual or organization to whom they are addressed. We remind
> you that if you are not the intended recipient of this email message or the
> person responsible for processing it, then you are not authorized to read,
> save, modify, send, copy or disclose any of its contents. If you have
> received this email message by mistake, we kindly ask you to inform the
> sender of this and to eliminate both the message and any attachments it
> carries from your account. Thank you for your collaboration.
> _______________________________________________
> AMBER mailing list

Daniel R. Roe, PhD
Department of Medicinal Chemistry
University of Utah
30 South 2000 East, Room 201
Salt Lake City, UT 84112-5820
(801) 587-9652
(801) 585-6208 (Fax)
AMBER mailing list
Received on Tue Dec 17 2013 - 14:00:03 PST
Custom Search