From: Claw Isthelaw (clawisthelaw_at_hotmail.com)
Date: Mon Jun 02 2008 - 13:25:51 CDT

Hi all, I just wanted to throw this into the mailing list to follow up on a post I made a while back, in case anyone needs to do this. There was an error in the last solution to this. These scripts write out a new PDB containing the protein and the N-closest waters to a specified selection (usually part of the protein). The first script finds the N-closest waters based only on the water oxygens, while for the second, it can be any of the water atoms. The two methods may result in slightly different water selections.

proc nwat {n sel} {
  set lists [measure contacts 8 [atomselect top "water and name OH2"] $sel]
  set wlist [lindex $lists 0]
  set slist [lindex $lists 1]
  foreach satom $slist watom $wlist {
    set wresnum [[atomselect top "index $watom"] get resid]
    set d [measure bond "$watom $satom"]
    lappend l1 [list $wresnum $d]
  }
  set l2 [lrange [lsort -index 1 [lsort -unique -index 0 [lsort -index 1 -decreasing $l1]]] 0 [expr $n - 1]]
  foreach water $l2 {
    lappend l3 "[lindex $water 0]"
  }
  [atomselect top "protein or (water and resid $l3)"] writepdb new.pdb
}

proc nwat2 {n sel} {
  set lists [measure contacts 8 [atomselect top "water"] $sel]
  set wlist [lindex $lists 0]
  set slist [lindex $lists 1]
  foreach satom $slist watom $wlist {
    set wresnum [[atomselect top "index $watom"] get resid]
    set d [measure bond "$watom $satom"]
    lappend l1 [list $wresnum $d]
  }
  set l2 [lrange [lsort -index 1 [lsort -unique -index 0 [lsort -index 1 -decreasing $l1]]] 0 [expr $n - 1]]
  foreach water $l2 {
    lappend l3 "[lindex $water 0]"
  }
  [atomselect top "protein or (water and resid $l3)"] writepdb new.pdb
}

Jeff Tibbitt

_________________________________________________________________
Give to a good cause with every e-mail. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?souce=EML_WL_ GoodCause