1 # ====================================================================== 2 # demo.tcl -- 3 # 4 # CCP4Interface 5 # 6 # ======================================================================= 7 8 # procedure which is run automatically before drawing the interface 9 # used to set up variables, menus etc 10 #--------------------------------------------------------------------- 11 proc demo3_setup { typedefVar arrayname } { 12 #--------------------------------------------------------------------- 13 upvar #0 $typedefVar typedef 14 upvar #0 $arrayname array 15 16 # Define the 'refinement type' and 'input phase' menus 17 18 DefineMenu _demo_refine_type [list "full refinement" \ 19 "quick refinement" ] \ 20 [ list FULL \ 21 FAST ] 22 23 set typedef(_demo_restrain_mode) [list varmenu RESTRAINT_MENU RESTRAINT_ALIAS 10] 24 25 DefineMenu _demo_input_phase [list "input phases" \ 26 "no phase input" ] \ 27 [list PHASE \ 28 NO ] 29 30 # procedure must return sucess code (1) for drawing task window to continue 31 return 1 32 } 33 34 #--------------------------------------------------------------------- 35 proc demo3_run { arrayname } { 36 #--------------------------------------------------------------------- 37 # this procedure is run when user clicks the 'Run' button 38 # used to check user input and where necessary convert parameters 39 # to form required by the program run script 40 41 upvar #0 $arrayname array 42 43 #The labin depends on the INPUT_PHASE mode selected by the user 44 #Get the 'alias' for the currently selected value of INPUT_PHASE 45 # and if it matchs "PHASE" then include the phase labels in the labin 46 47 if [regexp PHASE [GetValue $arrayname INPUT_PHASE]] { 48 set array(LABIN) "FP SIGFP PHIB FOMB" 49 } else { 50 set array(LABIN) "FP SIGFP" 51 } 52 53 # procedure must return sucess code (1) for running job to continue 54 return 1 55 } 56 57 #----------------------------------------------------------------------- 58 proc demo3_set_range { arrayname } { 59 #----------------------------------------------------------------------- 60 upvar #0 $arrayname array 61 62 # Get the full path name of the PDB file 63 set pdb_filename [GetFullFileName0 $arrayname XYZIN] 64 65 # 'Zero' the variables containing name of chain & res ids in PDB 66 set array(PDB_CHAINS) {} 67 set array(PDB_RES_RANGE) {} 68 69 # Make sure PdbGetChains procedure is accessible 70 source [SearchPath TOP utils pdb_utils.tcl] 71 72 # Call PdbGetChains to get chain names and first/last res ids from PDB 73 # Quit here if this procedure fails 74 if { ![PdbGetChains $pdb_filename \ 75 array(PDB_CHAINS) array(PDB_RES_RANGE) ] } { return } 76 77 # Diagnostic - are we getting the right info back? 78 puts "PDB_CHAINS $array(PDB_CHAINS)" 79 puts "PDB_RES_RANGE $array(PDB_RES_RANGE)" 80 81 # Set the array variables for CHAIN FIRST_RES and LAST_RES 82 set n 0 83 foreach chain $array(PDB_CHAINS) res_range $array(PDB_RES_RANGE) { 84 incr n 85 set array(CHAIN,$n) $chain 86 set array(FIRST_RES,$n) [lindex $res_range 0] 87 set array(LAST_RES,$n) [lindex $res_range 1] 88 } 89 90 # Force the redrawing of extending frames 91 UpdateExtendingFrame demo3_refine_range 0 $arrayname [expr $n - $array(NRANGES) ] 92 93 } 94 95 96 #--------------------------------------------------------------------- 97 proc demo3_refine_range { arrayname counter } { 98 #--------------------------------------------------------------------- 99 #procedure to draw one line of the 'refinement range' extending frame 100 upvar #0 $arrayname array 101 102 CreateLine line \ 103 message "Enter range of residues to refine" \ 104 label "Use" \ 105 widget RESTRAIN_MODE \ 106 label "restraints for chain" \ 107 widget CHAIN \ 108 label "from residue" \ 109 widget FIRST_RES \ 110 label "to residue" \ 111 widget LAST_RES 112 113 } 114 115 #--------------------------------------------------------------------- 116 proc demo3_restraint_modes { arrayname counter } { 117 #--------------------------------------------------------------------- 118 #procedure defining one line of the restaints definition extending frames 119 upvar #0 $arrayname array 120 121 # If there is no name already set for the restraint name then provide one 122 if { $array(RESTRAINT_NAME,$counter) == "" } { 123 set array(RESTRAINT_NAME,$counter) "restraint_$counter" } 124 125 CreateLine line \ 126 message "Enter a name for the restraint mode" \ 127 label "Restraint mode" \ 128 widget RESTRAINT_NAME -command "demo3_update_restraints_menu $arrayname" \ 129 label "has bond restraint weight" \ 130 widget BOND_RESTRAINT \ 131 label "and angle restraint weight" \ 132 widget ANGLE_RESTRAINT 133 134 demo3_update_restraints_menu $arrayname 135 136 } 137 138 #--------------------------------------------------------------------- 139 proc demo3_update_restraints_menu { arrayname } { 140 #--------------------------------------------------------------------- 141 # Update the variable menu RESTRAINT_MENU 142 upvar #0 $arrayname array 143 144 # Initialise the list which will contain all of the items to appear on the menu 145 set restraint_list {} 146 147 # Add each of the restraints names RESTRAINT_NAME to the list 148 for { set n 1 } { $n <= $array(NRESTRAINTMODES) } { incr n } { 149 lappend restraint_list $array(RESTRAINT_NAME,$n) 150 } 151 152 # Update the menu - this will automatically update everywhere that the menu 153 # is displayed in the task interface 154 UpdateVariableMenu $arrayname initialise 0 RESTRAINT_MENU $restraint_list \ 155 RESTRAINT_ALIAS $restraint_list 156 157 } 158 159 160 # procedure to draw task window 161 #--------------------------------------------------------------------- 162 proc demo3_task_window { arrayname } { 163 #--------------------------------------------------------------------- 164 upvar #0 $arrayname array 165 166 if { [CreateTaskWindow $arrayname \ 167 "Task Interface Demo Three" "Demo 3" \ 168 [ list "Required Parameters" \ 169 "Restraint Modes" \ 170 "Define Protein Ranges to Refine" \ 171 "Crystal Parameters" ] ] == 0 } return 172 173 # Set the name of the CCP4 program help file to use 174 # (set it to refmac because it is most suitable program for this example!) 175 SetProgramHelpFile "refmac" 176 177 demo3_update_restraints_menu $arrayname 178 179 #=PROTOCOL============================================================== 180 181 OpenFolder protocol 182 183 CreateTitleLine line TITLE 184 185 CreateLine line \ 186 message "Refinement method (REFI TYPE)" \ 187 help refi_type \ 188 label "Do" \ 189 widget REFINE_TYPE \ 190 label "using" \ 191 widget INPUT_PHASE 192 193 #=FILES================================================================ 194 195 OpenFolder file 196 197 CreateInputFileLine line \ 198 "Enter input MTZ file name (HKLIN)" \ 199 "MTZ in" \ 200 HKLIN DIR_HKLIN \ 201 -fileout HKLOUT DIR_HKLOUT "_demo" \ 202 -setfileparam space_group_name SPACE_GROUP \ 203 -setfileparam cell_4 CELL_1 \ 204 -setfileparam cell_4 CELL_2 \ 205 -setfileparam cell_4 CELL_3 \ 206 -setfileparam cell_4 CELL_4 \ 207 -setfileparam cell_5 CELL_5 \ 208 -setfileparam cell_6 CELL_6 \ 209 -setfileparam resolution_min EXCLUDE_RESOLUTION_MIN \ 210 -setfileparam resolution_max EXCLUDE_RESOLUTION_MAX 211 212 CreateLabinLine line \ 213 "Observed amplitude (FP) and obligatory sigma (SIGFP)" \ 214 HKLIN FP FP [list FP F_P] \ 215 -sigma Sigma SIGFP [list SIGFP SIGF_P SIGP] 216 217 CreateLabinLine line \ 218 "Input phase (PHIB) and figure of merit (FOMB)" \ 219 HKLIN PHIB PHIB PHIB \ 220 -sigma FOMB FOMB FOMB \ 221 -toggle_display INPUT_PHASE open PHASE 222 223 CreateOutputFileLine line \ 224 "Output MTZ File" \ 225 "MTZ out" \ 226 HKLOUT DIR_HKLOUT 227 228 CreateInputFileLine line \ 229 "Enter input coordinate file name (XYZIN)" \ 230 "PDB in" \ 231 XYZIN DIR_XYZIN \ 232 -fileout XYZOUT DIR_XYZOUT "_refmac" \ 233 -command "demo3_set_range $arrayname" 234 235 CreateOutputFileLine line \ 236 "Output coordinate file" \ 237 "PDB out" \ 238 XYZOUT DIR_XYZOUT 239 240 #-----------------------------------------------------Required parameters 241 242 OpenFolder 1 243 244 CreateLine line \ 245 message "Number of cycles of refinement (NCYC)" \ 246 help refi_ncyc \ 247 label "Number of refinement cycles" \ 248 widget NCYCLES \ 249 -width 3 250 251 CreateLine line \ 252 message "Apply resolution limits (REFI RESOlution)" \ 253 help refi_reso \ 254 widget EXCLUDE_RESOLUTION \ 255 message "Minimum resolution" \ 256 label "Resolution range from minimum" \ 257 widget EXCLUDE_RESOLUTION_MIN \ 258 message "Maximum resolution" \ 259 label " to " \ 260 widget EXCLUDE_RESOLUTION_MAX 261 262 #-------------------------------------------------------- restrain modes 263 264 OpenFolder 2 265 266 CreateExtendingFrame NRESTRAINTMODES demo3_restraint_modes \ 267 "Define parameters for different restraint modes" \ 268 "Add Restraint Mode" \ 269 [list RESTRAINT_NAME \ 270 BOND_RESTRAINT \ 271 ANGLE_RESTRAINT ] \ 272 -update "demo3_update_restraints_menu $arrayname" 273 274 #--------------------------------------------------------refinement range 275 276 OpenFolder 3 277 278 CreateExtendingFrame NRANGES demo3_refine_range \ 279 "Define range(s) of residue ranges to refine" \ 280 "Add Refinement Range" \ 281 [ list RESTRAIN_MODE \ 282 CHAIN \ 283 FIRST_RES \ 284 LAST_RES ] 285 286 287 #-------------------------------------------------------------cell parameters 288 289 OpenFolder 4 closed 290 291 CreateLine line \ 292 message "Space group (default from MTZ) (SYMM)" \ 293 label "Space group" \ 294 widget SPACE_GROUP 295 296 CreateLine line \ 297 message "Cell dimensions (default from MTZ) (CELL)" \ 298 label "Cell a" \ 299 widget CELL_1 \ 300 label "b" \ 301 widget CELL_2 \ 302 label "c" \ 303 widget CELL_3 \ 304 label "alpha" \ 305 widget CELL_4 \ 306 label "beta" \ 307 widget CELL_5 \ 308 label "gamma" \ 309 widget CELL_6 310 311 } 312