# [gmx-users] Measuring distance to the nearest image

Mark Abraham mark.j.abraham at gmail.com
Wed Dec 20 11:28:46 CET 2017

```Hi,

>From its help: "gmx distance calculates distances between pairs of
positions as a function of
time. Each selection specifies an independent set of distances to calculate.
Each selection should consist of pairs of positions, and the distances are
computed between positions 1-2, 3-4, etc."

You've got it computing distances within each group, which is why they have
little or no variation and have the length of a C-H bond and maybe a C-C
bond. Per "gmx help selections examples", you might try something like "gmx
distance -select 'com of HYP1 plus com of GLPInt1' -s -n"

I'll add an explicit tip to the help text - you're not the first person to
assume that giving it two selection groups gets some kind of distance
between the groups.

Mark

On Wed, Dec 20, 2017 at 7:56 PM Anthony Nash <anthony.nash at dpag.ox.ac.uk>
wrote:

> Hi Mark,
>
> I think with a combined project list as long as my arm and going between
> VMD and Gromacs that the fault lies with me. A misunderstanding with the
> decimal point. However, I am a little confused over the output and despite
> reading the help I am still none the wiser.
>
> I go on to select two groups:
>
> [ HYP1 ]  ← part of the side chain of a hydroxyproline
> 4669 4670 4672 4673 4676 4677
> [ GLPInt1 ] ←
>  563 564 566 567 570 571 574 576
>
>  I assume the average absolute distance between the two groups will be the
> same regardless of which one you take your measurement (as x1, y1, z1)
> from. My output looks like:
>
> @    title "Average distance"
> @    xaxis  label "Time (ps)"
> @    yaxis  label "Distance (nm)"
> @TYPE xy
> @ view 0.15, 0.15, 0.75, 0.85
> @ legend on
> @ legend box on
> @ legend loctype view
> @ legend 0.78, 0.8
> @ legend length 2
> @ s0 legend "HYP1"
> @ s1 legend "GLPInt1"
>   10000.000    0.109    0.159
>   10000.200    0.109    0.159
>   10000.400    0.109    0.160
>
> Reflected in the on-screen output (I have just used a tiny sample size to
> run this very quickly, the standard deviation in the larger sample size is
> much different)
>
> Analyzed 501 frames, last time 100.200
> HYP1:
>   Number of samples:  1503
>   Average distance:   0.10900  nm
>   Standard deviation: 0.00000  nm
> GLPInt1:
>   Number of samples:  2004
>   Average distance:   0.15911  nm
>   Standard deviation: 0.05431  nm
>
> I want the distance between HYP1 and GLPInt1. Why the two measurements?
> Clearly there is something I do not understand about the gmx distance
> command.
>
> Really hope you can clear this up. Thanks again!
> Anthony
>
>
> On 19/12/2017 11:25, "gromacs.org_gmx-users-bounces at maillist.sys.kth.se
> on behalf of Mark Abraham" <
> gromacs.org_gmx-users-bounces at maillist.sys.kth.se on behalf of
> mark.j.abraham at gmail.com> wrote:
>
>     Hi,
>
>     An example where the structure comes from a single frame would be a
> useful
>     thing to explore whether the code is working correctly. I don't think
> the
>     composition of the index groups should matter, but I can't see how the
> code
>     wouldn't work correctly.
>
>     Mark
>
>     On Tue, Dec 19, 2017, 10:12 PM Anthony Nash <
> anthony.nash at dpag.ox.ac.uk>
>     wrote:
>
>     > Hi Mark,
>     >
>     > As an example, from numerous attempts, I have tried:
>     >
>     > /usr/local/gromacs5.1.2/bin/gmx_d distance -pbc -b 10000 -f
>     >
>     > which was throwing a value of around 8 nm, rather than the 2 nm I was
>     > expecting if it took a measurement from over the periodic boundary.
>     >
>     > Unfortunately, I’ve left the necessary harddrive at home. I’’’ be
> more
>     > than happy to respond with a more comprehensive example along with
> output
>     > data in a few hours.
>     >
>     > Thanks
>     > Anthony
>     >
>     >
>     > On 19/12/2017 11:02, "
> gromacs.org_gmx-users-bounces at maillist.sys.kth.se
>     > on behalf of Mark Abraham" <
>     > gromacs.org_gmx-users-bounces at maillist.sys.kth.se on behalf of
>     > mark.j.abraham at gmail.com> wrote:
>     >
>     >     Hi
>     >
>     >     This is exactly what two well chosen selections should produce,
> given
>     > a tpr
>     >     and the PBC option. What have you tried that didn't work as you
>     > expected?
>     >
>     >     Mark
>     >
>     >     On Mon, Dec 18, 2017, 5:23 PM Anthony Nash <
> anthony.nash at dpag.ox.ac.uk
>     > >
>     >     wrote:
>     >
>     >     >
>     >     > Hi all,
>     >     >
>     >     > I am trying to measure the distance between the COM of two
> side chain
>     >     > functional groups across the periodic boundary to their
> nearest image
>     >     > rather than across the unit cell itself. I have tried several
> gromacs
>     >     > distance commands with no success and more at random as I trawl
>     > through the
>     >     > help and manual, so I won’t replicate those commands here.
>     >     >
>     >     > This link is a hand drawn image of what I am trying to do. I
> would
>     > like to
>     >     > measure how far apart the two large dots are across the
> periodic
>     > boundary.
>     >     > VMD gives me roughly 1 nm, but the Gromacs commands give me 8
> nm as
>     > it
>     >     > takes the measurement from within the unit cell.
>     >     >
>     >     >
>     >     >
>     >
> https://www.researchgate.net/profile/Anthony_Nash3/post/How_to_calculate_distance_between_groups_into_the_nearest_image_using_Gromacs/attachment/5a30d10eb53d2f0bba43e5c3/AS:571001131417600@1513148686095/image/IMG_20171213_065534.jpg
>     >     > If this involve a tcl script in VMD I would appreciate knowing
> how
>     > to code
>     >     > for an atom selection in a “Periodic” image rather than the
> “Self”.
>     >     >
>     >     > Loads of thanks!
>     >     > Anthony
>     >     > --
>     >     > Gromacs Users mailing list
>     >     >
>     >     > * Please search the archive at
>     >     > http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List
> before
>     >     > posting!
>     >     >
>     >     > * Can't post? Read
> http://www.gromacs.org/Support/Mailing_Lists
>     >     >
>     >     > * For (un)subscribe requests visit
>     >     >
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
>     > or
>     >     > send a mail to gmx-users-request at gromacs.org.
>     >     --
>     >     Gromacs Users mailing list
>     >
>     >     * Please search the archive at
>     > http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>     > posting!
>     >
>     >     * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>     >
>     >     * For (un)subscribe requests visit
>     >
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
>     > send a mail to gmx-users-request at gromacs.org.
>     >
>     > --
>     > Gromacs Users mailing list
>     >
>     > * Please search the archive at
>     > http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>     > posting!
>     >
>     > * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>     >
>     > * For (un)subscribe requests visit
>     > https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
> or
>     > send a mail to gmx-users-request at gromacs.org.
>     --
>     Gromacs Users mailing list
>
>     * Please search the archive at
> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
> posting!
>
>     * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>
>     * For (un)subscribe requests visit
>     https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
> send a mail to gmx-users-request at gromacs.org.
>
> --
> Gromacs Users mailing list
>
> * Please search the archive at
> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
> posting!
>
> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>
> * For (un)subscribe requests visit
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
> send a mail to gmx-users-request at gromacs.org.
```