Link groups with make_ndx

I have generated a large number of groups through the gmx select command, now I need to link all these groups into one. Somebody can help me? Thanks!

Use -on to output the selections to an index file:
gmx select -on index_output.ndx

Then you can combine them using make_ndx with the | (or) function:
gmx make_ndx -n index_output.ndx -o index_combined.ndx

Thank you…but i have more than 12000 groups. Or is not usefull in this case.

With this many groups, I suggest trying to find a way to make fewer groups; there has to be a way to express your selections more generally so you don’t have to deal with so many.

Thanks! We solved this problem. mm

Could you please share what your solution was? That is the purpose of this forum. Other users may find it useful in the future to know what you did.

A collaborator wrote a code that links all groups into one. I ´ll ask him to share the program, MM

Here we share the script to link several groups avoiding redundance:

MergeGroups script

This script reads a ‘ndx’ file (INPUT) from GROMACS containing many groups of atoms,

and writes-out a single merged file (OUTPUT) with non-redundant atom numbers.

To run: 1) modify in lines 1 and 2 INPUT & OUTPUT names;

2) modify in line 3 the text in the OUTPUT header: [ group of …];

3) execute this script from the command line.

Diego Guerin; June 2020

export INPUT=IndexMut17_wat4ALYR.ndx
export OUTPUT=IndexMut17_wat4ALYR_mrg.ndx
echo [ group of TIP3 that reach a 4A distance from LYR] > $OUTPUT
awk ’ BEGIN {imin=1; imax=500000}
{for (i=1; i<16; i++) A[$i]=$i}
END { for (j=imin; j<imax+1; j++) {
if (A[j] > 0)
{k=k+1; if (k<15) printf " %5d", A[j]
else {printf " %5d\n", A[j]; k=0}