# \-pbc flag in hbond calculation not working

**URL:** <https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472>\
**Category:** User discussions\
**Created:** [June 22, 2024, 7:57am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472 "2024-06-22T07:57:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sahil](https://gromacs.bioexcel.eu/u/Sahil)\
**Post date:** [June 22, 2024, 7:57am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/1 "2024-06-22T07:57:40Z")

</div>

GROMACS version: 2021.5  
GROMACS modification: No

Hii  
In my simulation box, the protein and the DNA are totally out of the boxes. I modified the trajectory with -pbc whole and -pbc nojump. Now I’m trying to calculate the hbonds between them. The distance between them is more than 4nm, and it should not make any hbonds. However I’m still getting it. I was facing similar problem with the gmx mindist but there -pbc flag worked and gave me proper distances, however in gmx hbond, -pbc flag is not working.

Any kind of help is highly appreciated.  
Thank you for reading.

---

<div class="post-metadata">

**Author:** ![Karis](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@Karis](https://gromacs.bioexcel.eu/u/Karis)\
**Post date:** [June 27, 2024, 5:04am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/2 "2024-06-27T05:04:01Z")

</div>

Did you also include the -pbc flag as part of the hbond command? I’ve found that for the analysis modules, even if you’re running them on trajectories with pbc removed, the results returned are still for the trajectory with pbc unless you also include the -pbc flag in the analysis command

---

<div class="post-metadata">

**Author:** ![Sahil](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sahil](https://gromacs.bioexcel.eu/u/Sahil)\
**Post date:** [June 27, 2024, 5:19am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/3 "2024-06-27T05:19:03Z")

</div>

For the hbond analysis I used "gmx hbond -f \*.xtc -s \*.tpr -n \*.ndx -num \*.xvg -pbc no ". The trajectory is already modified with pbc removed. It is still not working.

---

<div class="post-metadata">

**Author:** ![Karis](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@Karis](https://gromacs.bioexcel.eu/u/Karis)\
**Post date:** [June 27, 2024, 5:44am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/4 "2024-06-27T05:44:12Z")

</div>

Could you try visualizing the system and seeing which hbonds are being identified? It might be that pbc removal isn’t working perfectly, and especially in the case of multiple freely floating molecules, it might be difficult to stop objects from interacting with mirror images of a different object.

You can find a description of how each pbc option works here: [gmx trjconv - GROMACS 2024.2 documentation](https://manual.gromacs.org/current/onlinehelp/gmx-trjconv.html). While they mostly work to stop an object from interacting with its own mirror image, if you have 2 separate objects floating at opposite ends of the box, preventing interactions might require altering the set up of the simulation

---

<div class="post-metadata">

**Author:** ![Sahil](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sahil](https://gromacs.bioexcel.eu/u/Sahil)\
**Post date:** [June 27, 2024, 5:58am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/5 "2024-06-27T05:58:39Z")

</div>

My question is, does the -pbc flag work with gmx hbond? Because in my case it is not working.

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/bioexcel1/original/2X/1/1d677b9ea6d5962733c40c97ff01c3d71b2af95a.png)

---

<div class="post-metadata">

**Author:** ![Karis](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@Karis](https://gromacs.bioexcel.eu/u/Karis)\
**Post date:** [June 27, 2024, 6:21am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/6 "2024-06-27T06:21:15Z")

</div>

I see it listed in the 2024.2 documentation but not in earlier versions so it might not work with older versions of gmx hbond

---

<div class="post-metadata">

**Author:** ![obZehn](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/obzehn/32/2629_2.png) [@obZehn](https://gromacs.bioexcel.eu/u/obZehn)\
**Post date:** [June 27, 2024, 8:36am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/7 "2024-06-27T08:36:21Z")

</div>

Please take a look at the [manual](https://manual.gromacs.org/2021/onlinehelp/gmx-hbond.html). For GROMACS 2021, there is no `pbc` flag. There is for GROMACS 2024 but the tool is different (the one in previous versions has been moved to [hbond-legacy](https://manual.gromacs.org/current/onlinehelp/gmx-hbond-legacy.html)).

---

<div class="post-metadata">

**Author:** ![Ligand1](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@Ligand1](https://gromacs.bioexcel.eu/u/Ligand1)\
**Post date:** [June 28, 2024, 9:58pm UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/8 "2024-06-28T21:58:22Z")

</div>

Hi,

I have a small followup question @Karis . Do we need to give -pbc flag for every analysis? I am not familiar with this and this is something not mentioned in the Gromacs tutorials written by Dr. Justin Lemkul.

Thanks

---

<div class="post-metadata">

**Author:** ![scinikhil](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/scinikhil/32/3483_2.png) [@scinikhil](https://gromacs.bioexcel.eu/u/scinikhil)\
**Post date:** [June 28, 2024, 11:41pm UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/9 "2024-06-28T23:41:52Z")

</div>

fix the pbc with gmx trjconv and analyse the output trajectory. @Ligand1

---

<div class="post-metadata">

**Author:** ![Karis](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@Karis](https://gromacs.bioexcel.eu/u/Karis)\
**Post date:** [June 29, 2024, 3:24am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/10 "2024-06-29T03:24:14Z")

</div>

You’ll have to check the gromacs manual for the specific analysis module you’re considering to see whether a -nopbc flag is present, I only know that using gmx distance on a trajectory where pbc was removed still did not account for pbc being removed until I added a -nopbc flag to the gmx distance command, and that this might be the case for other modules where -nopbc flag is an option

---

<div class="post-metadata">

**Author:** ![Ligand1](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@Ligand1](https://gromacs.bioexcel.eu/u/Ligand1)\
**Post date:** [July 1, 2024, 10:19pm UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/11 "2024-07-01T22:19:54Z")

</div>

Hi Karis,

Thanks for replying to my comment. I went ahead and tested this myself. I am using Gromacs 2022.5. In the gmx rms module there is an option for -nopbc. My trajectory is already corrected for PBC. I used the following commands:

gmx trjconv -s md\_100.tpr -f md\_100.xtc -o md\_100\_center.xtc -center -pbc mol -ur compact  
Choose “Protein” for centering and “System” for output.

gmx trjconv -s md\_100.tpr -f md\_100\_center.xtc -o Finalcenterfir0\_100.xtc -fit rot+trans  
Choose “Backbone” to perform least-squares fitting to the protein backbone, and “System” for output.

Now I went ahead and analyzed the RMSD of the Calpha atoms of my protein by using gmx rmsd module:

First I used this command: gmx rms -s md\_100.tpr -f Finalcenterfit0\_100.xtc -o 1CArmsd.xvg -tu ns

Then I used the second command with -nopbc flag:  
gmx rms -s md\_100.tpr -f Finalcenterfit0\_100.xtc -nopbc -o 2CArmsd.xvg -tu ns

When I am looking at the two XVG files I cannot see any difference. They are exactly the same. I guess this observation might be unique to your case. Let me know what are your thoughts on this.

Best Regards

---

<div class="post-metadata">

**Author:** ![Karis](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@Karis](https://gromacs.bioexcel.eu/u/Karis)\
**Post date:** [July 2, 2024, 2:37am UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/12 "2024-07-02T02:37:49Z")

</div>

It might depend on the version of gromacs or the modules used, I’m not familiar enough with how they work to be sure. That being said, it might also be that your protein didn’t reach the sides of the box during the simulation, in which case correcting for pbc wouldn’t make a difference.

---

<div class="post-metadata">

**Author:** ![Ligand1](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@Ligand1](https://gromacs.bioexcel.eu/u/Ligand1)\
**Post date:** [July 2, 2024, 5:16pm UTC](https://gromacs.bioexcel.eu/t/pbc-flag-in-hbond-calculation-not-working/9472/13 "2024-07-02T17:16:34Z")

</div>

Yes I do have a big box. There could be other reasons too. Anyways, Thanks for the insights.

Best regards
