1 | |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | # code for distance restraints (soft constraints) |
---|
6 | proc DisplayDistanceRestraints {} { |
---|
7 | global expcons |
---|
8 | eval destroy [winfo children $expcons(distmaster)] |
---|
9 | |
---|
10 | set leftfr $expcons(distmaster).f1 |
---|
11 | set rightfr $expcons(distmaster).f2 |
---|
12 | |
---|
13 | grid [frame $leftfr -bd 2 -relief groove] -column 0 -row 0 \ |
---|
14 | -sticky nsew |
---|
15 | grid [frame $rightfr -bd 2 -relief groove] -column 1 -row 0 \ |
---|
16 | -sticky nsew |
---|
17 | |
---|
18 | grid rowconfigure $expcons(distmaster) 0 -weight 1 |
---|
19 | grid columnconfigure $expcons(distmaster) 1 -weight 1 |
---|
20 | |
---|
21 | |
---|
22 | # Pick Phase to be Evaluated ********************************************** |
---|
23 | label $leftfr.phlabel -text Phase |
---|
24 | set ::sr_phaselist $::expmap(phaselist) |
---|
25 | eval tk_optionMenu $leftfr.phase sr_entryvar(softphase) $::sr_phaselist |
---|
26 | grid $leftfr.phlabel -column 0 -row 0 |
---|
27 | grid $leftfr.phase -column 1 -row 0 |
---|
28 | #************************************************************************** |
---|
29 | |
---|
30 | # Run Disagl Commands ***************************************************** |
---|
31 | button $leftfr.disagl -text "Refresh Disagl" |
---|
32 | grid $leftfr.disagl -column 1 -row 1 |
---|
33 | #************************************************************************** |
---|
34 | |
---|
35 | grid [label $leftfr.lweight -text "Restraint Weight"] -column 0 -row 2 -sticky sw |
---|
36 | grid [entry $leftfr.weight -width 8 -textvariable entryvar(distrestweight)] -column 1 -row 2 -sticky sw |
---|
37 | set ::entrycmd(distrestweight) "SoftConst weight" |
---|
38 | set ::entrycmd(trace) 0 |
---|
39 | set ::entryvar(distrestweight) [SoftConst weight] |
---|
40 | set ::entrycmd(trace) 1 |
---|
41 | grid [button $leftfr.edit -text "Edit Distance Restraints" -command SR_TEST] -column 0 -row 3 \ |
---|
42 | -sticky sw -columnspan 2 |
---|
43 | |
---|
44 | |
---|
45 | foreach {top main side lbl} [MakeScrollTable $rightfr] {} |
---|
46 | |
---|
47 | set atom1_state 1 |
---|
48 | set atom2_state 1 |
---|
49 | |
---|
50 | button $top.alabel1 -text "Atom 1" -width 6 -anchor center \ |
---|
51 | -command "SR_Sort atom1 $main $top.alabel1 $top.alabel2 {}" |
---|
52 | |
---|
53 | button $top.alabel2 -text "Atom 2" -width 6 -anchor center \ |
---|
54 | -command "SR_Sort atom2 $main $top.alabel1 $top.alabel2 {}" |
---|
55 | |
---|
56 | label $top.rlabel1 -text "Restraint" -width 9 -anchor center |
---|
57 | label $top.rlabel2 -text "esd" -width 9 -anchor center |
---|
58 | |
---|
59 | grid $top.alabel1 -column 1 -row 2 -padx 3 |
---|
60 | grid $top.alabel2 -column 2 -row 2 -padx 3 |
---|
61 | grid $top.rlabel1 -column 4 -row 2 |
---|
62 | grid $top.rlabel2 -column 5 -row 2 |
---|
63 | |
---|
64 | set ::sr_rb "" |
---|
65 | SR_Fill_Display $main |
---|
66 | ResizeScrollTable $rightfr |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | #package require Tk |
---|
72 | #source c:/gsas/expgui/readexp.tcl |
---|
73 | #source c:/gsas/expgui/gsascmds.tcl |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | #********************************************************************************************* |
---|
80 | #Read Disangle File and Create Bond List (sr_bond_list)************************************************************************** |
---|
81 | #********************************************************************************************* |
---|
82 | proc SR_Read_Distances {filename} { |
---|
83 | # initialiaze |
---|
84 | catch {unset ::sr_lookuplist1} |
---|
85 | catch {unset ::sr_lookuplist2} |
---|
86 | # catch {unset ::sr_restraintdist} |
---|
87 | # catch {unset ::sr_restraintesd} |
---|
88 | set ::sr_bond_list "" |
---|
89 | set ::sr_key_list "" |
---|
90 | |
---|
91 | #::sr_bond_list 0 - Phase Number |
---|
92 | # 1, 2 - Atom 1 number, Atom 2 number |
---|
93 | # 3, 4 - symmetry information |
---|
94 | # 5, 6, 7 - cell translations |
---|
95 | # 8 - bond distance |
---|
96 | # 9, 10 - atom types |
---|
97 | # 11, 12 - atom labels |
---|
98 | # 13 - bond id key |
---|
99 | |
---|
100 | |
---|
101 | # switch to run disagl here someday |
---|
102 | if {[file exists $filename]} { |
---|
103 | puts "$filename from [pwd] is opened" |
---|
104 | set fh [open $filename r] |
---|
105 | # puts $fh |
---|
106 | } else { |
---|
107 | puts "$filename not found in directory [pwd]" |
---|
108 | } |
---|
109 | # read in the file |
---|
110 | set bond_totals -1 |
---|
111 | while {[gets $fh line] >= 0} { |
---|
112 | if {[lindex $line 2] == 0} { |
---|
113 | incr bond_totals |
---|
114 | set bond_dist_array($bond_totals) $line |
---|
115 | #puts "$bond_dist_array($bond_totals)" |
---|
116 | } |
---|
117 | } |
---|
118 | #puts "there are [phaseinfo 1 natoms] atoms in the file" |
---|
119 | #puts "$bond_totals bond distances have been read from the file" |
---|
120 | close $fh |
---|
121 | |
---|
122 | #create initial parameter for implimentation of soft restraints |
---|
123 | catch (unset initsoftpar) |
---|
124 | set x 0 |
---|
125 | |
---|
126 | #set ::sr_bond_list "" |
---|
127 | while {$x < $bond_totals} { |
---|
128 | |
---|
129 | #phase number (0) |
---|
130 | set initsoftpar($x) [lindex $bond_dist_array($x) 1] |
---|
131 | |
---|
132 | #atom number 1 (1) |
---|
133 | lappend initsoftpar($x) [lindex $bond_dist_array($x) 5] |
---|
134 | |
---|
135 | #atom number 2 (2) |
---|
136 | lappend initsoftpar($x) [lindex $bond_dist_array($x) 6] |
---|
137 | |
---|
138 | #extract symmetry information (3, 4) |
---|
139 | set temp [lindex $bond_dist_array($x) 7] |
---|
140 | lappend initsoftpar($x) [expr abs($temp) % 100 * abs($temp) / $temp] |
---|
141 | lappend initsoftpar($x) [expr abs($temp)/100] |
---|
142 | |
---|
143 | #extract unit cell translations (5, 6, 7) |
---|
144 | lappend initsoftpar($x) [expr [string index [lindex $bond_dist_array($x) 8] 0] - 5] |
---|
145 | lappend initsoftpar($x) [expr [string index [lindex $bond_dist_array($x) 8] 1] - 5] |
---|
146 | lappend initsoftpar($x) [expr [string index [lindex $bond_dist_array($x) 8] 2] - 5] |
---|
147 | |
---|
148 | #create bond ID code |
---|
149 | set t2 [string map {" " ""} [set t1 $initsoftpar($x)]] |
---|
150 | |
---|
151 | set z [info exists ::sr_restraintdist($t2)] |
---|
152 | if {$z == 0} { |
---|
153 | set ::sr_restraintdist($t2) "" |
---|
154 | set ::sr_restraintesd($t2) "" |
---|
155 | } |
---|
156 | |
---|
157 | #extract bond distance |
---|
158 | lappend initsoftpar($x) [lindex $bond_dist_array($x) 3] |
---|
159 | |
---|
160 | #extract atom type and labels |
---|
161 | set num1 [lindex $bond_dist_array($x) 5] |
---|
162 | set num2 [lindex $bond_dist_array($x) 6] |
---|
163 | set type1 [atominfo 1 [lindex $bond_dist_array($x) 5] type] |
---|
164 | set type1 [lindex [split $type1 {+-}] 0] |
---|
165 | set type2 [atominfo 1 [lindex $bond_dist_array($x) 6] type] |
---|
166 | set type2 [lindex [split $type2 {+-}] 0] |
---|
167 | lappend initsoftpar($x) $type1 |
---|
168 | lappend initsoftpar($x) $type2 |
---|
169 | |
---|
170 | lappend initsoftpar($x) [atominfo 1 [lindex $bond_dist_array($x) 5] label] |
---|
171 | lappend initsoftpar($x) [atominfo 1 [lindex $bond_dist_array($x) 6] label] |
---|
172 | |
---|
173 | #puts "$initsoftpar($x)" |
---|
174 | #set atom types into array |
---|
175 | lappend ::sr_lookuplist1($type1) $x |
---|
176 | lappend ::sr_lookuplist2($type2) $x |
---|
177 | |
---|
178 | #add bond code to list element and key list |
---|
179 | lappend initsoftpar($x) $t2 |
---|
180 | lappend ::sr_key_list $t2 |
---|
181 | |
---|
182 | #create master list of bonds |
---|
183 | lappend ::sr_bond_list $initsoftpar($x) |
---|
184 | |
---|
185 | incr x |
---|
186 | } |
---|
187 | } |
---|
188 | |
---|
189 | #************************************************************************************** |
---|
190 | # Procedure to sort soft restraints --------------------------------------------- |
---|
191 | #************************************************************************************** |
---|
192 | proc SR_Sort {whichbutton main alabel1 alabel2 dlabel1} { |
---|
193 | # reset all button labels |
---|
194 | $alabel1 config -text "Atom 1" |
---|
195 | $alabel2 config -text "Atom 2" |
---|
196 | if {$dlabel1 != ""} {$dlabel1 config -text "Distance"} |
---|
197 | |
---|
198 | if {$whichbutton == "atom1"} { |
---|
199 | if {$::sr_atom1_button == 1} { |
---|
200 | set sr_prsort [lsort -integer -decreasing -index 1 $::sr_bond_list] |
---|
201 | |
---|
202 | $alabel1 config -text "Atom 1 \u2193" |
---|
203 | } else { |
---|
204 | set sr_prsort [lsort -integer -increasing -index 1 $::sr_bond_list] |
---|
205 | $alabel1 config -text "Atom 1 \u2191" |
---|
206 | } |
---|
207 | set x [expr $::sr_atom1_button * -1] |
---|
208 | set ::sr_atom1_button $x |
---|
209 | #puts $::sr_atom1_button |
---|
210 | } elseif {$whichbutton == "atom2"} { |
---|
211 | if {$::sr_atom2_button == 1} { |
---|
212 | set sr_prsort [lsort -integer -decreasing -index 2 $::sr_bond_list] |
---|
213 | $alabel2 config -text "Atom 2 \u2193" |
---|
214 | } else { |
---|
215 | set sr_prsort [lsort -integer -increasing -index 2 $::sr_bond_list] |
---|
216 | $alabel2 config -text "Atom 2 \u2191" |
---|
217 | } |
---|
218 | set x [expr $::sr_atom2_button * -1] |
---|
219 | set ::sr_atom2_button $x |
---|
220 | } else { |
---|
221 | if {$::sr_distance_button == 1} { |
---|
222 | puts "distance" |
---|
223 | set sr_prsort [lsort -increasing -index 8 $::sr_bond_list] |
---|
224 | $dlabel1 config -text "Distance \u2193" |
---|
225 | } else { |
---|
226 | set sr_prsort [lsort -decreasing -index 8 $::sr_bond_list] |
---|
227 | $dlabel1 config -text "Distance \u2191" |
---|
228 | } |
---|
229 | set x [expr $::sr_distance_button * -1] |
---|
230 | set ::sr_distance_button $x |
---|
231 | } |
---|
232 | set ::sr_bond_list $sr_prsort |
---|
233 | SR_Fill_Display $main |
---|
234 | } |
---|
235 | #********************************************************************************* |
---|
236 | #Procedure to set up soft display ************************************************ |
---|
237 | #********************************************************************************* |
---|
238 | |
---|
239 | proc SR_Display {args} { |
---|
240 | #global rprint |
---|
241 | destroy .mainrestraintbox.sr_rvaluebox |
---|
242 | set ::sr_rb .mainrestraintbox.sr_rvaluebox |
---|
243 | frame $::sr_rb |
---|
244 | pack $::sr_rb -side top -fill both -expand 1 |
---|
245 | |
---|
246 | foreach {::sr_top main side lbl} [MakeScrollTable $::sr_rb] {} |
---|
247 | set ::contraintmainbox $main |
---|
248 | |
---|
249 | button $::sr_top.alabel1 -text "Atom 1 " \ |
---|
250 | -command "SR_Sort atom1 $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1" |
---|
251 | button $::sr_top.alabel2 -text "Atom 2 " \ |
---|
252 | -command "SR_Sort atom2 $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1" |
---|
253 | button $::sr_top.dlabel1 -text "Distance " \ |
---|
254 | -command "SR_Sort distance $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1" |
---|
255 | |
---|
256 | grid $::sr_top.alabel1 -column 1 -row 2 |
---|
257 | grid $::sr_top.alabel2 -column 2 -row 2 |
---|
258 | grid $::sr_top.dlabel1 -column 3 -row 2 |
---|
259 | |
---|
260 | label $::sr_top.rlabel1 -text "Restraint" |
---|
261 | label $::sr_top.rlabel2 -text "esd" |
---|
262 | grid $::sr_top.rlabel1 -column 4 -row 2 -padx 20 |
---|
263 | grid $::sr_top.rlabel2 -column 5 -row 2 -padx 20 |
---|
264 | |
---|
265 | |
---|
266 | button $::sr_top.rcon1 -text "Check All" -width 10 -command { |
---|
267 | set ::sr_checkall 1 |
---|
268 | SR_Set_All_Check_Buttons |
---|
269 | grid forget $::sr_top.rcon1 |
---|
270 | grid $::sr_top.rcon2 -column 6 -row 2 -padx 5 |
---|
271 | } |
---|
272 | |
---|
273 | button $::sr_top.rcon2 -text "Clear All" -width 10 -command { |
---|
274 | set ::sr_checkall 0 |
---|
275 | SR_Set_All_Check_Buttons |
---|
276 | grid forget $::sr_top.rcon2 |
---|
277 | grid $::sr_top.rcon1 -column 6 -row 2 -padx 5 |
---|
278 | } |
---|
279 | |
---|
280 | grid $::sr_top.rcon1 -column 6 -row 2 -padx 5 |
---|
281 | |
---|
282 | #SR_Sort atom1 $main |
---|
283 | SR_Fill_Display $main |
---|
284 | } |
---|
285 | |
---|
286 | #***************************************************************************************** |
---|
287 | #Procedure to fill in sorted Restraint and esd data ************************************** |
---|
288 | #***************************************************************************************** |
---|
289 | proc SR_Fill_Display {main args} { |
---|
290 | eval destroy [winfo children $main] |
---|
291 | set choice $::sr_entryvar(choicenum) |
---|
292 | set atomreq1 $::sr_entryvar(softatom1) |
---|
293 | set atomreq2 $::sr_entryvar(softatom2) |
---|
294 | set phasereq $::sr_entryvar(softphase) |
---|
295 | set mode [string match "edit" $::sr_display_mode] |
---|
296 | |
---|
297 | set len [llength $::sr_bond_list] |
---|
298 | set rownum 0 |
---|
299 | for {set i 0} {$i <= $len} {incr i} { |
---|
300 | set rprint [lindex $::sr_bond_list $i] |
---|
301 | set atomid1 [lindex $rprint 9] |
---|
302 | set atomid2 [lindex $rprint 10] |
---|
303 | if {$::sr_entryvar(softphase) == [lindex $rprint 0]} { |
---|
304 | if {([lindex $rprint 8] >= $::sr_dminvalue || [lindex $rprint 8] == "?.???") && ([lindex $rprint 8] <= $::sr_dmaxvalue || [lindex $rprint 8] == "?.???")} { |
---|
305 | if {$atomreq1 == "" || $atomreq1 == "all" || $atomreq1 == $atomid1} { |
---|
306 | if {$atomreq2 == "" || $atomreq2 == "all" || $atomreq2 == $atomid2} { |
---|
307 | if {$choice == 0 || ($choice == 1 && [string trim $::sr_restraintdist([lindex $rprint 13])] != "") \ |
---|
308 | || ($choice == 2 && [string trim $::sr_restraintdist([lindex $rprint 13])] == "") } { |
---|
309 | label $main.ratom1$i -text [lindex $rprint 11] -justify center -anchor center |
---|
310 | label $main.ratom2$i -text [lindex $rprint 12] -justify center -anchor center |
---|
311 | if {$mode} { |
---|
312 | label $main.rdistance$i -text [lindex $rprint 8] -justify center -anchor center |
---|
313 | entry $main.restraint$i -width 8 -textvariable ::sr_restraintdist([lindex $rprint 13]) -takefocus 1 |
---|
314 | bind $main.restraint$i <KeyRelease> {SR_Validate_Soft %W distance} |
---|
315 | entry $main.restesd$i -width 8 -textvariable ::sr_restraintesd([lindex $rprint 13]) -takefocus 1 |
---|
316 | bind $main.restesd$i <KeyRelease> {SR_Validate_Soft %W esd} |
---|
317 | checkbutton $main.sr_crestraint$i -variable ::sr_crestraint([lindex $rprint 13]) |
---|
318 | } else { |
---|
319 | label $main.restraint$i -width 8 -textvariable ::sr_restraintdist([lindex $rprint 13]) -takefocus 1 |
---|
320 | label $main.restesd$i -width 8 -textvariable ::sr_restraintesd([lindex $rprint 13]) -takefocus 1 |
---|
321 | } |
---|
322 | incr rownum |
---|
323 | grid $main.ratom1$i -column 1 -row $rownum |
---|
324 | grid $main.ratom2$i -column 2 -row $rownum |
---|
325 | if {$mode} { |
---|
326 | grid $main.rdistance$i -column 3 -row $rownum |
---|
327 | grid $main.sr_crestraint$i -column 6 -row $rownum |
---|
328 | $main.ratom1$i conf -width 8 |
---|
329 | $main.ratom2$i conf -width 8 |
---|
330 | $main.rdistance$i conf -width 8 |
---|
331 | bind $main.restraint$i <ButtonPress> {SR_Set_Rval %W} |
---|
332 | } |
---|
333 | grid $main.restraint$i -column 4 -row $rownum |
---|
334 | grid $main.restesd$i -column 5 -row $rownum |
---|
335 | } |
---|
336 | } |
---|
337 | } |
---|
338 | } |
---|
339 | } |
---|
340 | } |
---|
341 | |
---|
342 | bind $::sr_rb <Configure> {ResizeScrollTable $::sr_rb} |
---|
343 | } |
---|
344 | #**************************************************************************** |
---|
345 | #Procedure for updating sr_rvalue and sr_resd Boxes ******************************* |
---|
346 | #**************************************************************************** |
---|
347 | proc SR_Set_Rval {window} { |
---|
348 | set ::sr_rvalue [$window get] |
---|
349 | set ::sr_resd [[regsub ".f.restraint" $window ".f.restesd"] get] |
---|
350 | } |
---|
351 | |
---|
352 | #**************************************************************************** |
---|
353 | #Error Checking Procedures for Entry Boxes ********************************** |
---|
354 | #**************************************************************************** |
---|
355 | |
---|
356 | proc SR_Validate_Num {val1} { |
---|
357 | # is it a valid number? |
---|
358 | if {[string trim $val1] != ""} { |
---|
359 | expr $val1 |
---|
360 | if {$val1 < 0} {error} |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | proc SR_Validate_Soft {win type} { |
---|
365 | set val [$win get] |
---|
366 | if {[catch { |
---|
367 | SR_Validate_Num $val |
---|
368 | }]} { |
---|
369 | # error on validation |
---|
370 | $win config -fg red |
---|
371 | $::srcb3.rbutton3 config -bg red -text "Invalid Restraints" |
---|
372 | set ::sr_error 1 |
---|
373 | } else { |
---|
374 | # valid value |
---|
375 | $win config -fg black |
---|
376 | $::srcb3.rbutton3 config -bg green -text "Save Restraints to EXP File" |
---|
377 | set ::sr_error 0 |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | #************************************************************************************** |
---|
382 | #Procedure to load current restraints, flag presetraints and build restraint only list |
---|
383 | #************************************************************************************** |
---|
384 | proc SR_Load_Restraints {args} { |
---|
385 | set temp_res [SoftConst restraintlist] |
---|
386 | set lenr [llength $temp_res] |
---|
387 | |
---|
388 | #for {set i 0} {$i < $lenr} {incr i} { |
---|
389 | # set temp_res1 [lindex $temp_res $i] |
---|
390 | #} |
---|
391 | foreach temp_res1 $temp_res { |
---|
392 | set t1 "[lindex $temp_res1 0] [lindex $temp_res1 1] [lindex $temp_res1 2] \ |
---|
393 | [lindex $temp_res1 3] [lindex $temp_res1 4] [lindex $temp_res1 5] \ |
---|
394 | [lindex $temp_res1 6] [lindex $temp_res1 7]" |
---|
395 | set t2 [string map {" " ""} $t1] |
---|
396 | |
---|
397 | set test [lsearch -exact $::sr_key_list $t2] |
---|
398 | |
---|
399 | if {$test == -1} { |
---|
400 | set new_restraint "" |
---|
401 | set type1 [atominfo 1 [lindex $temp_res1 1] type] |
---|
402 | set type1 [lindex [split $type1 {+-}] 0] |
---|
403 | set type2 [atominfo 1 [lindex $temp_res1 2] type] |
---|
404 | set type2 [lindex [split $type2 {+-}] 0] |
---|
405 | |
---|
406 | lappend new_restraint [lindex $temp_res1 0] [lindex $temp_res1 1] \ |
---|
407 | [lindex $temp_res1 2] [lindex $temp_res1 3] [lindex $temp_res1 4] \ |
---|
408 | [lindex $temp_res1 5] [lindex $temp_res1 6] [lindex $temp_res1 7] \ |
---|
409 | "?.???" $type1 $type2 \ |
---|
410 | [atominfo 1 [lindex $temp_res1 1] label] [atominfo 1 [lindex $temp_res1 2] label] \ |
---|
411 | $t2 |
---|
412 | set x [llength $::sr_bond_list] |
---|
413 | lappend ::sr_lookuplist1($type1) $x |
---|
414 | lappend ::sr_lookuplist2($type2) $x |
---|
415 | lappend ::sr_bond_list $new_restraint |
---|
416 | } |
---|
417 | set ::sr_restraintdist($t2) [lindex $temp_res1 8] |
---|
418 | set ::sr_restraintesd($t2) [lindex $temp_res1 9] |
---|
419 | |
---|
420 | |
---|
421 | |
---|
422 | # if $t2 not in ::sr_bond_list need to add to sr_bond_list and ::sr_lookuplist1/2 |
---|
423 | } |
---|
424 | } |
---|
425 | |
---|
426 | |
---|
427 | #************************************************************************* |
---|
428 | #write soft restraints to file ******************************************* |
---|
429 | #************************************************************************* |
---|
430 | proc SR_Write_Restraints { } { |
---|
431 | if {$::sr_error == 0} { |
---|
432 | set sr_write "" |
---|
433 | set new_list "" |
---|
434 | set len [llength $::sr_bond_list] |
---|
435 | set ::sr_key_list "" |
---|
436 | for {set i 0} {$i <= [expr $len-1]} {incr i} { |
---|
437 | set temp [lindex $::sr_bond_list $i] |
---|
438 | if {[string trim $::sr_restraintdist([lindex $temp 13])] != ""} { |
---|
439 | set softrest "[lindex $temp 0] [lindex $temp 1] \ |
---|
440 | [lindex $temp 2] [lindex $temp 3] [lindex $temp 4] \ |
---|
441 | [lindex $temp 5] [lindex $temp 6] [lindex $temp 7]\ |
---|
442 | $::sr_restraintdist([lindex $temp 13])\ |
---|
443 | $::sr_restraintesd([lindex $temp 13])" |
---|
444 | lappend sr_write $softrest |
---|
445 | lappend new_list $temp |
---|
446 | |
---|
447 | } else { |
---|
448 | unset ::sr_restraintdist([lindex $temp 13]) |
---|
449 | unset ::sr_restraintesd([lindex $temp 13]) |
---|
450 | } |
---|
451 | } |
---|
452 | puts $sr_write |
---|
453 | # put the entire restraint list back into the .EXP file |
---|
454 | SoftConst restraintlist set $sr_write |
---|
455 | set ::sr_bond_list $new_list |
---|
456 | # indicate a change to the .EXP file |
---|
457 | incr ::expgui(changed) |
---|
458 | # close the window and return access to main window |
---|
459 | destroy .mainrestraintbox |
---|
460 | set ::sr_display_mode noedit |
---|
461 | afterputontop |
---|
462 | DisplayDistanceRestraints |
---|
463 | } else { |
---|
464 | bell |
---|
465 | #puts "invalid restaint / esd. Save aborted" |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | #********************************************************************************* |
---|
470 | #Procedure to update restraints ************************************************* |
---|
471 | #********************************************************************************* |
---|
472 | |
---|
473 | proc SR_Update_Restraints {args} { |
---|
474 | foreach i [array names ::sr_crestraint] { |
---|
475 | if {$::sr_crestraint($i) == 1} { |
---|
476 | #puts "::sr_restraintdist($i) $::sr_rvalue" |
---|
477 | set ::sr_restraintdist($i) $::sr_rvalue |
---|
478 | set ::sr_restraintesd($i) $::sr_resd |
---|
479 | } |
---|
480 | } |
---|
481 | } |
---|
482 | |
---|
483 | #******************************************************************************* |
---|
484 | #Procedure to delete restraints ************************************************ |
---|
485 | #******************************************************************************* |
---|
486 | |
---|
487 | proc SR_Delete_Restraints {args} { |
---|
488 | foreach i [array names ::sr_crestraint] { |
---|
489 | if {$::sr_crestraint($i) == 1} { |
---|
490 | set ::sr_restraintdist($i) "" |
---|
491 | set ::sr_restraintesd($i) "" |
---|
492 | } |
---|
493 | } |
---|
494 | } |
---|
495 | |
---|
496 | #********************************************************************************* |
---|
497 | #set flag for restraint update *************************************************** |
---|
498 | #********************************************************************************* |
---|
499 | proc SR_Set_All_Check_Buttons { } { |
---|
500 | # loop over all widgets in main frame |
---|
501 | foreach w [winfo children $::contraintmainbox] { |
---|
502 | # pick out checkboxes which have crest |
---|
503 | if {[string first crest $w] != -1} { |
---|
504 | $w deselect |
---|
505 | if {$::sr_checkall} { |
---|
506 | $w invoke |
---|
507 | } |
---|
508 | } |
---|
509 | } |
---|
510 | } |
---|
511 | |
---|
512 | #********************************************************************************* |
---|
513 | #Main Program Begin*************************************************************** |
---|
514 | #********************************************************************************* |
---|
515 | proc SR_Main_Editor {args} { |
---|
516 | |
---|
517 | catch {destroy .mainrestraintbox} |
---|
518 | set mrb .mainrestraintbox |
---|
519 | toplevel $mrb |
---|
520 | #pack $mrb -side top |
---|
521 | wm title $mrb "Soft Restraint Control Panel" |
---|
522 | #wm geometry $mrb 415x500+10+10 |
---|
523 | #wm geometry $mrb {} |
---|
524 | set srcb1 $mrb.srconbox1 |
---|
525 | set srcb2 $mrb.srconbox2 |
---|
526 | set ::srcb3 $mrb.srconbox3 |
---|
527 | frame $srcb1 -bd 2 -relief groove -pady 5 |
---|
528 | frame $srcb2 -bd 2 -relief groove -pady 5 |
---|
529 | frame $::srcb3 -bd 2 -relief groove -pady 5 |
---|
530 | pack $srcb1 -side top -anchor w -fill x |
---|
531 | pack $srcb2 -side top -anchor w -fill x |
---|
532 | pack $::srcb3 -side bottom -anchor w -fill x |
---|
533 | |
---|
534 | label $srcb1.atomlabel1 -text "Atom 1 Filter" |
---|
535 | label $srcb1.atomlabel2 -text "Atom 2 Filter" |
---|
536 | label $srcb1.dminlabel -text "Dmin" |
---|
537 | label $srcb1.dmaxlabel -text "Dmax" |
---|
538 | label $srcb2.restlabel -text "Restraint Value" -width 16 -anchor w |
---|
539 | label $srcb2.restlabelesd -text "esd" |
---|
540 | eval tk_optionMenu $srcb1.atom1 ::sr_entryvar(softatom1) "[lsort [array names ::sr_lookuplist1]] all" |
---|
541 | eval tk_optionMenu $srcb1.atom2 ::sr_entryvar(softatom2) "[lsort [array names ::sr_lookuplist2]] all" |
---|
542 | |
---|
543 | |
---|
544 | entry $srcb1.sr_dminvalue -width 8 -textvariable ::sr_dminvalue -takefocus 1 |
---|
545 | entry $srcb1.sr_dmaxvalue -width 8 -textvariable ::sr_dmaxvalue -takefocus 1 |
---|
546 | entry $srcb2.sr_rvalue -width 8 -textvariable ::sr_rvalue -takefocus 1 |
---|
547 | entry $srcb2.sr_resd -width 8 -textvariable ::sr_resd -takefocus 1 |
---|
548 | |
---|
549 | bind $srcb1.sr_dminvalue <KeyRelease> {SR_Validate_Soft %W dmin} |
---|
550 | bind $srcb1.sr_dmaxvalue <KeyRelease> {SR_Validate_Soft %W dmax} |
---|
551 | bind $srcb2.sr_rvalue <KeyRelease> {SR_Validate_Soft %W sr_rvalue} |
---|
552 | bind $srcb2.sr_resd <KeyRelease> {SR_Validate_Soft %W sr_resd} |
---|
553 | |
---|
554 | button $srcb1.recalc -text "Filter" -bd 6 -command {SR_Display} |
---|
555 | button $srcb2.rbutton1 -text "check update" -command {SR_Update_Restraints} |
---|
556 | button $srcb2.rbutton2 -text "check remove" -command {SR_Delete_Restraints} |
---|
557 | button $::srcb3.rbutton3 -text "Save Restraints to EXP File" -bd 6 -bg green -command {SR_Write_Restraints} |
---|
558 | button $::srcb3.rbutton4 -text "Cancel" -command {destroy .mainrestraintbox |
---|
559 | afterputontop |
---|
560 | SR_Rest_Only |
---|
561 | DisplayDistanceRestraints} |
---|
562 | wm protocol .mainrestraintbox WM_DELETE_WINDOW {destroy .mainrestraintbox |
---|
563 | afterputontop |
---|
564 | SR_Rest_Only |
---|
565 | DisplayDistanceRestraints} |
---|
566 | |
---|
567 | grid $srcb1.atomlabel1 -column 1 -row 0 |
---|
568 | grid $srcb1.atom1 -column 2 -row 0 |
---|
569 | $srcb1.atom1 conf -width 2 |
---|
570 | grid $srcb1.atomlabel2 -column 1 -row 1 |
---|
571 | grid $srcb1.atom2 -column 2 -row 1 |
---|
572 | $srcb1.atom2 conf -width 2 |
---|
573 | grid $srcb1.recalc -column 4 -row 2 -padx 5 |
---|
574 | $srcb1.recalc conf -width 7 |
---|
575 | |
---|
576 | grid $srcb1.dminlabel -column 3 -row 0 |
---|
577 | grid $srcb1.sr_dminvalue -column 4 -row 0 |
---|
578 | grid $srcb1.dmaxlabel -column 3 -row 1 |
---|
579 | grid $srcb1.sr_dmaxvalue -column 4 -row 1 |
---|
580 | |
---|
581 | |
---|
582 | set choice {"Show All Bonds" "Restrained Bonds" "Unrestrained Bonds"} |
---|
583 | set ::sr_entryvar(choice) "Show All Bonds" |
---|
584 | |
---|
585 | set m1 [eval tk_optionMenu $srcb1.rcon3 sr_entryvar(choice) $choice] |
---|
586 | # set up a variable to track menu choices by number. Do this by adding a command |
---|
587 | # to each item in the option menu |
---|
588 | foreach i {0 1 2} { |
---|
589 | $m1 entryconfig $i -command "set ::sr_entryvar(choicenum) $i" |
---|
590 | } |
---|
591 | grid $srcb1.rcon3 -column 1 -row 2 -padx 5 |
---|
592 | $srcb1.rcon3 config -width 23 |
---|
593 | grid configure $srcb1.rcon3 -columnspan 2 |
---|
594 | |
---|
595 | grid $srcb2.restlabel -column 0 -row 3 -sticky w |
---|
596 | grid $srcb2.sr_rvalue -column 1 -row 3 |
---|
597 | grid $srcb2.restlabelesd -column 2 -row 3 |
---|
598 | grid $srcb2.sr_resd -column 3 -row 3 |
---|
599 | grid $srcb2.rbutton1 -column 4 -row 3 -padx 5 |
---|
600 | grid $srcb2.rbutton2 -column 5 -row 3 -padx 5 |
---|
601 | |
---|
602 | grid $::srcb3.rbutton3 -column 0 -row 0 |
---|
603 | grid $::srcb3.rbutton4 -column 0 -row 1 -pady 5 |
---|
604 | |
---|
605 | |
---|
606 | |
---|
607 | SR_Display |
---|
608 | |
---|
609 | foreach item [trace vinfo ::sr_entryvar(softatom1)] { |
---|
610 | eval trace vdelete ::sr_entryvar(softatom1) $item |
---|
611 | } |
---|
612 | trace variable ::sr_entryvar(softatom1) w SR_Display |
---|
613 | |
---|
614 | foreach item [trace vinfo ::sr_entryvar(softatom2)] { |
---|
615 | eval trace vdelete ::sr_entryvar(softatom2) $item |
---|
616 | } |
---|
617 | trace variable ::sr_entryvar(softatom2) w SR_Display |
---|
618 | |
---|
619 | foreach item [trace vinfo ::sr_entryvar(choicenum)] { |
---|
620 | eval trace vdelete ::sr_entryvar(choicenum) $item |
---|
621 | } |
---|
622 | trace variable ::sr_entryvar(choicenum) w SR_Display |
---|
623 | |
---|
624 | foreach item [trace vinfo ::sr_entryvar(softphase)] { |
---|
625 | eval trace vdelete ::sr_entryvar(softphase) $item |
---|
626 | } |
---|
627 | #trace variable ::sr_entryvar(softphase) w SR_Display |
---|
628 | putontop $mrb |
---|
629 | |
---|
630 | #list of global variables and procedures |
---|
631 | |
---|
632 | #::sr_lookuplist1 |
---|
633 | #::sr_lookuplist2 |
---|
634 | #::sr_rb |
---|
635 | #::sr_top |
---|
636 | #::sr_checkall |
---|
637 | #::sr_entryvar(choicenum) |
---|
638 | #::sr_entryvar(softatom1) |
---|
639 | #::sr_entryvar(softatom2) |
---|
640 | #::sr_entryvar(softphase) |
---|
641 | #::sr_dminvalue |
---|
642 | #::sr_dmaxvalue |
---|
643 | #::sr_restraintdist |
---|
644 | #::sr_restraintesd |
---|
645 | #::sr_rvalue |
---|
646 | #::sr_resd |
---|
647 | #::srcb4.rbutton3 |
---|
648 | #::sr_crestraint |
---|
649 | #::sr_phaselist |
---|
650 | #::sr_bond_list |
---|
651 | |
---|
652 | #SR_Read_Distances |
---|
653 | #SR_Make_ScrollTable |
---|
654 | #SR_Resize_Scroll_Table |
---|
655 | #SR_Display |
---|
656 | #SR_Set_Rval |
---|
657 | #SR_Validate_Num |
---|
658 | #SR_Load_Restraints |
---|
659 | #SR_Write_Restraints |
---|
660 | #SR_Update_Restraints |
---|
661 | #SR_Delete_Restraints |
---|
662 | #SR_Set_All_Check_Buttons |
---|
663 | #SR_Build |
---|
664 | |
---|
665 | } |
---|
666 | #************************************************************************ |
---|
667 | #Procedure to Initialize variables *************************************** |
---|
668 | #************************************************************************* |
---|
669 | proc SR_Initialize {} { |
---|
670 | catch {unset ::sr_restraintdist} |
---|
671 | catch {unset ::sr_restraintesd} |
---|
672 | |
---|
673 | set ::sr_atom1_button 1 |
---|
674 | set ::sr_atom2_button 1 |
---|
675 | set ::sr_distance_button 1 |
---|
676 | set ::sr_entryvar(choicenum) 0 |
---|
677 | set ::sr_entryvar(softphase) "1" |
---|
678 | set ::sr_entryvar(softatom1) "all" |
---|
679 | set ::sr_entryvar(softatom2) "all" |
---|
680 | set ::sr_phaselist $::expmap(phaselist) |
---|
681 | set ::sr_error 0 |
---|
682 | set ::sr_bond_list "" |
---|
683 | set ::sr_dminvalue 0 |
---|
684 | set ::sr_dmaxvalue 1000 |
---|
685 | SR_Rest_Only |
---|
686 | } |
---|
687 | |
---|
688 | proc SR_Rest_Only {} { |
---|
689 | set ::sr_display_mode noedit |
---|
690 | catch {unset ::sr_lookuplist1} |
---|
691 | catch {unset ::sr_lookuplist2} |
---|
692 | # catch {unset ::sr_restraintdist} |
---|
693 | # catch {unset ::sr_restraintesd} |
---|
694 | set ::sr_bond_list "" |
---|
695 | set ::sr_key_list "" |
---|
696 | SR_Load_Restraints |
---|
697 | } |
---|
698 | |
---|
699 | |
---|
700 | |
---|
701 | #expload TEST3.EXP |
---|
702 | #mapexp |
---|
703 | SR_Initialize |
---|
704 | #SR_Read_Distances test2.disagl |
---|
705 | #SR_Load_Restraints |
---|
706 | #SR_Main_Editor |
---|
707 | #SR_Load_Restraints |
---|
708 | |
---|
709 | |
---|
710 | |
---|
711 | |
---|
712 | proc SR_TEST {} { |
---|
713 | set ::sr_display_mode edit |
---|
714 | SR_Read_Distances test2.disagl |
---|
715 | SR_Load_Restraints |
---|
716 | SR_Main_Editor |
---|
717 | } |
---|
718 | |
---|
719 | |
---|
720 | |
---|
721 | |
---|
722 | |
---|
723 | |
---|
724 | |
---|
725 | |
---|
726 | |
---|
727 | |
---|
728 | |
---|