Running genion non-interactively. No dialogues

GROMACS version: 2024.2
GROMACS modification: No

Hello community.

How to run genion non-interactively at the command line?

For example, I can specify positive and negative ions as in this example:

gmx genion -s ions.tpr -o solv_ions.pdb -p topol.top -pname NA -nname CL -neutral -conc 0.1

However, genion executed as shown above will open a dialogue where the user may choose SOL like this:

Select a continuous group of solvent molecules
Group     0 (         System) has 34553 elements
Group     1 (        Protein) has  1130 elements
Group     2 (      Protein-H) has   920 elements
Group     3 (        C-alpha) has   135 elements
Group     4 (       Backbone) has   400 elements
Group     5 (      MainChain) has   540 elements
Group     6 (   MainChain+Cb) has   645 elements
Group     7 (    MainChain+H) has   670 elements
Group     8 (      SideChain) has   460 elements
Group     9 (    SideChain-H) has   380 elements
Group    10 (    Prot-Masses) has  1130 elements
Group    11 (    non-Protein) has 33423 elements
Group    12 (          Water) has 33423 elements
Group    13 (            SOL) has 33423 elements
Group    14 (      non-Water) has  1130 elements
Select a group: 13
Selected 13: 'SOL'

In short:
How can the user specify SOL at the command line without a dialogue?

Thank you.

Ivan Gregoretti

If you know that the group SOL is at position 13, then just echoing the command

echo "13" | gmx genion -s ions.tpr -o solv_ions.pdb -p topol.top -pname NA -nname CL -neutral -conc 0.1

should work!

Hi obZehn.

First, thanks for a replying to my question.

I am trying to come up with a general computational protocol. SOL will be common to all cases I have in mind but position 13 will not be guaranteed. That is the reason I inquired about selecting SOL and no mention of the position.

So, the question still stands:
How can the user specify SOL at the command line without a dialogue?
(Regardless of position in the dialogue.)

Thank you.

Ivan

You can use

echo “SOL” |

1 Like

Such a simple solution!

I haven’t tested it so I can’t yet confirm success.

However, I can contribute a little solution to the community that has strong similarities:

When running energy like this

gmx energy -f em.edr -o potential.xvg

GROMACS opens a dialogue that looks something like this

Select the terms you want from the following list by
selecting either (part of) the name or the number or a combination.
End your selection with an empty line or a zero.
-------------------------------------------------------------------
  1  G96Bond          2  G96Angle         3  Proper-Dih.      4  Improper-Dih. 
  5  LJ-14            6  Coulomb-14       7  LJ-(SR)          8  Coulomb-(SR)  
  9  Coul.-recip.    10  Potential       11  Pressure        12  Vir-XX        
 13  Vir-XY          14  Vir-XZ          15  Vir-YX          16  Vir-YY        
 17  Vir-YZ          18  Vir-ZX          19  Vir-ZY          20  Vir-ZZ        
 21  Pres-XX         22  Pres-XY         23  Pres-XZ         24  Pres-YX       
 25  Pres-YY         26  Pres-YZ         27  Pres-ZX         28  Pres-ZY       
 29  Pres-ZZ         30  #Surf*SurfTen   31  T-rest

To select Potential energy interactively with that dialogue the user must type “10 0”.

Thanks to abZehn and scinikhil I learned today that the same result can be obtained non-interactively with

echo "Potential" | gmx energy -f em.edr -o potential.xvg

Notice that the load of the echo command is just “Potential”, not “Potential 0”.

Thank you all.

Ivan

1 Like