# Distance calculation between four different protein residues and the ligand molecule as a function o

**URL:** <https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478>\
**Category:** User discussions\
**Tags:** pdb2gmx, mdrun, analysis-tools\
**Created:** [July 8, 2021, 8:17pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478 "2021-07-08T20:17:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amar\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Amar\_Kumar](https://gromacs.bioexcel.eu/u/Amar_Kumar)\
**Post date:** [July 8, 2021, 8:17pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/1 "2021-07-08T20:17:02Z")

</div>

GROMACS version:  
GROMACS modification: Yes/No  
Here post your question I am seeking some suggestions or help on how to find the distance between the different protein residues and ligand molecules as a function of time. I am seeing some suggestions regarding making index file of all the four residues of the protein and group it with the ligand but it did not work for me. Also for the index file do I consider the em. gro file or the output trajectory file (.xtc, or center.xtc or fix.xtc)

As I can see some other people also having trouble with the same issue a detailed explanation may also help others too.

Thank you.

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [July 12, 2021, 3:20am UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/2 "2021-07-12T03:20:28Z")

</div>

> [@Amar\_Kumar](#):
>
> but it did not work for me

What did you do? What happened?

> [@Amar\_Kumar](#):
>
> Also for the index file do I consider the em. gro file or the output trajectory file (.xtc, or center.xtc or fix.xtc)

The atom order never changes, so it is irrelevant which coordinate file you use (you cannot use trajectories for input to `make_ndx`).

---

<div class="post-metadata">

**Author:** ![Amar\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Amar\_Kumar](https://gromacs.bioexcel.eu/u/Amar_Kumar)\
**Post date:** [July 13, 2021, 11:09pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/3 "2021-07-13T23:09:03Z")

</div>

I followed this command:

gmx\_mpi distance -f md.xtc -s md\_0\_10.tpr -n md\_0\_10.ndx -oav distave.xvg -oall dist.xvg -oxyz distxyz.xvg -oh disthist.xvg -oallstat diststat.xvg -select `com of group "22" plus com of group "13"` -tu ns -dt 50

The error says that there are no such groups:

Error in user input:  
Invalid command-line options  
Unknown command-line option -selectcom of group “22” plus com of group  
“13”

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [July 14, 2021, 2:01pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/4 "2021-07-14T14:01:03Z")

</div>

Selection strings need to be enclosed by single quote marks.

```
gmx_mpi distance -f md.xtc -s md_0_10.tpr -n md_0_10.ndx 
-oav distave.xvg -oall dist.xvg -oxyz distxyz.xvg -oh disthist.xvg 
-oallstat diststat.xvg -select 'com of group "22" plus com of group "13"' 
-tu ns -dt 50
```

---

<div class="post-metadata">

**Author:** ![Amar\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Amar\_Kumar](https://gromacs.bioexcel.eu/u/Amar_Kumar)\
**Post date:** [July 15, 2021, 7:07pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/5 "2021-07-15T19:07:42Z")

</div>

Hello Dr. Lemkul,  
Thank you for the response. Its now showing a new error (mentioned below):

Invalid index group reference(s)  
Cannot match ‘group “22”’, because no such index group can be found.  
Cannot match ‘group “13”’, because no such index group can be found.

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [July 20, 2021, 1:14pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/6 "2021-07-20T13:14:53Z")

</div>

Group numbers are specified without quotation marks (which are used for group names).

---

<div class="post-metadata">

**Author:** ![Amar\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Amar\_Kumar](https://gromacs.bioexcel.eu/u/Amar_Kumar)\
**Post date:** [July 20, 2021, 5:38pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/7 "2021-07-20T17:38:39Z")

</div>

Thank you @jalemkul, the command worked, but as an output, I am getting all blank graphs and histograms.

But I am also getting the output numbers (mentioned below):

Analyzed 1 frames, last time 10000.000  
com of group 22 plus com of group 13:  
Number of samples: 1  
Average distance: 8.01073 nm  
Standard deviation: 0.00000 nm

I am a bit confused here. What am I doing wrong here? My motive is to select 4 residues from my protein of interest and find out the distance change (change in trajectory) of my ligand over the course of the simulation. Then plot the distance as a function of time.

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [July 20, 2021, 7:01pm UTC](https://gromacs.bioexcel.eu/t/distance-calculation-between-four-different-protein-residues-and-the-ligand-molecule-as-a-function-o/2478/8 "2021-07-20T19:01:48Z")

</div>

> [@Amar\_Kumar](#):
>
> Analyzed 1 frames, last time 10000.000  
> com of group 22 plus com of group 13:  
> Number of samples: 1

Apparently whatever you’re analyzing has one frame, so you’re not going to get a time series. If you have a multi-frame trajectory, you’ll get the output you want as a function of time. I have no idea what your groups are, but if you want four distance time series, you need to have the four residues of interest in their own groups and compute each COM distance of interest separately.
