Version 4 (modified by dkearney, 15 years ago) (diff)


Wrapper Script Basics

Topics covered:

  1. What is a Wrapper Script?
  2. Basic Format of a Wrapper Script.
  3. Hands On Example
  4. Wrapper Script Examples

What is a wrapper script?

A wrapper script is a file used to processes the data traveling between the Rappture GUI and the science portion of a project. Most applications do not need a wrapper script because the Rappture libary calls can be embedded directly into the source code, yet still separate from the science code. Typically, wrapper scripts are written in a scripting language such as Tcl or Python. Here are a few cases when you should consider using a wrapper script instead of embedding the Rappture library calls into the source code:

  1. If the code is considered a legacy application where there is little new development and it just needs a graphical user interface.
  2. If the original source code is considered an industry standard and there is no advantage to changing it.
  3. You do not have access/permission to the original source to add Rappture library calls

If your project is still under development or otherwise does not fit into one of the previously definded conditions, you should seriously consider embedding the library calls into your application.

Basic Format of a Wrapper Script

All wrapper scripts follow the same basic format:

  1. open a rappture library object by sending it an xml file
  2. "get" inputs that the user specified, from the rappture object
  3. create an input file for your science code
  4. call your science code
  5. parse the output files from the science code
  6. "put" the interesting output back into the rappture library object
  7. call the result function to tell rappture graphical user interface that the wrapper script is complete.

Generally wrapper scripts are written in a scripting language such as Tcl, Python, or Perl. This is because with scripting languages usually make it easy to do string manipulation, external application calls, and creation of files. While these activities can be done in languages like C/C++ or Fortran, its just easier and more convenient to use a scripting language. If you don't know a scripting language, then this is an excellent time to learn one. Tcl, Python and Perl are all pretty easy to learn and understand, especially if you already know another programming language.

Hands On Example

Wrapper Script Examples

There are a number of previously written wrapper scripts you can look at or use as a starting place for your own script. Check out these examples from other projects:

  1. MolCToy Wrapper Script (tcl)
  2. Padre Wrapper Script (tcl)
  3. CNTBands Wrapper Script (tcl)
  4. Rappture Upload Wrapper Script Example (python)

Back to Frequently Asked Questions