Resource: Improving a GreenMamba web resource with a custom input form

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/ $motif @fasta
page_home : greenmamba/examples/motifs_home.html

The file 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 />
<select name='motif'>
<option value='[ILV]..[R][VF][GS].'>CLV_MEL_PAP_1</option>
<option value='(.RK)|(RR[^KR])'>CLV_NDR_NDR_1</option>
<option value='R.[RK]R.'>CLV_PCSK_FUR_1</option>
</select><br />
<br />
Enter the sequences to be searched in FASTA format:<br/>
<textarea name='fasta' cols='80' rows='20'>&gt;MYB_HUMAN

Note that this is not a complete HTML page but only the piece of HTML code that goes between the <form> and /<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. fasta and 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.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s