In two previous blog posts we introduced the GreenMamba framework (download) and showed how it can be used to easily set up a web database from an Excel sheet or tab-delimited file. However, the primary motivation for developing GreenMamba was to make it as simple as possible to turn command-line tools, e.g. sequence-based prediction methods, into full-fledged web tools.
The work that would normally be required to do so is to install a web server, create an HTML page with an input form, and code a CGI script that receives the input from the form, converts the input data into command-line arguments, executes the command-line tool, and returns the result. This is not terribly difficult provided that you know how to configure a web server (e.g. Apache) and write CGI scripts. However, it takes considerable time to design a consistent, professional looking HTML web interface that handles both input and output and works correctly on all major web browsers.
With GreenMamba setting up a command-line tool as a web tool requires only a few lines in the inifile describing the name and command syntax of the tool. To exemplify this, we have made a simple example Perl script that simply searches a regular expression against a set of protein or DNA sequences in a FASTA file, both of which are provided by the user. The following inifile is all it takes to turn that Perl script into a web tool:
host : localhost
port : 8080
plugins : ./greenmamba
command : greenmamba/examples/motifs.pl $motif @fasta
The first two lines should be familiar from the previous blog post, and the last two lines specify that we have a tool called Motifs, which should run the Perl script
motifs.pl with two arguments
@fasta. The difference between handles starting with
@ is that the former will be replaced with the input data, whereas the latter will be replaced with the name of temporary file containing the input data. In the example, the script is to be run with a regular expression (
$motif) as first argument and the name of a fasta file (
@fasta) as second argument.
Based on the command-line syntax given in the inifile alone, GreenMamba creates the following rudimentary web interface, which can be accessed through http://localhost:8080/HTML/Motifs (here shown with a query):
The names of the various handles (@fasta and $motif) are used as labels for the input fields. It is thus possible to improve the interface a bit simply by giving the handles more descriptive names (underscores will be shown as spaces). GreenMamba also allows the use of a customized input form, which will be explained in an upcoming blog post.
In this example above, pressing the submit button causes GreenMamba to take the command from the inifile, replace
$motif with the content of the
motif text field, replace
@fasta with the name of a temporary file into which the content of the
fasta textarea has been written, and execute the resulting command using a system call. Subsequently the output of the command is read and temporary files deleted. In this particular case, the script produces tab-delimited output, which GreenMamba automatically detects and formats as an HTML table in the output page:
If the output is not tab-delimited, it is by default shown as plain pre-formatted text. However, through the .ini file you can change it to handle several other types of output including comma-separated values, HTML, and several image formats. We will likely add support for more formats in the future.