[gmx-users] Automation of selecting water around a molecule
Mark Abraham
Mark.Abraham at anu.edu.au
Wed May 2 15:18:28 CEST 2012
On 2/05/2012 7:49 PM, Lara Bunte wrote:
> Hi
>
> I need a little help in using Linux. I wrote this script for the bash, that I called g_select_script.sh:
>
>
> #!/bin/bash
> g_select -s mol_in_water.pdb -select '"Close to ISO" resname SOL and within 0.4 of resname ISO' -on
> make_ndx -f mol_in_water.pdb -o index2.ndx
> cat index2.ndx index.ndx> index3.ndx
> make_ndx -f mol_in_water.pdb -n index3.ndx -o index_final.ndx
> trjconv -n index_final.ndx -f mol_in_water.pdb -s mol_in_water.pdb -o output.pdb
>
>
> After this I make a file called parameters_for_g_select_script, that looks like:
>
> 2
> q
> 2|7
> q
> 8
>
> And finally I type in the bash this command:
>
>
> ./g_select_script.sh< parameters_for_g_select_script
>
> Sadly this does not work. It works correct until make_ndx -f mol_in_water.pdb -n index3.ndx -o index_final.ndx with parameters 2|7 and q
>
> The numbers of the groups are correct. I guess, that 2|7 is not transfered correctly. I tried '2|7' and "2|7" that also do not work.
>
>
> What is wrong in my automation? Please help a Linux noob like me.
Not sure, but maybe the shell redirection of the file to stdin
interprets the pipe symbol as it would on the command line. If so,
"escaping" it as 2\|7 may work. Or as Teemu suggests, g_select is a more
expressive tool once you wrap your brain around it. You should be able
to get away with a 2-line script needing no redirection in most (all?)
cases.
A further clue - groups can be identified by name in GROMACS, so you can
make your scripting more meaningful and resilient to change by referring
to groups by name rather than number. Next month, you'll have no idea
what 2, 7 and 8 are, but their names you'll still understand, hopefully!
Mark
More information about the gromacs.org_gmx-users
mailing list