# Structural Realignment

**URL:** <https://gromacs.bioexcel.eu/t/structural-realignment/650>\
**Category:** User discussions\
**Created:** [August 10, 2020, 8:05pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650 "2020-08-10T20:05:10Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 10, 2020, 8:05pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/1 "2020-08-10T20:05:10Z")

</div>

GROMACS version: 2020.2

Hello All,

I am looking to realign my protein after my simulation before calculating RMSD. From my understanding, I would need a tpr file along with the centered xtc file and may use a python script to carry out structural realignment. Does anyone have a script that can do this in addition to more information on this subject?

Thank you!

---

<div class="post-metadata">

**Author:** ![Neena](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@Neena](https://gromacs.bioexcel.eu/u/Neena)\
**Post date:** [August 10, 2020, 8:49pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/2 "2020-08-10T20:49:21Z")

</div>

Assuming I understood your question: gmx rms command involves two stages: first select a group for least-squares alignment (fitting) to the reference structure, then calculates rmsd.

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 10, 2020, 9:15pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/3 "2020-08-10T21:15:08Z")

</div>

Thank you. Yes, the selected group is aligned to the reference structure first (tpr), and then rmsd is calculated. My question is more so about a correction to the output xtc file to structurally align it with the reference structure before moving to gmx rms.

In the analysis section of the Lysozyme in water tutorial found here: ([http://www.mdtutorials.com/gmx/lysozyme/05\_EM.html](http://www.mdtutorials.com/gmx/lysozyme/05_EM.html)) we recenter the protein in the output xtc file in the form of a noPBC.xtc file and then we calculate the rmsd in the two steps that you have described.

But based on my current understanding, re-centered and structurally aligned are two different things. As in, if the protein were re-centered then it could still be slightly out of alignment with the reference structure which would therefore influence the rmsd. I am looking to first align the reference structure and the output structure so that they are perfectly superimposed before least-squares fitting and before calculating rmsd.

Any thoughts/advice is greatly appreciated, thank you in advance!

---

<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:** [August 11, 2020, 1:06am UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/4 "2020-08-11T01:06:57Z")

</div>

This is what `gmx trjconv -fit` is for.

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 4:19am UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/5 "2020-08-11T04:19:58Z")

</div>

I see, is there a certain selection that I have to make: none, rot+trans, rotxy+transxy, translation, transxy, progressive? Or simply include -fit in the command?

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 4:44pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/6 "2020-08-11T16:44:42Z")

</div>

I tried the follow steps to implement -fit:

1. gmx trjconv -s md\_0\_1.tpr -f md\_0\_1.xtc -o md\_0\_1\_noPBC.xtc -pbc mol -center
2. gmx trjconv -s md\_0\_1.tpr -f md\_0\_1\_noPBC.xtc -o md\_0\_1\_align.xtc -fit rot+trans
3. gmx rms -s md\_0\_1.tpr -f md\_0\_1\_align.xtc -o rmsd.xvg -tu ns

But, this gave the error:  
Molecule in topology has atom numbers below and above natoms (8748).  
You are probably trying to use a trajectory which does not match the first  
8748 atoms of the run input file. How can I use gmx convert-tpr to make an appropriate input tpr file?

---

<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:** [August 11, 2020, 5:02pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/7 "2020-08-11T17:02:51Z")

</div>

The contents of the `.tpr` have to match the trajectory. So if you only saved a subset of coordinates in the `.xtc` file, you need to have that same subset in the `.tpr` file.

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 5:07pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/8 "2020-08-11T17:07:12Z")

</div>

I see, thank you. This segment is saved from one part of my simulaiton in md\_0\_1\_align.xtc which came from md\_0\_1\_noPBC.xtc. To do so can I use the command:  
gmx convert-tpr -s md\_0\_1.tpr -f md\_0\_1\_align.xtc -o md\_0\_1\_align.tpr ?

---

<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:** [August 11, 2020, 5:19pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/9 "2020-08-11T17:19:42Z")

</div>

> [@L\_k](#):
>
> gmx convert-tpr -s md\_0\_1.tpr -f md\_0\_1\_align.xtc -o md\_0\_1\_align.tpr

No, because `convert-tpr` does not take `-f` or any coordinate/trajectory format. All you need is `-s` and `-o` and you can name the output whatever you like (doesn’t have anything to do with the coordinate manipulations in the trajectory, really).

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 5:33pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/10 "2020-08-11T17:33:19Z")

</div>

Right, thank you for the clarification. So then:  
gmx convert-tpr -s md\_0\_1.tpr -o md\_0\_1\_align.tpr

Would give me a matching run input file?

---

<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:** [August 11, 2020, 5:44pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/11 "2020-08-11T17:44:18Z")

</div>

Try it and see :)

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 6:52pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/12 "2020-08-11T18:52:01Z")

</div>

It seems that this leads to the same error, but I did select 0) system for convert-tpr

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 6:55pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/13 "2020-08-11T18:55:39Z")

</div>

I do see that I could use -nsteps to change the number of nsteps. Maybe to match the number covered in the xtc file?

---

<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:** [August 11, 2020, 7:08pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/14 "2020-08-11T19:08:05Z")

</div>

> [@L\_k](#):
>
> It seems that this leads to the same error, but I did select 0) system for convert-tpr

You need to select the group that corresponds to what is in the `.xtc` file. Your `.tpr` already has the full system. By selecting “System” again, you are accomplishing nothing.

> [@L\_k](#):
>
> I do see that I could use -nsteps to change the number of nsteps. Maybe to match the number covered in the xtc file?

This is only relevant for `mdrun` and is not related to your problem.

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 11, 2020, 8:12pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/15 "2020-08-11T20:12:21Z")

</div>

Okay, I see. Thank you for the correction. So say I am interested in the rmsd of the backbone in this particular case. I carrried out the following steps to write the rmsd.xvg file:

1. gmx trjconv -s md\_0\_1.tpr -f md\_0\_1.xtc -o md\_0\_1\_noPBC.xtc -pbc mol -center (selecting 1 - Protein and 0 - system to re-center)
2. gmx trjconv -s md\_0\_1.tpr -f md\_0\_1\_noPBC.xtc -o md\_0\_1\_align.xtc -fit rot+trans (selecting 4 - Backbone for LSQ and 4 - Backbone for output)
3. gmx convert-tpr -s md\_0\_1.tpr -o align.tpr (selecting 4 - Backbone)
4. gmx rms -s align.tpr -f md\_0\_1\_align.xtc -o rmsd.xvg -tu ns (selecting 4 - Backbone for LSQ and 4 - Backbone for output)

Which seems to have produced a reasonable plot. Did I make any error in my procedure?

---

<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:** [August 12, 2020, 12:15pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/16 "2020-08-12T12:15:28Z")

</div>

There’s nothing “wrong” but I see no reason to only select the backbone for output in your trajectory. If you adopt this convention, you have to go back and run `trjconv` every time you want to analyze something else about the protein. Stripping water is standard procedure and I recommend just saving the whole protein and fitting to whatever group you like later.

---

<div class="post-metadata">

**Author:** ![L\_k](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@L\_k](https://gromacs.bioexcel.eu/u/L_k)\
**Post date:** [August 12, 2020, 4:58pm UTC](https://gromacs.bioexcel.eu/t/structural-realignment/650/17 "2020-08-12T16:58:29Z")

</div>

Thank you so much. This has helped tremendously!
