libtbx.program_template: Standard Program Template for CCTBX Programs¶
Program Template¶
The “program” is the actual task to be performed without any user interfaces. The user interfaces (command-line and graphical) build the “data_manager” and “params” objects for the program. The “data_manager” handles all file input and “params” handles all the program settings.
The required methods break up the calling order into discrete phases
constructor: minimal set up
validate: check that the inputs (files and parameters) are valid and consistent
run: run the actual task
get_results: return the desired output from the program
The optional methods provide some extra tweaking
custom_init: called at the end of the constructor, additional initialization
- clean_up: if temporary files are written in the course of running the program,
this step should remove those files.
- class libtbx.program_template.ProgramTemplate(data_manager, params, master_phil=None, logger=None)¶
- __init__(data_manager, params, master_phil=None, logger=None)¶
Common constructor for all programs
This is supposed to be lightweight. Custom initialization, if necessary, should be handled by the custom_init function. Developers should not need to override this function.
- Parameters:
data_manager – An instance of the DataManager (libtbx/data_manager.py) class containing data structures from file input
params – An instance of PHIL
logger – Standard Python logger (from logging module), optional. A logger will be created if it is not provided.
- clean_up()¶
- custom_init()¶
Optional initialization step
Developers should override this function if additional initialization is needed. There should be no arguments because all necessary information should be in self.data_manager (file input) and self.params (phil parameters)
- Parameters:
None
- get_results()¶
- run()¶
- validate()¶