ICM Manual

Introduction

Common Gateway Interface (CGI) is a standard method used to generate dynamic content on web pages and web applications. CGI, when implemented on a web server, provides an interface between the web server and programs that generate the web content. These programs are known as CGI scripts or simply CGIs; they are usually written in a scripting language, but can be written in any programming language including ICM.

An ICM CGI script consists of the following important elements:

Simple Example

The simplest 'Hello World' ICM CGI script may look like this:

#!/usr/prog/icm/icm64 -w/usr/prog/icm

printf "Content-type: text/html;\n\n"

print "Hello from ICM SGI script"

quit

Tables in HTML output

ICM provides a command show html to generate a nicely formatted HTML code for shell tables. The command generates fully self-contained HTML code with head and body tags. If you CGI script produces a single HTML table you can use this command as is.

Example:

#!/usr/prog/icm/icm64 -w/usr/prog/icm

printf "Content-type: text/html;\n\n"

params = Collection(web)
if (Exist(param["filename"])) then
 # reads sn SDF file on the server
 read table mol param["filename"] name="t"   
 show html t
endif

quit

In more complex cases when table is just a part of bigger HTML code you need to extract body part and, optionally, javascript part which renders chemical structures. It can be done using regular expression and Match function

Example:

# store the result HTML in s_html string variable
 show html t output = "s_html"   
 # extract table 
 s_table = Match(s_html,"<body.*?>(?n)(.*)</body>", 1 )  
 # for chemical tables you might want to extract JavaScript code
 # It defines a function with name: onLoad_<tableName> 
 # which will draw chemicals when you call it.
 s_js    = Match(s_html,"<script.?>(?n)(.*)</script>", 1 ); 
 # add s_table and s_js into appropriate parts of your result HTML
 s_head += s_js
 s_body += s_table
 # show the result html
 show "<head>" + s_head + <"/head">
 show '<body onload="onLoad_t();">' + s_body + "</body>"

Integration with Molsoft HTML5 Molecule Editor

Please click here to learn how to embed molecule editor into your html code.

Chemical Search Script Demo

The example which demonstrates the functionality above: Chemical Search Demo

It provides basic chemical search functionality using find molcart command and chemical database file The source code if the script is here