# Issue with correcting PBC for DNA Separation in GROMACS

**URL:** <https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013>\
**Category:** User discussions\
**Tags:** pbc\
**Created:** [January 12, 2025, 5:51pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013 "2025-01-12T17:51:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatemeh](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@fatemeh](https://gromacs.bioexcel.eu/u/fatemeh)\
**Post date:** [January 12, 2025, 5:51pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/1 "2025-01-12T17:51:34Z")

</div>

GROMACS version: gromacs2024.3  
Hello,  
I am trying to correct PBC for a DNA system, but even after running the commands, I still see artifacts in the trajectory. Here’s what I did:

gmx trjconv -pbc whole -f traj.xtc -o step1.xtc -s topol.tpr (select system)  
gmx trjconv -pbc nojump -f step1.xtc -o step2.xtc -s topol.tpr (select system)  
gmx trjconv -pbc mol -center -ur compact -f step2.xtc -o final.xtc -s topol.tpr (select dna then system)

However, water molecules still appear scattered beyond the simulation box, as visible in the trajectory visualization.

Can anyone suggest how to fix the PBC issue for water molecules while maintaining a proper setup for DNA? Should I use additional options or change the sequence of commands?

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

I appreciate any help you can provide.

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [January 13, 2025, 8:04am UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/2 "2025-01-13T08:04:27Z")

</div>

I don’t see the point in using `-pbc nojump` and then `-pbc mol`. It is also risky combining `-pbc` and `-center` (or most combinations of instructions) in the same command, since it can be difficult to know in what order it is applied.

Does it work better if you do:

```auto
gmx trjconv -pbc whole -f traj.xtc -o step1.xtc -s topol.tpr
gmx trjconv -pbc mol -f step1.xtc -o step2.xtc -s topol.tpr
gmx trjconv -center -ur compact -f step2.xtc -o final.xtc -s topol.tpr

```

?

---

<div class="post-metadata">

**Author:** ![fatemeh](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@fatemeh](https://gromacs.bioexcel.eu/u/fatemeh)\
**Post date:** [January 13, 2025, 10:03pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/3 "2025-01-13T22:03:56Z")

</div>

Thank you so much for your reply. I will definitely try it.  
I used the following command for two separate DNA strands. I would like to know your point of view.  
gmx trjconv -f file.xtc -s file.tpr -pbc whole -o file\_while.xtc  
gmx trjconv -f file\_while.xtc -s file.tpr -pbc cluster -o file\_while\_cluster.xtc  
gmx trjconv -f file\_while\_cluster.xtc -f file.tpr -pbc mol -center -o file\_while\_cluster\_center.xtc

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [January 14, 2025, 7:40am UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/4 "2025-01-14T07:40:16Z")

</div>

I think that looks like a good sequence of commands. To be on the safe side, I’d recommend splitting the third:

```auto
gmx trjconv -f file_while_cluster.xtc -s file.tpr -f file.tpr -center -o file_while_cluster_center.xtc
gmx trjconv -f file_while_cluster_center.xtc -s file.tpr -pbc mol -o file_while_cluster_center_mol.xtc

```

As above, I’d also recommend always using the tpr file, if possible. Hopefully, you’ll get a suitable trajectory this way.

Also, keep in mind that most of these modifications are to get a trajectory that you think is easy to use/present visually, so the end goal may be different from case to case. For analyses, it’s usually enough to do `-pbc nojump`, if any treatment is needed at all.

---

<div class="post-metadata">

**Author:** ![fatemeh](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@fatemeh](https://gromacs.bioexcel.eu/u/fatemeh)\
**Post date:** [January 14, 2025, 6:30pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/5 "2025-01-14T18:30:54Z")

</div>

Hello,  
Thank you so much for your help. I tried to follow your command, but when I use two -f flags, I get the error: “In command-line option -f: Option specified multiple times.” Could you please clarify why we need to specify it twice? I always use -s file.tpr.

Furthermore, with `-pbc cluster`, the DNA strand usually stays within the box, and I do not encounter problems when using x3DNA for analysis. To ensure the two strands of DNA remain together, I always use `gmx distance` between two atoms in the two strands with `file.xtc` without modifications to confirm the PBC issue. Do you think using `-pbc cluster` might introduce any artificial data when performing x3DNA analysis?

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [January 14, 2025, 7:49pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/6 "2025-01-14T19:49:35Z")

</div>

Sorry, my mistake regarding the `-f` option. The .tpr file should only be specified once and with the `-s` option.

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [January 14, 2025, 7:50pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/7 "2025-01-14T19:50:11Z")

</div>

I don’t think `-pbc cluster` would cause any problems, but I can’t say for sure.

---

<div class="post-metadata">

**Author:** ![fatemeh](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@fatemeh](https://gromacs.bioexcel.eu/u/fatemeh)\
**Post date:** [January 15, 2025, 2:10pm UTC](https://gromacs.bioexcel.eu/t/issue-with-correcting-pbc-for-dna-separation-in-gromacs/11013/8 "2025-01-15T14:10:26Z")

</div>

thank you so much.  
Best regards,  
Fatemeh,
