In the previous blog post I showed how you can use GreenMamba (download) to turn a command-line tool into a simplistic web tool with a minimal of effort. Sometimes, however, you will want to put in just a bit more effort and use a custom input form instead of the default one.
The default input page that was automatically created by GreenMamba based on the syntax of the command alone allowed the user to enter a motif in the form of a regular expression:
Suppose we would rather allow the user to select one of the 166 motifs from the ELM database through an input page looking like this:
To achieve this we add on line to the inifile, which instructs GreenMamba to use the custom HTML in the file
motifs_home.html instead of the auto-generated input page:
host : localhost
port : 8080
plugins : ./greenmamba
command : greenmamba/examples/motifs.pl $motif @fasta
page_home : greenmamba/examples/motifs_home.html
motifs_home.html contains the following piece of HTML code (numerous
<option> lines for different ELMs replaced with
... for brevity):
Select the Eukaryotic Linear Motif to search:<br />
Enter the sequences to be searched in FASTA format:<br/>
<textarea name='fasta' cols='80' rows='20'>>MYB_HUMAN
Note that this is not a complete HTML page but only the piece of HTML code that goes between the
/<form> tags (minus the submit button). Also note that the names of the input fields must match the handles specified under
command in the inifile (e.g.
motif; if they do not, GreenMamba will have no idea where to insert the user input in the command.
The example above is unusually complex due to the mapping of ELM names to regular expression. Usually your custom HTML forms will be far shorter. In those cases you may not even want to store the custom HTML file and instead provide the HTML on a single line inside the inifile, which GreenMamba supports.
Finally, it should be pointed out that this customization step is entirely optional. You do not have to edit HTML forms to set up GreenMamba web resources, but you have the flexibility to do so if you want to.