package require psfgen package require pbctools set topol "DNA_WAT.top" set output "water_3.5A.dat" set OUT [open $output "w"] set j 0 set f [open "crd.in" ] while {[gets $f line] } { mol load parm7 $topol mol addfile $line type crdbox waitfor all set framnr [molinfo top get numframes] puts "$framnr" molinfo top set a 66 molinfo top set b 67 molinfo top set c 63 set sel1 "all" set sel2 "nucleic" pbc unwrap -sel $sel2 -all pbc wrap -sel $sel1 -center $sel2 -all set sel3 "nucleic and (resid 291 to 298 303 to 310 and (name N3 N7 O6 O2 04 O1P O2P))" set cutoff 3.5 set all [atomselect top "all"] for {set frame 0} {$frame <= $framnr-1} {incr frame} { animate goto $frame display update set j [expr $j + 1] set moleculebin [atomselect top "(water and name O) and within $cutoff of ($sel3)"] set check [lsort -unique [$moleculebin get resid]] set i 0 foreach resid $check { set i [expr $i + 1] } puts $OUT "$j $i" } mol delete 0 } close $f