set outfile [open contacts.dat w] set numframes [molinfo top get numframes] for {set i 0} {$i < $numframes} {incr i} { set mysel [atomselect top "resname DMP and name P OA OB OC OD and within 3.5 of protein" frame $i] set atomlist [$mysel get index] puts "list of atoms within 3 of protein:" puts "$atomlist" foreach res $atomlist { set rsel [atomselect top "index $res" frame $i] set com [measure center $rsel weight [$rsel get mass]] puts $outfile "$i Res: $res COM: $com" $rsel delete } }