A Simple Example of a CCP4i Task

This simple example is intended to give you a quick idea of what is involved in coding a CCP4i task.
The demo task is an interface to a non-existant program demoprog which has some interface features you might expect for a refinement program.

The task window looks like this:


The top protocol folder has an entry for the user to give a job title and two menus for the user to choose full refinement/quick refinement and to choose no phase input/input phases.
The file folder has lines for the user to enter the names of input MTZ, output MTZ, input PDB and output PDB files.  Beneath the line for input MTZ file is a line to select input column data.  In the displayed task window the user has already selected an input MTZ file and the menus on column data select ion line have been set to list the column data in the input MTZ file.  A default name has also been set for the output MTZ file and the resolution limits found in the MTZ file have been put as defaults further down the task window.
The Required Parameters folder allows the user to set the number of refinement cycles and, optionally, to set a resolution range.
The Define Protein Ranges to Refine folder allows the user to select any number of residue ranges using an extending frame mechanism
The Crystal Parameters folder is, by default, closed but enables the user to set the space group and cell parameters.

There are four files needed to generate and support this interface:

demo.def - contains a list of all the variables associated with the task and their default values

There is one variable per line with the variable name, type and default value for each variable.  You should be able to see the correspondance between the variables in the def file and the widgets in the task window but some features to note:
All  data types are defined in $CCP4/ccp4i/etc/types.def  except the two variables which are represented by menus on the window, REFINE_TYPE and INPUT_PHASE. These have data types _demo_refine_type  and _demo_input_phase which are defined in the demo.tcl file.
Each file  selection has two variables, one is the file name and the other is the directory alias.
The LABIN variable contains a list of the MTZ column variables which are to be put into the program command file.  By default this is just 'FP SIGFP' but if the user opted to have phase input then this list would be extended to 'FP SIGFP PHIB FOMB'

demo.tcl  - defines the appearance of the task window.  This file is written in the Tcl scripting language but uses a lot of CCP4i library calls to simplify drawing the window.   The main procedure in this file is demo_task_window and within this procedure you can see calls to the library procedures such as OpenFolder and CreateLine.

demo.script- a script which is run when the user hits the 'Run' button.  This is run as a separate process and the script runs the program demoprog (or rather, it would run the program if it existed!).  The call to CreateComScript will create a command script for the demoprog program using the values of parameters from the GUI and the template file demoprog.com which encodes the command syntax required by the program.  The call to Execute will  run the program and handle the log file and program failure.