The CGI program can do almost anything. Our CGI program (called geom.pl) will only analyse the name=value string and pass on the name of the protein file (in the value part) to a molecular geometry program called geom after printing a simple heading. geom will read the Brookhaven file and calculate all the bond lengths, bond angles and torsion angles of the protein. The results will be displayed by the browser.
CGI programs can be written in any language. Sometimes they are written in Unix shell languages, such as bash, or they can be written in C/C++. Perl is particularly well suited to processing HTML forms and that is what I have used for geom.pl in order to decode the CGI string. However Perl is not suitable for heavy numerical calculations and therfore the Perl script passes the file name to geom which is machine code compiled from a C++ source text.
Let us now look at the Perl script.
# Get CGI-parsing routines
require "cgi-lib.pl";
# Parse form data
&ReadParse;
# Flush STDOUT buffer after each command
select(STDOUT);
$| = 1;
# Print header of output
print STDOUT "Content-type: text/plain\n\n";
print STDOUT "Protein Residues and Molecular Geometry\n\n";
print STDOUT "Protein file: $in{'filename'}";
# Call molecular geometry program
system("/home/prog/classlib/apps/geom/geom $in{'filename'}");
The output from the script which is associated with the Perl filehandle STDOUT. The select statement and the assignment to $| ensure that this output is unbuffered. This means that the output is sent to the server immediately after each print statement has been executed. Without this precaution, the output from the print statements in this script and the output from the molecular geometry program may become mixed up.
Try Out the Geometry Program
Back to Index