#! ./perl #************************************************************************ #* * #* Perl script: mr_rogers_proc * #* * #************************************************************************ #* #* G.D. Searle & Co. #* #* #* Date: 4/10/96 #* Programmer: Tom Doman #* Modified by: #* 7/96, 8/96 - mjc #* Extensive modifications to the program. #* - Base URL's defined at the top #* - Administrator name/email defined at the top #* - Encryption table definition and basic #* encryption and decryption functions. #* - Daylight environment checking #* - Database information associative arrays #* - Computation of database size and last date #* modified. Passing of information on to next #* call of page. #* - Added neighbor thresholds. #* - Compound and structure table and passing of #* the chosen compounds and their smiles on. #* - Lookup of compounds in databases. #* - Drawing of compound structures via Daylight #* utilities if user authorized to see structures #* (how authorization is determined is yet to #* be decided. At present, just a button to #* toggle authorization for testing purposes.) #* - Addition and removal of compounds from the #* list of selected compounds. #* - Wiring in of neighbor_of for production of #* the neighbors lists. Output is parsed, #* displayed, and passed on to next call of #* page. Neighbors are looked up in the #* databases to determine their smiles and the #* structures are displayed if authorization #* permits. #* - Ability to simply specify a smiles string and #* a name will be automatically generated for the #* compound (up to 1000 compounds may be specified #* this way and can be increased if necessary). #* - Grins editor interfaced with the script. This #* generates a script for the html page to be #* called after the grins editor exits in order to #* return the smiles and the other information. #* uses client pull to load the grins editor after #* constructing the script. #* - Checks to see if a hand-input smiles are valid #* - Looks up in $database_stats_file the database #* statistics rather than recomputing them all the #* time because it is a fairly time-consuming #* process and only needs to be done once every time #* a database is updated. #* - Changed the prefixes in the smiles files for CP #* and ACD to be CP and ACD rather than none. Fixes #* the problem with uniquely identifying where a #* compound came from for smiles lookup. #* - When entering smiles by hand, you can now enter #* the name and smiles in any order, the page will #* attempt to recognize which is which, but will #* make the preliminary assumption that the name #* is first and the smiles is second. #* 9/5/96 - tnd; made a change around line 467 & in #* "print_neighbors" so that it appears to the user #* that compound indexes start from 1 instead of 0; #* I only had to change ngh_lowervalue, which is a #* slightly disturbing (because it means I don't know #* exactly how "neighbor_of" works!) #* 9/6/96 - tnd; changed the order of lower/upper Tanimotos #* 9/9/96 - tjo; moved all required procs to own dir #* 9/9/96 - tjo; allow user to type return after grins #* editor tmp_proc asks for name #* 9/10/96 - tjo; add authorization front page and #* remove old "I am authorized..." submit button #* 9/10/96 - tjo; add save button (and functionality!) #* 9/11/96 - tjo; add toggle for structure display #* 9/11/96 - tjo; add refresh submit button #* 9/12/96 - tjo; add Save Results/Save Hitlist #* 9/13/96 - tjo; create offical v1.0; debug it #* 9/16/96 - tjo; add username to authorization page #* and enter "login" info to .log file #* 9/16/96 - tjo; disallow any search access to SC/CP #* for unauthorized users. This means authorization #* is easier to handle since you can't even search #* what you're not authorized to search - therefore #* all structures are displayed. #* =========BEGIN V1.2 CHANGES========= #* 9/20/96 - tnd; add "auth_user" external subroutine #* call; this simply checks yellow pages for a valid #* username & password; according to Jeff Gaw this is #* sufficient authorization to see structures (at #* least for Biochem) #* 9/20/96 - tnd; changed all default prefixes to "" #* =========BEGIN V1.3 CHANGES========= #* 9/30/96 - tjo; removed neighbor_of logging and #* expanded MrRogers logging #* 10/01/96 - tjo; added Display Smiles toggle #* 10/01/96 - tjo; restored neighbor_of logging to #* unique file #* 10/02/96 - tjo; allow startup of grins editor #* with contents of ID field #* 10/02/96 - tjo; only take first word if grins #* editor returns name with whitespace in it #* 10/02/96 - tjo; add Save Smi File feature #* 10/04/96 - tjo; treat idvalue as smiles it it's #* valid, even if compound number option is selected #* =========BEGIN V1.4 CHANGES========= #* 10/07/96 - tjo; if idvalue is null, ignore. #* 10/07/96 - tjo; fixup encrypt to not return ' char. #* 10/07/96 - tjo; remove encrypt/decrypt altogether. #* 10/07/96 - tjo; rewrite get_smiles3.pl to use #* gdbm for smiles lookup; use mkgdbm to make #* gdbm from .smi file when new .smi arrives #* 10/08/96 - tjo; add Read Results File option #* 10/08/96 - tjo; truncate tanimotos to 3 sig figs. #* 10/09/96 - tjo; add Print Results option #* =========BEGIN V1.5 CHANGES========= #* 10/11/96 - tjo; prettied up presentation using #* lists, reduced some paddings, #* added Intro/Hints/News links up top. #* =========BEGIN V1.6 CHANGES========= #* 10/11/96 - tjo; add some JavaScript alerts #* 10/17/96 - tjo; made thumbnails bigger when irix #* 10/17/96 - tjo; fix a bug passing(HIDDEN) results #* stored in @ngh_output after GRINS edit. #* 10/28/96 - tjo; PRADO output to user, not lp #* 10/29/96 - tjo; add CAP database #* fixup parseid to allow, e.g. CAP-0125677118-144 #* =========BEGIN V1.7 CHANGES========= #* 10/30/96 - tjo; add filename to Content-disposition #* 10/30/96 - tjo; check sc.sec authorization file #* 10/31/96 - tjo; revamp parseid to allow SC-#####A #* and other CAP name-types. Remove error exit #* since searching (get_smiles) is so fast now. #* 11/01/96 - tjo; revamp %smifiles, %databases, #* %fingerprints for better, smaller, more secure code. #* 11/01/96 - tjo; change @ngh_output to $ngh_output #* and let parse_neighbor_output split on \n #* 11/04/96 - tjo; add restart from scratch button #* 11/05/96 - tjo; restructure results table #* 11/06/96 - tjo; add cookies for tanilo, etc. #* =========BEGIN V2.0 CHANGES========= #* 12/16/96 - tnd; fixed bug w/ database hyperlinks #* (see comment TNDxxx01) #* =========BEGIN V2.1 CHANGES========= #* 12/96 - tjo; add computation of properties #* using PCMODELS clogp&cmr and script #* using DayPerl for more properties. #* 12/96 - tjo; remove cookies and replace with #* preferences file maintained with this perl prog. #* 12/6 - tjo; fix bug preventing # in Grins editor #* =========BEGIN V2.15 CHANGES========= #* 12/96 - tjo; restructure code for frames #* adding here docs when possible #* 12/96 - tjo; replace `bin2hex` with unpack H* #* 12/96 - tjo; replace `check_one_smi` with &check_smi #* 1/97 - tjo; move display_results, etc. to new #* mr_rogers_results.pl file to open new window #* with results. #* 1/97 -tjo; abort the changes of 1/97 #* !!!!!VERSION 2.15 NOT RELEASED!!!!! #* keep unpack H* and &check_smi changes in 2.2 #* =========BEGIN V2.2 CHANGES========= #* keep unpack H* and &check_smi changes in 2.2 #* 1/9/97 - tjo; add MFCD database and code to #* recognize special MFCDnnnnnnnn id's (no -) #* 1/10/97 - tjo; restart with 2.15 and add back #* unpack instead of `bin2hex` #* &check_smi instead of `check_one_smi` #* restructure code using here docs #* 1/13/97 - tjo; add grins edit button for each #* compound. #* 1/13/97 - tjo; add email link for suggestions, bugs. #* 1/13/97 - tjo; release 2.2 #* =========BEGIN V2.3 CHANGES========= #* 1/15/97 - tjo; restructure to make main code #* more readable by making sub routines #* #* #* Tools used: perl #* #* Description: #* #* #* #* Returns: #* #* Arguments: #* #* #* Notes: #* #* #* USAGE: #* #* #************************************************************************ #ENDHELP #@INC = ("/da/tjodon/www/MrRogers/mug97/demo/lib/perl5/IP17-irix/5.002", "/da/tjodon/www/MrRogers/mug97/demo/lib/perl5", "/da/tjodon/www/MrRogers/mug97/demo/lib/perl5/site_perl/IP17-irix", "/da/tjodon/www/MrRogers/mug97/demo/lib/perl5/site_perl", "."); # require("cgi-lib.pl"); require("get_smiles3.pl"); require("auth_user.pl"); $start_time = &sumtimes; $version = "2.x"; # Set up the home, cgi, and www URLs for this script. Makes it much easier to change where the files are located $home_URL = "/"; # The host machine $i = rindex($ENV{SCRIPT_NAME}, "/"); $cgi_dir = substr($ENV{SCRIPT_NAME},1,$i); $cgi_URL = $home_URL.$cgi_dir; # The cgi URL $home_day = "/"; # The host machine $day_URL = $home_day.$cgi_dir; # Might be the same as $cgi_URL $www_URL = $home_URL."MrRogers/mug97/demo/"; # The directory for my html/help # Administrator name and email address for errors which need to be reported $admin = "Tom Doman"; $admin_email = "tndoma\@ddix6.monsanto.com"; # Log file for authorization attempts and db access, etc. $LogFile = "mr_rogers.log"; $NghLogFile = "neighbor_of.log"; if ($ENV{'QUERY_STRING'} eq "") { &get_authorization; exit 1; } # are we on a irix server? $_ = $ENV{'HTTP_USER_AGENT'}; $irix = m/irix/i; # Now get the user input from the FORM &ReadParse(*in, *incfn, *inct, *insfn); # Process authorization privileges $authorized = $in{'Authorization'}; # Associative arrays for the file lookup by compound name %smifiles = ( "SC", "", "CP", "", "ACD", "acd.smi", "CAP", "cap.smi" ); %fingerprints = ( "SC", "", "CP", "", "ACD", "acd.fp", "CAP", "cap.fp"); %databases = ( "SC", "", "CP", "", "ACD", "acd.gdbm", "CAP", "cap.gdbm" ); %file_prefixes = ( "MFCD", "ACD", "CAP", "CAP" ); # unless authorized, don't even say where CP and SC compounds are if ($authorized) { $smifiles{"SC"} = "sc.smi"; $smifiles{"CP"} = "cp.smi"; $fingerprints{"SC"} = "sc.fp"; $fingerprints{"CP"} = "cp.fp"; $databases{"SC"} = "sc.gdbm"; $databases{"CP"} = "cp.gdbm"; %file_prefixes = ( "E", "SC", "L", "SC", "P", "SC", "R", "SC", "SN", "SC", "X", "SC", "Y", "SC", "SC", "SC", "CP", "CP", "MFCD", "ACD", "CAP", "CAP" ); } $database_stats_file = "database.stats"; @DBtypes = keys %databases; # == keys %smifiles == keys %fingerprints # Check to see if the daylight license data environment variable is set unless( $ENV{'DY_ROOT'} ) { # Not set, set it $ENV{'DY_ROOT'} = "/dd/daylight/v442"; $ENV{'DY_LICENSEDATA'} = "$ENV{'DY_ROOT'}/etc/dy_license.dat"; } # see if this is the 1st invocation, in which case there won't be any # data from the FORM if ($ENV{QUERY_STRING} eq "0" || $ENV{'REQUEST_METHOD'} ne "POST") { &init_stuff; } else { &process_form; } # Tell Netscape that this is a html file print "Content-type: text/html\n\n"; # Print the Mister Rogers form &print_mrr_form; # special stuff for client pull (GRINS editor) print $forward if ($forward); # informational output to another window if ($output) { print "\n"; } # summary output and times $end_time = &sumtimes; #print "