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 demo1_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     DefineMenu _demo_restrain_mode   [ list loose medium tight ]
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 demo1_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 demo1_refine_range { arrayname counter } {
59   #---------------------------------------------------------------------
60   #procedure to draw one line of the 'refinement range' extending frame
61     upvar #0 $arrayname array
62   
63     CreateLine line \
64           message "Enter range of residues to refine" \
65           label "Use" \
66           widget RESTRAIN_MODE \
67           label "restraints for chain" \
68           widget CHAIN \
69           label "from residue" \
70           widget FIRST_RES \
71           label "to residue" \
72           widget LAST_RES
73   
74   }
75   
76   # procedure to draw task window
77   #---------------------------------------------------------------------
78   proc demo1_task_window { arrayname } {
79   #---------------------------------------------------------------------
80     upvar #0 $arrayname array
81   
82     if { [CreateTaskWindow $arrayname  \
83       	"Task Interface Demo One" "Demo 1" \
84           [ list "Required Parameters"  \
85   	"Define Protein Ranges to Refine" \
86   	"Crystal Parameters" ] ] == 0 } return
87   
88   # Set the name of the CCP4 program help file to use
89   # (set it to refmac because it is most suitable program for this example!)
90     SetProgramHelpFile "refmac"
91   
92   #=PROTOCOL==============================================================
93   
94     OpenFolder protocol 
95   
96     CreateTitleLine line TITLE
97   
98     CreateLine line \
99           message "Refinement method (REFI TYPE)" \
100  	help refi_type \
101          label "Do" \
102          widget REFINE_TYPE  \
103          label "using" \
104          widget INPUT_PHASE
105  
106  #=FILES================================================================
107  
108    OpenFolder file 
109    
110    CreateInputFileLine line \
111  	"Enter input MTZ file name (HKLIN)" \
112        "MTZ in" \
113         HKLIN DIR_HKLIN \
114         -fileout HKLOUT DIR_HKLOUT "_demo" \
115         -setfileparam space_group_name SPACE_GROUP \
116  	-setfileparam cell_4 CELL_1 \
117  	-setfileparam cell_4 CELL_2 \
118  	-setfileparam cell_4 CELL_3 \
119  	-setfileparam cell_4 CELL_4 \
120  	-setfileparam cell_5 CELL_5 \
121  	-setfileparam cell_6 CELL_6 \
122  	-setfileparam resolution_min EXCLUDE_RESOLUTION_MIN \
123  	-setfileparam resolution_max EXCLUDE_RESOLUTION_MAX
124  
125    CreateLabinLine line \
126  	"Observed amplitude (FP) and obligatory sigma (SIGFP)" \
127  	HKLIN FP FP  [list FP F_P] \
128          -sigma Sigma SIGFP [list SIGFP SIGF_P SIGP]
129  
130    CreateLabinLine line \
131  	"Input phase (PHIB) and figure of merit (FOMB)" \
132  	HKLIN PHIB PHIB  PHIB \
133          -sigma FOMB FOMB FOMB \
134          -toggle_display INPUT_PHASE open PHASE
135  
136    CreateOutputFileLine line \
137  	"Output MTZ File" \
138  	"MTZ out" \
139  	HKLOUT DIR_HKLOUT
140  
141   CreateInputFileLine line \
142          "Enter input coordinate file name (XYZIN)" \
143        "PDB in" \
144         XYZIN DIR_XYZIN \
145         -fileout XYZOUT DIR_XYZOUT "_refmac"
146  
147    CreateOutputFileLine line \
148          "Output coordinate file" \
149          "PDB out" \
150          XYZOUT DIR_XYZOUT
151  
152  #-----------------------------------------------------Required parameters
153  
154    OpenFolder 1
155  
156    CreateLine line \
157  	message "Number of cycles of refinement (NCYC)" \
158  	help refi_ncyc \
159          label "Number of refinement cycles" \
160  	widget NCYCLES \
161  	  -width 3 
162  
163    CreateLine line \
164  	message "Apply resolution limits (REFI RESOlution)" \
165  	help refi_reso \
166  	widget EXCLUDE_RESOLUTION \
167  	message "Minimum resolution" \
168  	label "Resolution range from minimum" \
169  	widget EXCLUDE_RESOLUTION_MIN \
170  	message "Maximum resolution" \
171  	label " to " \
172  	widget EXCLUDE_RESOLUTION_MAX
173  
174  #--------------------------------------------------------refinement range
175  
176    OpenFolder 2
177  
178    CreateExtendingFrame NRANGES demo1_refine_range \
179          "Define range(s) of residue ranges to refine" \
180          "Add Residue Range" \
181         [ list RESTRAIN_MODE \
182  	CHAIN \
183          FIRST_RES \
184          LAST_RES ]
185  
186  
187  #-------------------------------------------------------------cell parameters
188  
189    OpenFolder 3 closed
190  
191    CreateLine line \
192  	message "Space group (default from MTZ) (SYMM)" \
193  	label "Space group" \
194  	widget SPACE_GROUP
195  
196    CreateLine line \
197  	message "Cell dimensions (default from MTZ) (CELL)" \
198  	label "Cell a" \
199  	widget CELL_1 \
200  	label "b" \
201  	widget CELL_2 \
202  	label "c" \
203  	widget CELL_3 \
204  	label "alpha" \
205  	widget CELL_4 \
206  	label "beta" \
207  	widget CELL_5 \
208  	label "gamma" \
209  	widget CELL_6
210  
211  }
212