#!/usr/local/bin/perl # ###################################################################################### # # molray.pl - Perl5 cgi script to run graphics suite. MRH 18-Oct-99/See $version below # ###################################################################################### # # Consists of several blocks corresponding to different pages. # # Referenced first as eg : "http://my_host_name/cgi-bin/molray.pl" # Or for single frame window : "http://my_host_name/cgi-bin/molray.pl?1" # Or for multiple windows : "http://my_host_name/cgi-bin/molray.pl?2" # # Installation help can be found at : # http://xray.bmc.uu.se/markh/notes/howto/molray_install.html # ################################################################################## # Set up variables #================= #------------------------------------------------ # You will want to change the next few lines #------------------------------------------------ # Scratch must be read-writable from cgi-bin and should be relative #------------------------------------------------ $script_name = "http://xray.bmc.uu.se/cgi-bin/markh/molray.pl"; $scratch_url = "http://xray.bmc.uu.se/tmp"; $scratch_dev = "../../tmp"; $prog_bin = "/usr/local/bin"; $remote_cmd = "$prog_bin/qsub -V -cwd -F -l batch -N Molray "; $Imagedir = "http://xray.bmc.uu.se/markh/cgi/images/"; $Usagelog = "molray_usage.log"; $Overloadlog = "molray_overload.log"; $Trusted_domain = "uu.se"; $Pov_incl_dir = "/home/markh/povray/"; $povray = "$prog_bin/megapov"; #$pov_inc = "/usr/local/lib/povray"; #-------------------------------------------------------------------- # Program execution commands. You will need to install these programs #-------------------------------------------------------------------- # # plt_pov can be found at : http://xray.bmc.uu.se/markh/notes/howto/plt_pov.f # POV-Ray can be found via : http://www.povray.org/ # gifsicle lives here : http://www.pdos.lcs.mit.edu/~eddietwo/gifsicle/index.html # surfout comes from : http://imsb.au.dk/~ding/prg_surfout.html # convert is in ImageMagick : http://www.wizards.dupont.com/cristy/ # ligplot can be got from : http://www.biochem.ucl.ac.uk/bsm/ligplot/ligplot.html # file_growth_monitor from : http://xray.bmc.uu.se/markh/notes/howto/file_growth_monitor.pl.save # #-------------------------------------------------------------------- $plt_pov = "$prog_bin/plt_pov"; $tga_to_other = "$prog_bin/convert"; $tga_to_png = "$prog_bin/convert_png"; $molscript = "$prog_bin/molscript_pov"; $surfout = "$prog_bin/surfout"; $ligplot = "$prog_bin/ligplot.scr"; $ligplotdir = "$prog_bin/"; $transgif_prog = "$prog_bin/gifsicle"; $transgif_prms = "-t 239,206,252 "; $animgif_prog = "$prog_bin/gifsicle"; $mpeg_prog = "$prog_bin/mpeg_encode"; $mpeg_params = "/usr/www/cgi-bin/markh/mpeg.params"; $file_growth_monitor = "file_growth_monitor.pl"; $file_growth_monitor_exp = "file_growth_monitor_exp.pl"; # Tidy-up time (minutes). Deletes tmp files after this time #---------------------------------------------------------- $tidy_time = "6000"; # Quota limits (mostly for public server) #---------------------------------------- $limit_pixels = 10000; $limit_frames = 1000; $limit_other_jobs = 5; # You probably don't want to change things below this line #========================================================= # Set some harder variables #------------------------------------------- $version = "Molray version 1.3 updated 27-Nov-2003"; $Helpfile = "http://xray.bmc.uu.se/markh/notes/howto/molray_help.html"; $Demofile = "http://xray.bmc.uu.se/markh/notes/howto/molray_demo.txt"; # Check to see if we're on the public server #------------------------------------------- $Trusted_flag ="no"; $public_flag ="no"; $host = `hostname`; chomp($host); if ($host eq "portray.bmc.uu.se") { $public_flag ="yes"; } if ($public_flag eq "yes") { $script_name = "http://portray.bmc.uu.se/cgi-bin/markh/molray.pl"; $scratch_url = "http://portray.bmc.uu.se/tmp"; $scratch_dev = "/serv/www/tmp"; $Imagedir = "http://xray.bmc.uu.se/markh/cgi/images/"; $mpeg_params = "/serv/www/apache/cgi-bin/markh/mpeg.params"; $remote_cmd = ""; # And also if we don't have local priviliges $client = $ENV{'REMOTE_HOST'}; if ($client eq "") {$client = "host"}; if (index($client,$Trusted_domain) == -1) { ## $limit_pixels = 600; ## $limit_frames = 10; $limit_other_jobs = 6; } else { $Trusted_flag = "yes"; } } else { # Local server $limit_other_jobs = 2; } # Find directory for file_growth_monitor #--------------------------- $url_bin = $script_name; $url_bin =~ s/\/([^\/]*$)/\//; # Date #----- $date = sprintf("%02d",$fulltime[4]); ($day, $month, $dom, $time, $year) = split(/\s+/,localtime(time),5); ($hour, $min, $sec) = split(/:/,$time,3); $date = "$day $dom-$month-$year $hour:$min"; # Other parameters #----------------- $thumb_size = "250"; $cam_dist = "20.0"; $preview_dist = "50"; $spline_tension = "0.5"; $spline_continuity = "0.0"; $spline_sampling = "10"; $spline_banking = "0.25"; $spline_function = "cubic"; $line_thick = "0.04"; $def_depth_cue = "10"; $depth_cue = "0"; $def_steps = 20; $perspangle = "60.0"; $aspect_ratio = ""; $selectall_checked = " "; $cam_points = "20,10,10\n20,10,-10\n20,-6,-6\n20,6,6"; $cam_points = "60,60,0\n48,40,20\n38,30,40\n30,20,20\n25,10,10\n20,0,0 "; # Colours #-------- $bgcolour = "#FFCC33"; $cell_colour = "#AAAAFF"; $run_colour = "#F9a907"; $Rback = 0.0; $Gback = 0.0; $Bback = 0.0; # Movie parameters #----------------- $movie_rate = 10; $movie_loop = ""; # Pickup URL parameters #---------------------- $qstring = $ENV{'QUERY_STRING'}; if($qstring eq "0"){$qstring="Pltp&frames=0"} if($qstring eq "1"){$qstring="Pltp&frames=1"} if($qstring eq "2"){$qstring="Pltp&frames=2"} $page = substr($qstring,0,5); $id = substr($qstring,index($qstring,'&id=')+4); if (index($id,'&') > 1) {$id = substr($id,0,index($id,'&'))}; $page_num = substr($qstring,4,1); $tmp = $page_num; if (substr($page,4,1) eq "&" || substr($page,4,1) eq "9") { $page = substr($qstring,0,4); $page_num = ""; } if (index($qstring,'&frames=') gt 0) { $frames_type = substr($qstring,index($qstring,'&frames=')+8); } else { $frames_type = 0; } $advmode = substr($qstring,index($qstring,'&advmode=')+9); if (index($advmode,'&') > 1) {$advmode = substr($advmode,0,index($advmode,'&'))}; # Find host and set scratch dir #------------------------------ $client = $ENV{'REMOTE_HOST'}; if ($client eq "") {$client = "host"}; $client =~ s/\..*$//; $scratch = "$scratch_dev"."/"."$client"; # Add log files to batch command #------------------------------- if (index($remote_cmd,"qsub") != -1) { $remote_cmd = "$remote_cmd -e $scratch/tmpp_batch_error.log -o $scratch/tmpp_batch_out.log "; } # Set id to process id only on first page, and create scratch subdir #------------------------------------------------------------------- if ($page_num eq "0" || $page_num eq "") { $id = "$$"; system ("mkdir $scratch ; chmod 755 $scratch "); } # temp files #----------- $lpt_infile = "$scratch/tmpp$id.lpt"; $lpt_outfile = "$scratch/tmpp$id.ps"; $grs_infile = "$scratch/tmpp$id.grs"; $mls_infile = "$scratch/tmpp$id.mls"; $pdb_infile = "$scratch/tmpp$id.pdb"; $plt_infile = "$scratch/tmpp$id.plt"; $tmp_lstfile = "$scratch/tmpp$id.lst"; $tmp_logfile = "$scratch/tmpp$id.log"; $pov_infile = "$scratch/tmpp$id.pov"; $pov_tmpfile = "$scratch/tmpp$id.tpv"; $pov_movfile = "$scratch/tmpp$id.mpv"; $bac_movfile = "$scratch/tmppbac$id.mpv"; $pov_outfile = "$scratch/tmpp$id.tga"; $pov_lstfile = "$scratch/tmpp$id.Lst"; $jpeg_outfile = "$scratch/tmpp$id.jpeg"; $rgb_outfile = "$scratch/tmpp$id.rgb"; $gif_outfile = "$scratch/tmpp$id.gif"; $gif_thumbfile = "$scratch/tmpp$id.Gif"; $animgif_file = "$scratch/tmpp$id.GIF"; $tiff_outfile = "$scratch/tmpp$id.tiff"; $png_outfile = "$scratch/tmpp$id.png"; $mng_outfile = "$scratch/tmpp$id.mng"; $mail_file = "$scratch/tmpp$id.mail"; $mail_mov_file = "$scratch/tmpp$id.Mail"; $tmp_cshfile = "$scratch/tmpp$id.csh"; $kill_cshfile = "$scratch/tmppd$id.csh"; $tmp_subfile = "$scratch/tmpp$id.CSH"; $scratchfile = "$scratch/tmpp$id.tmp"; $pid_file = "$scratch/tmpp$id.pid"; $mpeg_outfile = "$scratch/tmpp$id.mpeg"; $mpeg_lstfile = "$scratch/tmpp$id.LST"; $mpeg_tmp_prms = "$scratch/tmpp$id.prm"; $outofmem_file = "$scratch/tmppoom$id.prm"; $adv_cshfile = "$scratch/tmppadv$id.csh"; $povray_logo = "$Imagedir/povscript_logo.gif"; $molray_logo = "$Imagedir/molray_logo.gif"; $pltpov_logo = "$Imagedir/pltpov_logo.gif"; $demo_image = "$pltpov_logo"; $def_mail_addr = ""; $Guestbook = "http://xray.bmc.uu.se/markh/notes/guestbook/guestbook_molray.html"; $exe_cmd = " "; if ($client eq "pluto") { $exe_cmd = "nice" } if ($client eq "narva") { $mrh_flag = "yes"; $def_mail_addr = "markh\@xray.bmc.uu.se"; $selectall_checked = "CHECKED"; $limit_other_jobs = 4; } if ($client eq "monet") { $gunnar_flag = "yes"; } # Kill current job issued if(substr($qstring,0,4) eq "term"){ $idk = substr($qstring,rindex($qstring,'&term=')+6); if (rindex($idk,'&') > 1) {$idk = substr($idk,0,rindex($idk,'&'))}; print "Content-TYPE: text/html\n\n"; print ""; print "
\n"; print "Killing current POV-Ray job ($idk) ...
\n"; print "This message will self destruct in 3 seconds....
\n"; $kill_cshfile = "$scratch/tmppd$idk.csh"; $cmd = "/bin/csh -f $kill_cshfile"; # print "Cmd : $cmd"; system("$cmd"); # execute file containing povray-process kill commands print "\n"; print ""; print ""; exit; } # General tidy up issued if($qstring eq "Tidy"){ print "Content-TYPE: text/html\n\n"; print ""; print "
\n"; print "Killing outstanding POV-Ray jobs...
\n"; print "Tidying up scratch directory...
\n"; print "rm -rf $scratch/tmpp*
\n"; print "This message will self destruct in 3 seconds....
\n"; system("echo \"ps -jea | grep $id | grep $client | grep -v grep | awk '{print \\\$2}' | xargs kill -9 \" > $scratch/tmpptidy.csh"); # create file containing process kill command system("csh -f $scratch/tmpptidy.csh"); # execute file containing povray-process kill commands system("rm -rf $scratch/tmpp*"); # delete files print "\n"; print ""; print ""; exit; } # Set frames type #---------------- # Frames #------- if ($frames_type eq "0" || $frames_type eq "") { $frames = "yes"; $src_win = "source"; $plp_win = "pltpov"; $pov_win = "povray"; $res_win = "result"; $ani_win = "povray"; $big_win = "bigwin"; $mov_win = "movies"; $adv_win = "advwin"; $adv_win = "pltpov"; } # Separate windows #----------------- if ($frames_type eq "2") { $frames = "no"; $src_win = "source_w"; $plp_win = "pltpov_w"; $pov_win = "povray_w"; $res_win = "result_w"; $ani_win = "povray_w"; $big_win = "bigwin_w"; $mov_win = "movies_w"; $adv_win = "advwin_w"; } # Single window #-------------- if ($frames_type eq "1") { $frames = "no"; $src_win = "_top"; $plp_win = "_top"; $pov_win = "_top"; $res_win = "_top"; $ani_win = "_top"; $big_win = "_top"; $mov_win = "_top"; $adv_win = "_top"; } ############################################################################## # Check script_name specified above is same as parent ############################################################################## $parent_script = "http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}"; if ($parent_script ne $script_name) { print "Content-TYPE: text/html\n\n"; print ""; print "
"; print "!!! MolRay configuration error !!!
"; print "Mismatch between parent script and \"script_name\" variable in program
";
print "Parent script - http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}
";
print "Called script - $script_name
"; print "Call your systems manager and tell him to make variable \"script_name\" truly match the location of the molray perl script."; print ""; exit; } ############################################################################## # Page 0. Startup pages (Pure frames HTML) ############################################################################## if ($page eq "Page0" || $page eq "" || $page eq "Pltp" || $page eq "Mols" || $page eq "Gras" || $page eq "Scri" || $page eq "Ligp") { # Adjust number of windows depending on program ############################################### $First_page = "Pltp0"; $Columns = "400,*,*"; if ($page eq "Mols" || $page eq "Gras" || $page eq "Scri") { $First_page = "$page"."0"; $Columns = "400,*"; } if ($page eq "Ligp") { $First_page = "$page"."0"; $Columns = "400,*"; } if ($frames eq "yes") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOH";