Upon creating the index file with gmx make_ndx
, we are usually
prompted with interactive shell.
For example:
$ gmx make_ndx -f em.gro -o index.ndx
Will give:
0 System : 120070 atoms
1 Protein : 7132 atoms
2 Protein-H : 3818 atoms
3 C-alpha : 500 atoms
4 Backbone : 1500 atoms
5 MainChain : 2001 atoms
6 MainChain+Cb : 2463 atoms
7 MainChain+H : 2472 atoms
8 SideChain : 4660 atoms
9 SideChain-H : 1817 atoms
10 Prot-Masses : 7132 atoms
11 non-Protein : 112938 atoms
12 Other : 446 atoms
13 PEP : 446 atoms
14 NA : 156 atoms
15 CL : 112 atoms
16 Water : 112224 atoms
17 SOL : 112224 atoms
18 non-Water : 7846 atoms
19 Ion : 268 atoms
20 PEP : 446 atoms
21 NA : 156 atoms
22 CL : 112 atoms
23 Water_and_ions : 112492 atoms
nr : group '!': not 'name' nr name 'splitch' nr Enter: list groups
'a': atom '&': and 'del' nr 'splitres' nr 'l': list residues
't': atom type '|': or 'keep' nr 'splitat' nr 'h': help
'r': residue 'res' nr 'chain' char
"name": group 'case': case sensitive 'q': save and quit
'ri': residue index
Then manually I have to do this:
# Choosing "1 Protein" and "13 PEP" when prompted
> 1 | 13
> q
How can I by-pass that by issuing just one command line? I tried this but failed:
$ echo "1 | 13" | gmx make_ndx -f em.gro -o index.ndx
echo -e "0 & ! a H*\n q"| gmx make_ndx -f lig.pdb -o index_lig.ndx
but this throws, syntax error. then i tired the followed one. it works fine.echo "0 & ! a H*\n q"| gmx make_ndx -f lig.pdb -o index_lig.ndx
$\endgroup$echo -e
is not POSIX compliant and so it will vary what systems will use that syntax. Most shells should allow echo to expand escape characters by default (as your working example does), as described in this comment on Linux&Unix $\endgroup$