Skip to content

Instantly share code, notes, and snippets.

@vmirly
Created October 7, 2013 22:24
Show Gist options
  • Select an option

  • Save vmirly/6876041 to your computer and use it in GitHub Desktop.

Select an option

Save vmirly/6876041 to your computer and use it in GitHub Desktop.
AWK: randomly change 10% of water residues from TIP3 to TIPT
awk '
function prpdb(anum, aname, rnum, x,y,z) {
if(rnum<1000) {
printf "ATOM %5d %-3s TIPT0%4d %8.3f%8.3f%8.3f 1.00 0.00 WT00\n",anum, aname, rnum, x, y, z
}else{
printf "ATOM %5d %-3s TIPT0%5d %8.3f%8.3f%8.3f 1.00 0.00 WT00\n",anum, aname, rnum, x, y, z
}
}
BEGIN { srand() }
!/^$/ {
if($3=="OH2" && rand()<=0.1) {
prpdb($2, $3, $5, $6, $7, $8)
for(i=2; i<=3; i++) {
getline;
prpdb($2, $3, $5, $6, $7, $8)
}
}else{
print $0
}
} ' min.pdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment