[gmx-users] Genbox - Removal of Unwanted Waters

chris.neale at utoronto.ca chris.neale at utoronto.ca
Mon May 8 21:04:07 CEST 2006


If I have a solvated membrane and I want to extend the z dimension and add new
waters there, this is what I do. The script could be modified to get rid of new
waters in any x/y/z dimensions (around line 41 of the script).

1. run genbox on initial.gro to create solvated.gro
2. cp solvated.gro new_waters.gro
3. use vi to remove everything in new_waters.gro except the new waters (make
sure you remove waters that were in initial.gro)
4. use vi to edit keepbyz.pl
   - upperz and lowerz variables as you please
   - sol to the name of your solvent molecule
5. run keepbyz.pl on new_waters.gro 
   ./keepbyz new_waters.gro > keep_these_waters.gro
6. tail -1 initial.gro > last_line.gro
7. head -$(expr $(cat initial.gro | wc -l | awk '{print $1}') - 1 ) initial.gro
> not_last_line.gro
8. cat not_last_line.gro new_waters.gro last_line.gro > new_system.gro
9. editconf -f new_system.gro -o new_system_sequential_numbers.gro

Here is the script (make sure you chmod +x keepbyz.pl):

#!/bin/bash
# give x.gro as first command line arguement
upperz=6.417
lowerz=0.820
sol=SOL
count=0
cat $1 | grep "$sol" | while read line; do
  for first in $line; do
    break
  done
  if [ "$count" = 3 ]; then
    count=0
  fi
  count=$(expr $count + 1)
  if [ "$count" != 1 ]; then
    continue
  fi
  l=${#line}
  m=$(expr $l - 24)
  i=1
  for word in ${line:$m}; do
    if [ "$i" = 1 ]; then
      popex=$word
    else
      if [ "$i" = 2 ]; then
        popey=$word
      else
        if [ "$i" = 3 ]; then
          popez=$word
          break
        fi
      fi
    fi
    i=$(expr $i + 1)
  done
  nolx=`echo "$popez > $upperz" | bc`
  nohx=`echo "$popez < $lowerz" | bc`
  myno=$(expr $nolx + $nohx)
  if [ "$myno" != 0 ]; then
    z=${#first}
    if [ "$z" != 8 ]; then
      sfirst="[[:space:]]$first"
    else
      sfirst=$first
    fi
    `echo grep $sfirst $1`
  fi
done



More information about the gromacs.org_gmx-users mailing list