# [gmx-users] Gmx distance

Dallas Warren dallas.warren at monash.edu
Thu Dec 6 12:15:35 CET 2018

```Did you try using gmx rdf -xy ?

That is probably going to do what you want.  You will have to ensure that
the axis of the CNT is aligned exactly along the z axis.

Catch ya,

Dr. Dallas Warren
Drug Delivery, Disposition and Dynamics
Monash Institute of Pharmaceutical Sciences, Monash University
381 Royal Parade, Parkville VIC 3052
dallas.warren at monash.edu
---------------------------------
When the only tool you own is a hammer, every problem begins to resemble a
nail.

On Mon, 26 Nov 2018 at 11:13, Dallas Warren <dallas.warren at monash.edu>
wrote:

> It will be calculating it based on the COM of the CNT, which will be a
> single point, since that is what you are asking to do.
>
> One way I can see is align the axis of the CNT so that it has the same
> x,y coordinates all the way along, process in same manner, then
> separate the distance in the x-y plan from your output data using
> simple trigonometry.  Alternatively split box into slices along the
> z-axis, so that the difference in the total distance at the top of the
> slice versus middle of slice is sufficiently small (i.e. theta ~ 0),
> calculate it for each slice, then average across all slices.
>
> Catch ya,
>
> Dr. Dallas Warren
> Drug Delivery, Disposition and Dynamics
> Monash Institute of Pharmaceutical Sciences, Monash University
> 381 Royal Parade, Parkville VIC 3052
> dallas.warren at monash.edu
> ---------------------------------
> When the only tool you own is a hammer, every problem begins to resemble a
> nail.
>
> On Thu, 22 Nov 2018 at 23:35, rose rahmani <rose.rhmn93 at gmail.com> wrote:
> >
> > To be clear, i put 30 similar AA around NT i want to know how the average
> > distance of group PROTEIN( consist of 30 AA ) varies during 100nS
> > simulation. As i see in .gro file this distance decreased. I mean at the
> > first moment i put them about 3nm far from Z axis of NT. THIS 3NM IS THE
> > MINIMUM LENGTH OF A LINE BETWEEN AA COM POINT AND Z AXIS OF NT, AS YOU
> CAN
> > IMAGINE THIS LINE IS PERPENDICULAR TO Z AXIS OF NT. this length is
> decrease
> > after 100nS. But what i can't understand is that when i analyze it by
> > g_dist( i select ZnS(NT) and Group Potein(=30 AA) in g_dist).. this is
> the
> > result!
> >
> > Group     0 (         System) has 27831 elements
> > Group     1 (          Other) has   408 elements
> > Group     2 (            ZnS) has   408 elements
> > Group     3 (        Protein) has   720 elements
> > Group     4 (      Protein-H) has   390 elements
> > Group     5 (        C-alpha) has    30 elements
> > Group     6 (       Backbone) has    90 elements
> > Group     7 (      MainChain) has    90 elements
> > Group     8 (   MainChain+Cb) has   120 elements
> > Group     9 (    MainChain+H) has   180 elements
> > Group    10 (      SideChain) has   540 elements
> > Group    11 (    SideChain-H) has   300 elements
> > Group    12 (    Prot-Masses) has   720 elements
> > Group    13 (    non-Protein) has 27111 elements
> > Group    14 (          Water) has 26703 elements
> > Group    15 (            SOL) has 26703 elements
> > Group    16 (      non-Water) has  1128 elements
> >
> > Select a group: 2
> > Selected 2: 'ZnS'
> > Select a group: 3
> > Selected 3: 'Protein'
> >
> >    0.0000000    0.2176011   -0.0120678   -0.0465498    0.2122209
> >    1.0000000    0.2124534   -0.0301750   -0.0463870    0.2051198
> >    2.0000000    0.1923753   -0.0158403   -0.0510135    0.1848106
> >    3.0000000    0.1885315   -0.0107298   -0.0488160    0.1817856
> >    4.0000000    0.2044982   -0.0052650   -0.0490329    0.1984630
> >    5.0000000    0.2033602   -0.0002742   -0.0429537    0.1987720
> >    6.0000000    0.2050487    0.0013833   -0.0444658    0.2001646
> >    7.0000000    0.2002475    0.0041072   -0.0415003    0.1958568
> >    8.0000000    0.2006473    0.0033450   -0.0511889    0.1939790
> >    9.0000000    0.2032918   -0.0000119   -0.0330052    0.2005947
> >   10.0000000    0.2255659    0.0003929   -0.0415857    0.2216990
> >   11.0000000    0.2243811    0.0118313   -0.0344751    0.2214010
> > .
> > .
> > .
> > 99990.0000000    0.6195676   -0.1357532   -0.0029635    0.6045051
> > 99991.0000000    0.5355353   -0.3716600    0.0125020    0.3853707
> > 99992.0000000    0.5243484   -0.3698001    0.0180452    0.3712997
> > 99993.0000000    0.4459361   -0.1407223   -0.2021322    0.3717511
> > 99994.0000000    0.5592619   -0.3545561   -0.2162843    0.3745463
> > 99995.0000000    0.5707593   -0.3472078   -0.2309759    0.3896961
> > 99996.0000000    0.5238984   -0.3467841   -0.0103419    0.3925600
> > 99997.0000000    0.5122938   -0.3379052    0.0097873    0.3849275
> > 99998.0000000    0.5608831   -0.3396225   -0.2052171    0.3963993
> > 99999.0000000    0.5230988   -0.3479364    0.0172603    0.3902240
> > 100000.0000000    0.5158455   -0.3283865    0.0047119    0.3977897
> >
> > If the nanotube is along Z axis, so how g_dist calculate the COM of nano
> > tube? Is it each point along Z axis which pass center of nano tube or COM
> > in this case is just one point in the nanotube. If it is the second one,
> so
> > g_dist doesn't calculate perpendicular distance from AA to Z axis... so
> it
> > is completely different from what i want.
> >
> > How can i get what i want?
> > this is exactly what want it is not an article it is just the figure 2
> >
> https://www.sciencedirect.com/science/article/pii/S0008622314006691#f0010
> >
> >
> > i'm completely confused!
> >
> > Best
> > Rose
> >
> >
> >
> >
> > On Wed, 7 Nov 2018, 18:32 Justin Lemkul <jalemkul at vt.edu wrote:
> >
> > >
> > >
> > > On 11/3/18 2:15 PM, rose rahmani wrote:
> > > > On Sat, 3 Nov 2018, 19:56 Justin Lemkul <jalemkul at vt.edu wrote:
> > > >
> > > >>
> > > >> On 11/2/18 11:36 AM, rose rahmani wrote:
> > > >>> but this is output of -oall. its not a single value?!
> > > >> You are asking in your command for all interatomic distances
> between the
> > > >> groups (presumably, because you haven't shown your selection). This
> > > >> command won't yield what you're hoping to see and my advice does not
> > > >> apply for this type of situation (which doesn't seem to even match
> your
> > > >> original statement of your problem).
> > > >>
> > > >>>     gmx distance -f md2.xtc -oall dist.xvg -n index.ndx
> > > >>> # gmx distance is part of G R O M A C S:
> > > >>> #
> > > >>> #
> > > >>>
> > > >>
> > >
> Â¸<8d><9a><9a><91>ÃÂ­<9a><9b>ÃÂ°<8d><9e><91><98><9a>ÃÂ²<9e><98><9a><91><8b><9e>ÃÂ¾<85><8a><8d><9a>ÃÂ¼<86><9e><91>ÃÂ¬<94><86><9d><99a>8a><<
> > > >>> #
> > > >>> @    title "Distance"
> > > >>> @    xaxis  label "Time (ps)"
> > > >>> @    yaxis  label "Distance (nm)"
> > > >>> @TYPE xy
> > > >>>
> > > >>>       1.000    0.229    0.229    0.446    0.582    0.446    0.229
> > > 0.446
> > > >>> 0.583    0.447    0.229    0.447    0.227    0.228    0.229
> 0.446
> > > >>> 0.582    0.446    0.228    0.446    0.583    0.447    0.228
> 0.447
> > > >>> 0.227    0.227    0.228    0.446    0.582    0.446    0.227
> 0.446
> > > >>> 0.583    0.447    0.227    0.447    0.227    0.228    0.229
> 0.446
> > > >>> 0.582    0.446    0.228    0.446    0.583    0.447    0.228
> 0.447
> > > >>> 0.227    0.228    0.229    0.446    0.582    0.446    0.228
> 0.446
> > > >>> 0.583    0.447    0.228    0.447    0.227    0.229    0.229
> 0.446
> > > >>> 0.582    0.446    0.229    0.446    0.583    0.447    0.229
> 0.447
> > > >>> 0.227    0.229    0.229    0.446    0.582    0.446    0.229
> 0.446
> > > >>> 0.583    0.447    0.229    0.447    0.227    0.228    0.229
> 0.446
> > > >>> 0.582    0.446    0.228    0.446    0.583    0.447    0.228
> 0.447
> > > >>> 0.227    0.228    0.229    0.446    0.582    0.446    0.228
> 0.446
> > > >>> 0.583    0.447    0.228    0.447    0.227    0.227    0.228
> 0.446
> > > >>> 0.582    0.446    0.227    0.446    0.583    0.447    0.227
> 0.447
> > > >>> 0.227    0.228    0.229    0.446    0.582    0.446    0.228
> 0.446
> > > >>> 0.583    0.447    0.228    0.4
> > > >>> .
> > > >>> .
> > > >>> .
> > > >>>
> > > >>> and this is -o of g_dist;
> > > >>>    g_dist -f md2.xtc -s md2.tpr -n index -o all.xvg
> > > >>> #
> > > >>> # g_dist is part of G R O M A C S:
> > > >>> #
> > > >>> # GRowing Old MAkes el Chrono Sweat
> > > >>> #
> > > >>> @    title "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 "|d|"
> > > >>> @ s1 legend "d\sx\N"
> > > >>> @ s2 legend "d\sy\N"
> > > >>> @ s3 legend "d\sz\N"
> > > >>>      0.0000000    0.2176011   -0.0120678   -0.0465498    0.2122209
> > > >>>      1.0000000    0.2124534   -0.0301750   -0.0463870    0.2051198
> > > >>>      2.0000000    0.1923753   -0.0158403   -0.0510135    0.1848106
> > > >>>      3.0000000    0.1885315   -0.0107298   -0.0488160    0.1817856
> > > >>>      4.0000000    0.2044982   -0.0052650   -0.0490329    0.1984630
> > > >>>      5.0000000    0.2033602   -0.0002742   -0.0429537    0.1987720
> > > >>>      6.0000000    0.2050487    0.0013833   -0.0444658    0.2001646
> > > >>>      7.0000000    0.2002475    0.0041072   -0.0415003    0.1958568
> > > >>>      8.0000000    0.2006473    0.0033450   -0.0511889    0.1939790
> > > >>>      9.0000000    0.2032918   -0.0000119   -0.0330052    0.2005947
> > > >>>     10.0000000    0.2255659    0.0003929   -0.0415857    0.2216990
> > > >>>     11.0000000    0.2243811    0.0118313   -0.0344751    0.2214010
> > > >>>     12.0000000    0.2347855    0.0078275   -0.0383532    0.2314994
> > > >>>     13.0000000    0.2371541    0.0081918   -0.0388267    0.2338107
> > > >> Here, you have what you want (I assume), and the first column after
> the
> > > >> time is all you need. It's the distance, which also can't be
> negative
> > > >> because it is the magnitude of the vector length and is unsigned.
> > > >>
> > > > How S0 is calculated? Does it resulted from distance between COM of
> amino
> > > > acid and COM of tube? Although, it is the magnitude of ... but it's
> > >
> > > The distance you get is the distance you ask for in your selection
> > > (which isn't shown or stated). The distance formula is quite simple,
> > > consult any geometry textbook.
> > >
> > > > calculated from x,y,z which may be negative and were not abaolute?!
> In
> > > > addition, i put AAs (more than) 1.5 nm far from tube as an initial
> > > > configuration, but any 1.5 nm distance..???
> > > >
> > >
> > > A component of a vector may be positive or negative, these are just
> > > differences along x, y, and z. The total length of a vector is a
> > > magnitude and is therefore positive.
> > >
> > > -Justin
> > >
> > > >
> > > >> -Justin
> > > >>
> > > >>> .
> > > >>> .
> > > >>> .
> > > >>>
> > > >>>
> > > >>> On Thu, Nov 1, 2018 at 11:39 PM Justin Lemkul <jalemkul at vt.edu>
> wrote:
> > > >>>
> > > >>>> On 11/1/18 2:25 PM, rose rahmani wrote:
> > > >>>>> I don't know how? I mean x,y,z(s1, s2,s3) in dist.xvg can easily
> be
> > > >>>>> multiplied by (-), but how should i modify second column,i don't
> know
> > > >> how
> > > >>>>> s0 is calculated by g_distance to modify it??
> > > >>>> The output of -oall is a single value, the actual distance, which
> I
> > > >>>> assume is what you are talking about in your previous message.
> You can
> > > >>>> parse that column in any scripting language you like and
> > > >>>>
> > > >>>> [ pseudocode, not functional ]
> > > >>>> if (value < 0)
> > > >>>> {
> > > >>>>        value *= -1
> > > >>>> }
> > > >>>>
> > > >>>> -Justin
> > > >>>>> On Wed, 31 Oct 2018, 19:38 Justin Lemkul, <jalemkul at vt.edu>
> wrote:
> > > >>>>>
> > > >>>>>> On 10/31/18 12:06 PM, rose rahmani wrote:
> > > >>>>>>> Hi,
> > > >>>>>>>
> > > >>>>>>> I want to calculate distances between fixed tube in the middle
> of
> > > the
> > > >>>> box
> > > >>>>>>> and amino acids(all are same type)around it. But gmx distance
> gives
> > > >> me
> > > >>>>>> the
> > > >>>>>>> relative distance i mean AA can be front or back( can be 0.5 or
> > > -0.5
> > > >>>> from
> > > >>>>>>> tube) of  tube but still |-0.5|=0.5 nm far from it. How can i
> have
> > > >> the
> > > >>>>>>> absolute value of distances?
> > > >>>>>> Write a simple post-processing script that multiplies any
> negative
> > > >> value
> > > >>>>>> by -1.
> > > >>>>>>
> > > >>>>>> -Justin
> > > >>>>>>
> > > >>>>>> --
> > > >>>>>> ==================================================
> > > >>>>>>
> > > >>>>>> Justin A. Lemkul, Ph.D.
> > > >>>>>> Assistant Professor
> > > >>>>>> Virginia Tech Department of Biochemistry
> > > >>>>>>
> > > >>>>>> 303 Engel Hall
> > > >>>>>> 340 West Campus Dr.
> > > >>>>>> Blacksburg, VA 24061
> > > >>>>>>
> > > >>>>>> jalemkul at vt.edu | (540) 231-3129
> > > >>>>>> http://www.thelemkullab.com
> > > >>>>>>
> > > >>>>>> ==================================================
> > > >>>>>>
> > > >>>>>> --
> > > >>>>>> 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.
> > > >>>>>>
> > > >>>> --
> > > >>>> ==================================================
> > > >>>>
> > > >>>> Justin A. Lemkul, Ph.D.
> > > >>>> Assistant Professor
> > > >>>> Virginia Tech Department of Biochemistry
> > > >>>>
> > > >>>> 303 Engel Hall
> > > >>>> 340 West Campus Dr.
> > > >>>> Blacksburg, VA 24061
> > > >>>>
> > > >>>> jalemkul at vt.edu | (540) 231-3129
> > > >>>> http://www.thelemkullab.com
> > > >>>>
> > > >>>> ==================================================
> > > >>>>
> > > >>>> --
> > > >>>> 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.
> > > >> --
> > > >> ==================================================
> > > >>
> > > >> Justin A. Lemkul, Ph.D.
> > > >> Assistant Professor
> > > >> Virginia Tech Department of Biochemistry
> > > >>
> > > >> 303 Engel Hall
> > > >> 340 West Campus Dr.
> > > >> Blacksburg, VA 24061
> > > >>
> > > >> jalemkul at vt.edu | (540) 231-3129
> > > >> http://www.thelemkullab.com
> > > >>
> > > >> ==================================================
> > > >>
> > > >> --
> > > >> 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.
> > >
> > > --
> > > ==================================================
> > >
> > > Justin A. Lemkul, Ph.D.
> > > Assistant Professor
> > > Virginia Tech Department of Biochemistry
> > >
> > > 303 Engel Hall
> > > 340 West Campus Dr.
> > > Blacksburg, VA 24061
> > >
> > > jalemkul at vt.edu | (540) 231-3129
> > > http://www.thelemkullab.com
> > >
> > > ==================================================
> > >
> > > --
> > > 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.
>
```