#!/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 "Tidy

\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 "Tidy

\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 "Error

"; 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"; Molray web interface for molecular graphics rendering EOH if ($page ne "Mols" && $page ne "Gras" && $page ne "Scri" && $page ne "Ligp") { print "\n"; } if ($page ne "LigpBBBJUNK") { print "\n"; } print "\n"; } else { $page = $First_page; } } ####################### # Initial plt_pov frame ####################### if ($page eq "Pltp0") { print "Content-TYPE: text/html\n\n"; print ""; ##print ":id: $id :: $idd :f:$frames_type:p:$page:$tmp:$page_num"; if (! -x $povray){ print "Warning - POV-Ray executable not found"; } if (! -x $plt_pov){ print "Warning - Plt_pov executable not found"; } print << "EOHS"; molray molecular graphics web interface

Plt_pov input form
Input O plot file : Select all objects
Help
Demo
Feedback \?
EOHS other_progs (); print ""; } ######################### # Initial molscript frame ######################### elsif ($page eq "Mols0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHM"; molray molecular graphics web interface

Molscript input form

Input Molscript file :

Input PDB file :
Help
Feedback \?
EOHM other_progs (); print ""; } ######################### # Initial GRASP frame ######################### elsif ($page eq "Gras0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHM"; molray molecular graphics web interface

GRASP input form

Input GRASP file :
Help
Feedback \?
EOHM other_progs (); print ""; } ######################### # Initial LIGPLOT frame ######################### elsif ($page eq "Ligp0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHM"; molray molecular graphics web interface

Ligplot input form

Input Ligplot PDB file :

Ligand residue numbers (range)

Help
Feedback \?
EOHM other_progs (); print ""; } ######################### # Initial Script frame ######################### elsif ($page eq "Scri0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHM"; molray molecular graphics web interface
Input POV-Ray input file :
Help
Feedback \?
EOHM other_progs (); print ""; } ###################### # Initial povray frame ###################### elsif ($page eq "Povr0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHP"; molray molecular graphics web interface

POV-Ray input

$version
O, plt_pov and molray were written at The Department of Cell and Molecular Biology, Uppsala, Sweden.
All ray tracing is performed by POV-Ray ®, written by the POV-Team.
Spline function macros by Chis Colefax. EOHP if ($public_flag eq "yes") { print << "EOHP2";
Computing power is provided by an Alpha 500 running OSF, kindly loaned by COMPAQ ®. EOHP2 } if ($public_flag ne "noOOOO") { print << "EOHP2";
News

New advanced movie features. 5-Feb-02
Depth cueing and png support added 11-Mar-03

Please let us know what you think/like/dislike about Molray. Thanks! Mail us
  EOHP2 } print << "EOHP3";

EOHP3 } #10-Nov-2001 #Simple support for Molscript execution added. See help file for details. #

####################### # Initial result frame ####################### elsif ($page eq "Resu0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHR"; molray molecular graphics web interface

Graphics output

EOHR } ####################### # Second plt_pov frame ####################### elsif ($page eq "Plpv0") { print "Content-TYPE: text/html\n\n"; print ""; print << "EOHF"; molray molecular graphics web interface

Plt_pov output

EOHF } ############################################################################## # Page 1. Runs plt_pov once and presents user with possible objects ############################################################################## elsif ($page eq "Page1") { # Write out uploaded file (This is rather messy. Sorry.) #------------------------------------------------------- $upload = "yes"; open (PLT,">$plt_infile"); $count == 1; while ($line = ) { $count++; if ($line =~ /Content-Disposition/) {$upload = "no"}; if ($prev_line =~ /Content-Type: text\/html/) {$upload = "yes"}; if ($prev_line =~ /infile/) {$upload = "yes"}; if ($line =~ /----/) {next}; if (length($line) == 0) {next}; if ($getprm2 eq "yes" && length($line) > 2) {$skipsel = $line}; $getprm2 = "no"; if ($getprm eq "yes") {$getprm2 = "yes"}; $getprm = "no"; if ($line =~ /skipsel/) {$getprm = "yes"}; if ($upload eq "yes") {print (PLT $line)}; $prev_line = $line; } close(PLT); ##print ""; ##exit; # pickup skip_selection flag from last page #------------------------------------------ chop($skipsel); chop($skipsel); if ($skipsel eq "on") { $page = "Page2"; goto SKIPSEL; } # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print ""; print << "EOH1"; Plt_pov submission form EOH1 if ($ENV{'CONTENT_LENGTH'} < 200) { print "

Error - empty plot file.

"; exit; } # Execute plt_pov to find objects #-------------------------------- $lst_command = "$plt_pov -mega -in=$plt_infile -out=/dev/null -list=$tmp_lstfile > /dev/null "; system("$lst_command"); # And look at the results dropped into the temp file #--------------------------------------------------- open (LST,"$tmp_lstfile"); read (LST,$list_string,10000); close(LST); ##system("rm -f $tmp_lstfile"); # Make into array #---------------- @obj_array = split(/\n/,$list_string); # Make new form to select objects #-------------------------------- print << "EOF1";

\n
Plt_pov selection
Help
Select objects :

EOF1 # Make a tickbox for each object, and then some POV-Ray options #-------------------------------------------------------------- print " All objects
\n"; print " All Stick objects
\n"; print " All CPK objects
\n"; print " All Cartoon objects
\n"; print " All Notes objects
\n"; print "

"; $icount = 0; foreach $obj (@obj_array) { $icount++; $objnam = $obj; $objnam =~ s/\&..\=/ /; $objnam =~ s/\(.*\)//; $objnam =~ s/ *//g; $obj =~ s/\&..\=/ /; $obj =~ s/ .*\(/ \(/g; $obj =~ s/ / /; $obj =~ s/ \(/<\/B> \(/; if ($objnam eq "notobj") {next}; print "$obj
\n"; } if ($icount <= 0) { print "

Error - No objects found.
Probably not a plot file.

"; $disk_space = `df $scratch_dev | grep -v Mount | cut -c 42-53`; if ($disk_space < 100) {print "

System tmp disk seems to be full. Mail administrator.

";} print "

"; exit; } print << "EOF17"; \n EOF17 if ($public_flag ne "an_unlikely_string") { print << "EOF18"; Transparent surfaces
Depth cueing
EOF18 } print << "EOF19";
Help
EOF19 print ""; print "
\n"; print ""; ############################################################################## # Page 2. Runs pltpov for real ############################################################################## } elsif ($page eq "Page2") { SKIPSEL: # Interpret form data pairs #-------------------------- @obj_pairs = &User_Data_Array(); $numobj = scalar(@obj_pairs); # Step through the options. Spot special options, rest are objects #----------------------------------------------------------------- $cmd_string = "$plt_pov -mega -povinc=\\\"$Pov_incl_dir\\\" -obj=\\\" "; for ($iobj=0;$iobj<$numobj;$iobj++) { $oname = $obj_pairs[$iobj]; $ovalue = $obj_pairs[$iobj]; $oname =~ s/=.*//; $oname =~ s/\%24/\$/; $ovalue =~ s/.*=//; if ($oname eq "plt_infile") {$plt_infile = $ovalue} elsif ($oname eq "tmp_lstfile") {$tmp_lstfile = $ovalue} elsif ($oname eq "debug") {$debug = $ovalue} elsif ($oname eq "transmap") {$transmap = $ovalue} elsif ($oname eq "reset_prms") {$reset_prms = $ovalue} elsif ($oname eq "depth_cue") {$depth_cue = $ovalue} else { $cmd_string = "$cmd_string $oname"; $obj_found = "yes"; } } if ($skipsel eq "on") { $cmd_string = "$plt_pov -mega -povinc=\\\"$Pov_incl_dir\\\" -obj=\\\"allting"; } $depth_cue_flag = ""; if ($depth_cue ne "Off") {$depth_cue_flag = "-depth_cue = $depth_cue"}; $trans_flag = " "; if ($transmap eq "on") {$trans_flag = "-trans"}; ## BUG ? $cmd_string = "$cmd_string \\\" $trans_flag > /dev/null"; $cmd_string = "$cmd_string \\\" $trans_flag "; $plt_string = "$cmd_string -in=$plt_infile -out=$pov_infile $depth_cue_flag -complete > /dev/null"; # Execute plt_pov #-------------------------------- system("$plt_string"); # And look at the results dropped into the temp file #--------------------------------------------------- open (LST,"$tmp_lstfile"); read (LST,$list_string,10000); close(LST); ##system("rm -f $tmp_lstfile"); # Send HTML header #----------------- # The idea here was to leave the old table intact if 'not_reset' was chosen, # but it seems that something has to be sent to the window specified by the form, # and I don't know how to not trash the old page. Maybe one day. if ($reset_prms ne "on") { print "Content-TYPE: text/html\n\n"; print << "EOH1"; POV-Ray submission form EOH1 if ($debug eq "on") { print "$plt_string
"; } # Setup POV-Ray options #---------------------- $plt_pov_flag = "yes"; pov_opts(); } exit; } ############################################################################## # Page 3. Runs POV-Ray for anything ############################################################################## elsif ($page eq "Page3") { $alias = " "; $alias_flag = " "; $debug = " "; $demo_flag = " "; $obj_found = " "; # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print ""; print << "EOH2"; POV-Ray output
POV-Ray output
EOH2 # Interpret form data pairs #-------------------------- @obj_pairs = &User_Data_Array(); $numobj = scalar(@obj_pairs); # Step through the options. Spot special options, rest are objects (Pov-Ray page) #----------------------------------------------------------------- ##$cmd_string = "$plt_pov -obj=\\\" "; for ($iobj=0;$iobj<$numobj;$iobj++) { $oname = $obj_pairs[$iobj]; $ovalue = $obj_pairs[$iobj]; $oname =~ s/=.*//; $oname =~ s/\%24/\$/; $ovalue =~ s/.*=//; if ($oname eq "plt_infile") {$plt_infile = $ovalue} elsif ($oname eq "width") {$width = $ovalue} elsif ($oname eq "cam_dist") {$cam_dist = $ovalue} elsif ($oname eq "quality") {$quality = $ovalue} elsif ($oname eq "alias") {$alias = $ovalue} elsif ($oname eq "stereo") {$stereo = $ovalue} elsif ($oname eq "perspective") {$perspective = $ovalue} elsif ($oname eq "perspangle") {$perspangle = $ovalue} elsif ($oname eq "demo_flag") {$demo_flag = $ovalue} elsif ($oname eq "debug") {$debug = $ovalue} elsif ($oname eq "monitor") {$monitor = $ovalue} elsif ($oname eq "blackground") {$blackground = $ovalue} elsif ($oname eq "shadowless") {$shadowless = $ovalue} elsif ($oname eq "transparent") {$transparent = $ovalue} elsif ($oname eq "map_thick") {$map_thick = $ovalue} elsif ($oname eq "texture") {$texture = $ovalue} elsif ($oname eq "walldist") {$walldist = $ovalue} elsif ($oname eq "transmap") {$trans_map_val = $ovalue} elsif ($oname eq "mail_flag") {$mail_flag = $ovalue} elsif ($oname eq "mail_addr") {$mail_addr = $ovalue} elsif ($oname eq "tmp_lstfile") {$tmp_lstfile = $ovalue} elsif ($oname eq "xtrans") {$xtrans = $ovalue} elsif ($oname eq "ytrans") {$ytrans = $ovalue} elsif ($oname eq "ztrans") {$ztrans = $ovalue} elsif ($oname eq "xrot") {$xrot = $ovalue} elsif ($oname eq "yrot") {$yrot = $ovalue} elsif ($oname eq "zrot") {$zrot = $ovalue} elsif ($oname eq "Rmap") {$Rmap = $ovalue} elsif ($oname eq "Gmap") {$Gmap = $ovalue} elsif ($oname eq "Bmap") {$Bmap = $ovalue} elsif ($oname eq "mapcol") {$mapcol = $ovalue} elsif ($oname eq "Rback") {$Rback = $ovalue} elsif ($oname eq "Gback") {$Gback = $ovalue} elsif ($oname eq "Bback") {$Bback = $ovalue} elsif ($oname eq "backcol") {$backcol = $ovalue} elsif ($oname eq "stereo_sep") {$stereo_sep = $ovalue} elsif ($oname eq "plt_pov_flag") {$plt_pov_flag = $ovalue} elsif ($oname eq "aspect_ratio") {$aspect_ratio = $ovalue} elsif ($oname eq "id2") {$id2 = $ovalue} else { } } # decode slashes in plt_filename, manipulate other params #-------------------------------------------------------- $plt_infile =~ s/%2F/\//g; $tmp_lstfile =~ s/%2F/\//g; if ($width > $limit_pixels) { $width = $limit_pixels; $too_wide_flag = "yes"; } $height = $width; if ($aspect_ratio ne "") {$height = int($width/$aspect_ratio)}; if ($alias eq "on") {$alias_flag = "+a"}; if ($thumb_size > $width) {$thumb_size = $width}; # add local pid to final image name to avoid caching problem #----------------------------------------------------------- #$pov_infile =~ s/\.([^.]*$)/$$\.$1/; $pov_outfile =~ s/\.([^.]*$)/$$.$1/; $jpeg_outfile =~ s/\.([^.]*$)/$$\.$1/; $rgb_outfile =~ s/\.([^.]*$)/$$\.$1/; $gif_outfile =~ s/\.([^.]*$)/$$\.$1/; $gif_thumbfile =~ s/\.([^.]*$)/$$\.$1/; $tiff_outfile =~ s/\.([^.]*$)/$$\.$1/; $png_outfile =~ s/\.([^.]*$)/$$\.$1/; $idd = $id.$$; # Assemble command strings #========================= if ($transmap eq "on") {$cmd_string = "$cmd_string -trans "}; $filter_string = " "; $transp_string = " "; $mail_string = " "; # Assemble sed commands #====================================================================== # Start sed filter command #------------------------- $filter_string = "cat $pov_infile "; if ($cam_dist ne "From file") { $filter_string = "$filter_string | sed /\"Mray_CamDist\"/s/\\^\\.\\*/\"\#declare Camera_Distance \= $cam_dist \\; \\/\\/Mray_CamDist\"/"; } if ($blackground eq "on") { $filter_string = "$filter_string | sed /\"Mray_Bgrnd\"/s/\\^\\.\\*/\"background \\{Black\\}\"/"; } if (defined $map_thick) { $filter_string = "$filter_string | sed /\"Mray_LinWid\"/s/\\^\\.\\*/\"#declare Line_Width = $map_thick; \\/\\/Mray_LinWid \"/"; $dot_thick = $map_thick*2; $filter_string = "$filter_string | sed /\"Mray_HbDot\"/s/\\^\\.\\*/\"#declare Hb_Dot_Size = $dot_thick; \\/\\/Mray_HbDot \"/"; } $filter_string = "$filter_string | sed /\"Mray_WallDist\"/s/\\^\\.\\*/\"#declare Wall_Dist = -$walldist \\; \\/\\/Mray_WallDist\"/"; if ($texture eq "Plain") { $filter_string = "$filter_string | sed /\"Mray_Plane\"/s/\\^\\.\\*/\"plane \\{z, Wall_Dist pigment \\{color rgb \\<$Rback $Gback $Bback\\> \\}\\} \\/\\/Mray_Plane \"/"; } elsif ($texture ne "None") { $filter_string = "$filter_string | sed /\"Mray_Plane\"/s/\\\\/\\\\/\\\\/\\\\///"; $filter_string = "$filter_string | sed /\"Mray_Plane\"/s/White_Marble/$texture/"; } if ($shadowless eq "on") { $filter_string = "$filter_string | sed /\"Mray_Light\"/s/\\}/\" shadowless \\}\"/"; } if (defined $trans_map_val) { $filter_string = "$filter_string | sed /\"Mray_MapT\"/s/0.5/$trans_map_val/"; } if ($stereo eq "on") { $filter_string = "$filter_string | sed /\"Mray_SterOn\"/s/\\^\\.\\*/\"#declare Stereo_On = yes \\/\\/Mray_SterOn\"/"; $filter_string = "$filter_string | sed /\"Mray_Lcol1\"/s/\\^\\.\\*/\"#declare lcol1 = color red 0.5 green 0.5 blue 0.5 \\/\\/Mray_Lcol1\"/"; $filter_string = "$filter_string | sed /\"Mray_Lcol2\"/s/\\^\\.\\*/\"#declare lcol2 = color red 0.25 green 0.25 blue 0.25 \\/\\/Mray_Lcol2\"/"; } if ($perspective eq "on") { $filter_string = "$filter_string | sed /\"Mray_Ortho\"/s/\\^\\.\\*/\"angle $perspangle \\/\\/Mray_Ortho\"/"; } else { $filter_string = "$filter_string | sed /\"Mray_Ortho\"/s/\\^\\.\\*/\"orthographic \\/\\/Mray_Ortho\"/"; } # Start sed transform command #---------------------------- $transform_string = "cat $pov_tmpfile "; $transform_string = "$transform_string | sed /\"Mray_Xtrans\"/s/\\^\\.\\*/\"translate x\*$xtrans \\/\\/Mray_Xtrans\"/"; $transform_string = "$transform_string | sed /\"Mray_Ytrans\"/s/\\^\\.\\*/\"translate y\*$ytrans \\/\\/Mray_Ytrans\"/"; $transform_string = "$transform_string | sed /\"Mray_Ztrans\"/s/\\^\\.\\*/\"translate z\*$ztrans \\/\\/Mray_Ztrans\"/"; $transform_string = "$transform_string | sed /\"Mray_Xrot\"/s/\\^\\.\\*/\"rotate x\*$xrot \\/\\/Mray_Xrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Yrot\"/s/\\^\\.\\*/\"rotate y\*$yrot \\/\\/Mray_Yrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Zrot\"/s/\\^\\.\\*/\"rotate z\*$zrot \\/\\/Mray_Zrot\"/"; $transform_string = "$transform_string | sed /\"Mray_SterSep\"/s/\\^\\.\\*/\"#declare Sep_Stereo \= $stereo_sep\; \\/\\/Mray_SterSep\"/"; # Start sed colour command for map #--------------------------------- $colour_string = "cat $pov_tmpfile "; if ($mapcol eq "on") { $colour_string = "$colour_string | sed /rgbt\\.\\*Plastic_Lines/s/rgbt\\.\\*Trans/\"rgbt \\<$Rmap $Gmap $Bmap Trans\"/"; $colour_string = "$colour_string | sed /rgb[\\^t\\]\\.\\*Plastic_Lines/s/rgb\\.\\*\\>/\"rgb \\<$Rmap $Gmap $Bmap\\>\"/"; $colour_string = "$colour_string | sed /rgbt\\.\\*Plastic_Maps/s/rgbt\\.\\*Trans/\"rgbt \\<$Rmap $Gmap $Bmap Trans\"/"; $colour_string = "$colour_string | sed /rgb[\\^t\\]\\.\\*Plastic_Maps/s/rgb\\.\\*\\>/\"rgb \\<$Rmap $Gmap $Bmap\\>\"/"; } # sed command for metallic colours (red value greater than 1.0) #-------------------------------------------------------------- $colour_string = "$colour_string | sed /'rgbt* *< *1.[^0][^0]'/s/Plastic/Metallic/"; $colour_string = "$colour_string | sed /'rgbt* *< *1.[^0][^0]'/s/'rgbt* *< *'/\\&666/"; $colour_string = "$colour_string | sed /'rgbt* *< *6661'/s/6661./0./"; # And for background (overridden by texture) #------------------------------------------- $colour_string = "$colour_string | sed /\"Mray_Bgrnd\"/s/\\^\\.\\*/\"background \\{color rgb \\<$Rback $Gback $Bback\\>\\} \\/\\/Mray_Bgrnd\"/"; $Rbacko = int($Rback*255); $Gbacko = int($Gback*255); $Bbacko = int($Bback*255); ### Agghh. I was hoping to set the transparent-gif key colour to background colour here ### but since POV-Ray expresses colours as floats, it is hard to predict the integer ### RGBs that will result, and so we can't trust them for key colour later. Pity. ### So we always antialias against white, and the next line shouldn't be uncommented. ###$transgif_prms = " -rgb $Rbacko $Gbacko $Bbacko"; if ($transparent eq "on" && (-x $transgif_prog)) { $filter_string = "$filter_string | sed /\"Mray_Bgrnd\"/s/\\^\\.\\*/\"background \\{Very_Light_Purple\\} \\/\\/Mray_Bgrnd\"/"; $transp_string = "$transgif_prog $transgif_prms -o $scratchfile $gif_outfile; cp $scratchfile $gif_outfile; $transgif_prog $transgif_prms -o $scratchfile $gif_thumbfile ; cp $scratchfile $gif_thumbfile"; } # Calculate tga file size #------------------------- $pred_file_size = $width * $height * 3; # Set batch flag #--------------- if ($mail_flag eq "on" && index($remote_cmd,"qsub") != -1) { $batch_flag = "Batch"; } else { $batch_flag = "Online"; } $frame_start = 0; $frame_end = 0; # Tell trustees where to find file #--------------------------------- $gif_outurl = $gif_outfile; $gif_outurl =~ s#$scratch_dev/#$scratch_url/#; if (($Trusted_flag eq "yes") || ($public_flag ne "yes")) { print "$gif_outurl
"; } # Check out how busy machine is #------------------------------ if ($batch_flag eq "Online") { $job_count_string = `ps aux | grep povray | grep -v grep | wc`; $job_count_string =~ s/.\s*//; ($job_count,) = split(/\s+/,$job_count_string,2); print "
Number of other POV-Ray jobs running : $job_count
\n"; # Abort if too many other jobs, and log if ($job_count > $limit_other_jobs) { print "

Error - Server is overloaded, please try later...."; open (LOG,">>$Overloadlog"); $string = sprintf("%5d %2s%1d %2s %3s %21s %s\n",$width,"+q",$quality,$alias_flag," ",$date,$ENV{'REMOTE_HOST'}); print (LOG $string); close (LOG); exit; } } # Log still usage #---------------- $mail_addr =~ s/\%40/\@/; if (!$mrh_flag) { open (LOG,">>$Usagelog"); $string = sprintf("%5d %2s%1d %2s %3s %21s %s %s %s %d\n",$width,"+q",$quality,$alias_flag," ",$date,$ENV{'REMOTE_HOST'},$mail_addr," ",$job_count); print (LOG $string); } close (LOG); # Make equivalent URL for output file (repeated below) # ---------------------------------------------------- $pov_outurl = $pov_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; # Arrange for mailing if chosen #------------------------------ $| = 1; if ($mail_flag eq "on") { chmod (0777, $mail_file); open (CSH,">$mail_file"); print (CSH "Subject: Molray image results\n"); print (CSH "From: Stills\@molray.com\n"); print (CSH "Your POV-Ray output files will be available for some time at :\n\n"); $pov_outurl = $pov_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "TGA : $pov_outurl\n"); $pov_outurl = $gif_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "GIF : $pov_outurl\n"); $pov_outurl = $jpeg_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "JPEG : $pov_outurl\n"); $pov_outurl = $rgb_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "RGB : $pov_outurl\n"); $pov_outurl = $tiff_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "TIFF : $pov_outurl\n"); $pov_outurl = $png_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "PNG : $pov_outurl\n"); $pov_outurl = $pov_tmpfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "POV-Ray input file : $pov_outurl\n"); close(CSH); $mail_addr =~ s/\%40/\@/; $mail_string = "/usr/bin/mail $mail_addr < $mail_file"; $fail_string = "/usr/bin/Mail -s \"Molray job failed\" $mail_addr < $mail_file"; $exe_cmd = $remote_cmd; } else { print "Your results are on their way....
"; } if ($too_wide_flag eq "yes") {print "Warning, your illegally-wide image has been shrunk down to ".$width." pixels
"}; $| = 0; # End sed commands #------------------ $filter_string = "$filter_string > $scratchfile ; cp $scratchfile $pov_tmpfile"; $transform_string = "$transform_string > $scratchfile ; cp $scratchfile $pov_tmpfile"; $colour_string = "$colour_string > $scratchfile ; cp $scratchfile $pov_tmpfile"; #$pov_string = "$povray +ft +i $pov_tmpfile +o $pov_outfile +w$width +h$height +q$quality $alias_flag >& $pov_lstfile"; $pov_string = "$povray +ft +i $pov_tmpfile +o $pov_outfile +w$width +h$height +q$quality $alias_flag"; $geom = $thumb_size."x".$thumb_size; $convert_string = "$tga_to_other -quality 90 $pov_outfile $jpeg_outfile ; $tga_to_other $pov_outfile $rgb_outfile ; $tga_to_other -geometry $geom $pov_outfile $gif_thumbfile ; $tga_to_other $pov_outfile $tiff_outfile ; $tga_to_png $pov_outfile $png_outfile ; $tga_to_other $pov_outfile $gif_outfile"; $tidy_string = "rm -f $tmp_lstfile"; $cmd_string = "$plt_string; $pov_string; $tidy_string $tmp_cshfile"; $final_tidy = "rm -f $scratch/tmpp$id* $scratch/tmpp$id* *.GIF"; # Write out still commands to shell script #----------------------------------------- chmod (0777, $tmp_cshfile); open (CSH,">$tmp_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "set echo\n"); if ($public_flag ne "yesORnoDISABLED") { print (CSH "limit datasize unlimited \n"); print (CSH "limit memoryuse unlimited \n"); # print (CSH "limit vmemoryuse unlimited \n"); } #print (CSH "cp $pov_inc/*.inc ./\n"); print (CSH "##Mray_batch cp movie.pov $pov_infile\n"); print (CSH "#\n$filter_string\n"); print (CSH "#\n$transform_string\n"); print (CSH "#\n$colour_string\n"); print (CSH "#\n$pov_string\n"); print (CSH "#\n$convert_string\n"); print (CSH "#\n$transp_string\n"); print (CSH "#\nif -r $pov_outfile then\n"); print (CSH " $mail_string\n"); print (CSH "else\n"); print (CSH " $fail_string\n"); print (CSH " unset echo\n"); print (CSH " set err = \`grep \"Out of memory\" $tmp_logfile\`\n"); print (CSH " if (\! \$status) touch $outofmem_file\n"); print (CSH " set echo\n"); print (CSH " $fail_string\n"); print (CSH "endif\n"); print (CSH "#\n$tidy_string\n"); if (($mrh_flag ne "yes_anything") && ($gunnar_flag ne "yes")) { print (CSH "csh\n"); print (CSH "echo $final_tidy | at now + $tidy_time minutes\n"); } close(CSH); chmod (0511, $tmp_cshfile); if ($debug eq "on") { print "


"; open (CSH,"$tmp_cshfile"); while ($line = ) { print "$line
"; } close(CSH); #print "

Exec command debug :
"; #print "%$plt_string
%$filter_string
%$pov_string
%$transp_string
%$convert_string
%$transp_string
%$tidy_string

"; print "


"; } # create file containing process kill command system("echo \"ps -jea | grep povray | grep $client | grep $id | grep -v grep | awk '{print \\\$2 \\\" \\\" \\\$3}' | xargs kill -9 \" > $kill_cshfile"); # Check Povray is really running if (! -x $povray) { print "Demo image due to POV-Ray missing
\n"; exit; } # Run the programs #----------------- if ($monitor eq "on") {MonitorGrowth($pov_outfile, $pred_file_size, $pov_outurl, $batch_flag, $frame_start, $frame_end)}; if ($batch_flag eq "Batch") { if ($debug eq "on") { print "
"; print "
$exe_cmd $tmp_cshfile 2> $tmp_logfile
\n"; } system("$exe_cmd $tmp_cshfile 2> $tmp_logfile"); } else { system("$exe_cmd $tmp_cshfile 2> $tmp_logfile"); } if ($mail_flag eq "on") { print "
The location of your output will be mailed to you.
"; exit; } if (! -e $pov_tmpfile) { print "No POV-Ray input file
"; print "Failure during pre-processing
"; print "

Check out the log file

"; exit; } elsif (-z $pov_tmpfile) { print "Empty POV-Ray input file
"; print "Failure probably during sed operations
"; print "

Check out the log file

"; exit; } if (-e $pov_outfile && (! -e $gif_outfile)) { print "

Conversion of your targa file failed (too big ?)"; print "
Pick up the Targa file and convert it elsewhere.

"; } if (! -e $pov_outfile) { print "No output TARGA file
"; print "Failure probably before/during POV-Ray execution
"; ## exit; if (-e $outofmem_file) { print "

Ran out of memory - plot is too complex
"; system ("rm $outofmem_file"); } else { print "

Check out the log file

"; } } elsif (-z $pov_outfile) { print "Empty TARGA file
"; print "Failure probably during POV-Ray execution
"; print "

Check out the log file

"; print << "EOF38";

POV CSH
EOF38 exit; } # Write some blurb #----------------- print << "EOF3"; \n

EOF3 print << "EOF344"; EOF344 if ($plt_pov_flag eq "yes") { print "" } print << "EOF37"; EOF37 print << "EOF38"; EOF38 print "
Output files : HelpMake movie
GIF JPEG TIFF PNG RGB POV
"; # Some more tidying. BUG, won't return.... #------------------ $final_tidy = "rm -f $scratch/tmpp$id* $scratch/tmpp$id* *.GIF"; if (($mrh_flag ne "yes") && ($gunnar_flag ne "yes")) { system("echo $final_tidy | at now + $tidy_time minutes"); } } ############################################################################### # Page Mols1. Runs Molscript ############################################################################### elsif ($page eq "Mols1") { $cam_dist = "100.0"; # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print ""; print << "EOH11"; Molscript POV-Ray

Molscript POV-Ray

EOH11 # Write out uploaded file #------------------------ if ($ENV{'CONTENT_LENGTH'} < 200) { print "

Error - empty molscript file.

"; exit; } open (MLS,">$mls_infile"); open (PDB,">$pdb_infile"); $count = 1; while ($line = ) { # Read through file again to get everything else $count++; if ($count < 4) {next}; if ($line =~ /----/) {next}; $line =~ s/^ +//; # Remove leading spaces if ($line =~ /pdbfile/) { # Note when PDB file starts, and extract name $pdb_flag = 1; $pdb_name = $line; $pdb_name =~ s/^.*filename="//; $pdb_name =~ s/".*$//; }; if ($line =~ /Content-/) {next}; # Skip headers if ($line =~ /^\s*read\smol /) { # Play with filename in molscript file $line =~ s/"/"$scratch\/tmpp$id\_/; # Append process id $linec = $line; }; if ($line =~ /^\s*area/) { # Play with areas $t = substr($line,5); @geom = split(/ /,substr($line,5)); $aspect_ratio = ($geom[3]-$geom[1])/($geom[2]-$geom[0]); }; if (!$pdb_flag) { print (MLS $line); # First (Molscript) file } else { print (PDB $line); # Second (PDB) file } } close(MLS); close(PDB); # Create command strings #----------------------- # Fix up Windows crap $newinfile = $pdb_name; $newinfile =~ s/^.*(NTNT)/$1/; # filename is prefixed with NTNT to cope with NT $oldfile = "$scratch/tmpp$id\_$pdb_name"; $newfile = "$scratch/tmpp$id\_$newinfile"; chomp($oldfile); $wind_command = "mv $oldfile $newfile"; # remove windows crap #print "$cmd
"; #system("$windcmd"); # NB We alternate filenames here. Need copy for even number of lines $mols_command0 = "mv $pdb_infile $scratch/tmpp$id\_$pdb_name"; $mols_command = "$molscript -povray < $mls_infile > $pov_infile"; #$mols_command2 = "rm $scratch/tmpp$id\_$pdb_name"; $mols_string1 = "cat $pov_tmpfile > $pov_infile"; # Disabling this until I can extract real camera distance #$mols_string1 = "cat $pov_tmpfile | sed /camera/s/\"100.00\"/\"Camera_Distance \"/ > $pov_infile"; $mols_string2 = "cat $pov_infile | sed /background/s/\\}/\"\\} \\/\\/ Mray_Bgrnd\"/ > $pov_tmpfile "; $mols_string3 = "cat $pov_tmpfile | sed /background/s/\"0.000\"/\"1.0\"/g > $pov_infile "; $mols_string4 = "cat $pov_infile | sed /light_source/s/\"rgb .5\"/\"rgb 1.0\"/g > $pov_tmpfile "; $mols_string5 = "cat $pov_tmpfile | sed /\"right x }\"/s/\"right x\"/\"right x orthographic\"/g > $pov_infile "; $mols_string6 = "cat $pov_infile | sed /RFont/s/timrom/\\\\/home\\\\/markh\\\\/povray\\\\/timrom/g > $pov_tmpfile "; $mols_string7 = "cat $pov_tmpfile | sed /GFont/s/symbol/\\\\/home\\\\/markh\\\\/povray\\\\/symbol/g > $pov_infile "; #$mols_string7 = "cat $pov_tmpfile > $pov_infile "; # Execute script #--------------- chmod (0777, $tmp_cshfile); open (CSH,">$tmp_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "#set echo\n"); print (CSH "$mols_command0\n"); print (CSH "$wind_command\n"); print (CSH "$mols_command\n"); print (CSH "cat << EOF | cat - $pov_infile > $pov_tmpfile\n"); print (CSH "#declare Camera_Distance = 100.0 //Mray_CamDist\n"); print (CSH "#\n"); print (CSH "EOF\n"); print (CSH "$mols_string1\n"); print (CSH "$mols_string2\n"); print (CSH "$mols_string3\n"); print (CSH "$mols_string4\n"); print (CSH "$mols_string5\n"); print (CSH "$mols_string6\n"); print (CSH "$mols_string7\n"); ##print (CSH "cp $pov_tmpfile $pov_infile \n"); close(CSH); chmod (0511, $tmp_cshfile); system("$tmp_cshfile 2> $tmp_logfile"); # Setup POV-Ray options #---------------------- pov_opts(); } ############################################################################### # Page Gras1. Runs Grasp surfout ############################################################################### elsif ($page eq "Gras1") { # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print ""; print << "EOH11"; Grasp POV-Ray

Grasp POV-Ray

EOH11 # Write out uploaded file #------------------------ if ($ENV{'CONTENT_LENGTH'} < 200) { print "

Error - empty grasp file.

"; exit; } open (GRS,">$grs_infile"); $count == 1; while ($line = ) { $count++; if ($count < 4) {next}; if ($line =~ /----/) {next}; print (GRS $line); } close(GRS); # Execute surfout via shell script #--------------------------------- $grs_string = "$surfout $grs_infile"; chmod (0777, $tmp_cshfile); open (CSH,">$tmp_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "$grs_string\n"); print (CSH "povray3\n"); print (CSH "$pov_infile"); close(CSH); chmod (0511, $tmp_cshfile); system("$tmp_cshfile 2> $tmp_logfile"); # Offer POV-Ray input file #------------------------- print "
POV-Ray input file here

"; # Setup POV-Ray options #---------------------- pov_opts(); } ############################################################################### # Page Ligp1. Runs Ligplot ############################################################################### elsif ($page eq "Ligp1") { # Send HTML header #----------------- $| = 1; print "Content-TYPE: text/html\n\n"; print ""; print << "EOH11"; Ligplot

Ligplot output

Your output is on its way...

EOH11 # Write out uploaded file, and look for resnum tagged on end #----------------------------------------------------------- if ($ENV{'CONTENT_LENGTH'} < 200) { print "

Error - empty PDBank file.

"; exit; } $upload = "yes"; open (LPT,">$lpt_infile"); $count == 1; while ($line = ) { $count++; if ($count < 4) {next}; if ($line =~ /----/) {next}; if ($line =~ /Content-Disposition/) {$upload = "no"}; if ($upload eq "yes") {print (LPT $line)}; $prev_line = $line; } close(LPT); if ($count < 12) { print "Warning - Tiny PDB file.
"; print "Probably didn't really exist...

"; exit; } $| = 0; # pickup resnum from last line of file and remove embedded CR #------------------------------------------------------------ $resnum = $prev_line; chop($resnum); chop($resnum); $resnum =~ s/-/ /; $resnum =~ s/:/ /; $lpt_infile =~ s/$scratch_dev\/$client\///; $tmp_lstfile =~ s/$scratch_dev\/$client\///; $lpt_outfile =~ s/$scratch_dev\/$client\///; # Execute ligplot via shell script #--------------------------------- $lpt_string = "$ligplot $lpt_infile $resnum > $tmp_lstfile"; $final_tidy = "rm -f $scratch/*.log $scratch/ligplot*"; if (($mrh_flag ne "yes") && ($gunnar_flag ne "yes")) { system("echo $final_tidy | at now + $tidy_time minutes"); } chmod (0777, $tmp_cshfile); open (CSH,">$tmp_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "set echo\n"); print (CSH "cd $scratch_dev\/$client\n"); print (CSH "rm $lpt_outfile\n"); print (CSH "setenv ligdir $ligplotdir ; setenv hbdir $ligplotdir\n"); print (CSH "$lpt_string\n"); print (CSH "cp ligplot.ps $lpt_outfile ; rm ligplot.ps\n"); #print (CSH "convert ligplot.ps $lpt_outfile \n"); print (CSH "$final_tidy\n"); close(CSH); chmod (0511, $tmp_cshfile); system("$tmp_cshfile 2> $tmp_logfile"); if (! -e "$scratch_dev/$client/$lpt_outfile") { print "No PostScript output file

"; print "Failure during processing, check ligand residue numbers exists.
"; exit; } # Offer Postscript file #------------------------- print "
Ligplot output PS file

"; #print "
Ligplot output PS file

"; } ############################################################################### # Page Scri1. Reads POV-Ray file directly ############################################################################### elsif ($page eq "Scri1") { # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print ""; print << "EOH12"; Direct POV-Ray input EOH12 # Write out uploaded file #------------------------ if ($ENV{'CONTENT_LENGTH'} < 200) { print "

Error - empty POV-Ray file.

"; exit; } open (PIN,">$pov_infile"); $count == 1; while ($line = ) { $count++; if ($count < 4) {next}; if ($line =~ /----/) {next}; print (PIN $line); if ($line =~ /Mray/) {$plt_pov_flag = "yes"} } close(PIN); # Setup POV-Ray options #---------------------- pov_opts(); ############################################################################## # Movi1 Sets up movie ############################################################################## } elsif ($page eq "Movi1") { $def_yrot_start = -20.0; $def_yrot_end = 20.0; # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print << "EOH99"; Movie Setup EOH99 # Find any morph frames to set default steps, and check for orthographic set on #------------------------------------------------------------------------------ $morph_flag = "no"; $ortho_flag = "no"; $perspangle_flag = "no"; $perspective_checked = "CHECKED"; open (POV,"$pov_tmpfile"); while ($line = ) { if ($line =~ /Mray_FM/) { ($def_steps) = $line =~ /FM.*fm(.{1,2}).*$/; $morph_flag = "yes"; } if ($line =~ /orthographic/) { $ortho_flag = "yes"; $perspective_checked = " "; } if ($line =~ /Mray_Ortho/) { if ($line =~ /angle/) { $perspangle_flag = "yes"; } } } close(POV); $rock_checked = "CHECKED"; $pendulum_checked = "CHECKED"; if ($morph_flag eq "yes") { $def_yrot_start = "0.0"; $def_yrot_end = "0.0"; $rock_checked = " "; $pendulum_checked = " "; } print << "EOH100";

\n EOH100 if ($mrh_flag eq "yes" || $mrh_flag ne "yes") { print ""; } if (! -x $animgif_prog) { print "Warning : $animgif_prog program missing\n"; exit; } print << "EOH110";
Movie Params
In-going POV-Ray input file here
Translation :
X Y Z Start
X Y Z End
Rotation :
X Y Z Start
X Y Z End
Start frame Steps
Stereo Rock Pendulum EOH110 if ($morph_flag eq "yes") { print " Morph"; } print << "EOH112";
 Transparent GIF  Perspective
 Assemble frames only  Append EOH112 #print " Angle"; #print ""; if ($mrh_flag eq "yes") { print "\ \;Movie\ \;name"; } print << "EOH113";  Advanced  Wiggle
save restore Debug Monitor EOH113 if ($public_flag ne "yesORnoIEdisabled") { print << "EOH114";
Mail results to :
EOH114 } print << "EOH115";
Image width (pixels)
Quality Antialiasing
Help
EOH115 # Load JavaScript cookie functions #--------------------------------- CookieFunctions(); ############################################################################## # Movi3 Sets up and executes advanced movie functions ############################################################################## } elsif ($page eq "Movi3") { # if movi3 $def_yrot_start = -20.0; $def_yrot_end = 20.0; $preview_checked = ""; $headlamp_checked = ""; # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print << "EOH299"; Advanced Movie Setup EOH299 # Interpret form data pairs #-------------------------- @obj_pairs = &User_Data_Array(); $numobj = scalar(@obj_pairs); # Step through the options. Spot special options, rest are objects (Movie page) #----------------------------------------------------------------- for ($iobj=0;$iobj<$numobj;$iobj++) { $oname = $obj_pairs[$iobj]; $ovalue = $obj_pairs[$iobj]; $oname =~ s/=.*//; $oname =~ s/\%24/\$/; $ovalue =~ s/.*=//; if ($oname eq "plt_infile") {$plt_infile = $ovalue} elsif ($oname eq "debug") {$debug = $ovalue} elsif ($oname eq "cam_points") {$cam_points = $ovalue} elsif ($oname eq "cam_dist") {$cam_dist = $ovalue} elsif ($oname eq "preview") {$preview = $ovalue} elsif ($oname eq "preview_dist") {$preview_dist = $ovalue} elsif ($oname eq "spline_tension") {$spline_tension = $ovalue} elsif ($oname eq "spline_continuity") {$spline_continuity = $ovalue} elsif ($oname eq "spline_sampling") {$spline_sampling = $ovalue} elsif ($oname eq "spline_banking") {$spline_banking = $ovalue} elsif ($oname eq "spline_function") {$spline_function = $ovalue} elsif ($oname eq "headlamp") {$headlamp = $ovalue} else { } } if ($preview eq "on") {$preview_checked = "CHECKED"}; if ($headlamp eq "on") {$headlamp_checked = "CHECKED"}; # If we came here from "save advanced params", then write out a file #------------------------------------------------------------------------------ if ($advmode eq 'do') { # if advwin is already open $cp_string = "cp $pov_movfile $bac_movfile"; # Construct advanced movie commands #---------------------------------- $cam_points = URLDecode($cam_points); # Remove URL encoding from the form item containing trajectory $cam_pointsd = $cam_points; $cam_pointsd =~ s/\r/>,/g; # Then put back in carriage-controls for perl, and brackets for povray $cam_pointsd =~ s/\n/\n,//g; # Remove blank vectors $cam_pointsd = "<$cam_pointsd>"; # add start and end brackets $cam_pointsd =~ s/<>//g; # Remove blank vectors $cam_pointsd =~ s/\n\\//g; # Remove more blank vectors $cam_pointsd =~ s/,\\\n$//g; # Remove and more blank vectors $count_points = $cam_pointsd; # Now count number of elements. Ugly, ugly... $count_points =~ s/[^>]//g; $point_count = length($count_points); $funk = "_spline"; $create_function = "create_$spline_function$funk"; # This should be easier... if ($preview ne 'on') { #------- animate $new_camera =" \#declare SplinePath = create_spline ( array[$point_count] { $cam_pointsd}, $create_function + spline_tension ($spline_tension) + spline_sampling($spline_sampling) + spline_continuity($spline_continuity)) camera { right -x/Frame_Scale up y/Frame_Scale location <0, 0, 0> look_at z // Mray_Look1 animate_by_spline (SplinePath, auto_banking($spline_banking)) } "; if ($headlamp eq 'on') { # headlamp $new_camera = "$new_camera light_source {<0, 1, -1>, rgb 2 spotlight point_at <0,0,1> radius 30 falloff 33 animate_by_spline (SplinePath, auto_banking($spline_banking))} "; } } else { #-------- preview $new_camera =" \#declare SplinePath = create_spline ( array[$point_count] { $cam_pointsd}, $create_function + spline_tension ($spline_tension) + spline_sampling($spline_sampling)+ spline_continuity($spline_continuity)) preview_spline (SplinePath, default_options) camera { location <0, 0, $preview_dist> direction <0, 0, -1.0> up y/Frame_Scale right -x/Frame_Scale look_at <0, 0, 0> // Mray_Look1 } "; } ## The following lines fail with longer coord lists, so replaced by the ugly code below ## $adv_string = "cat $bac_movfile "; ## $adv_string = "$adv_string | perl -ne '/Mray_StartCamera/ && (\$flag=1); /Mray_EndCamera/ && (\$flag=0,\$_=\"$new_camera\"); \$flag || print $_;'"; # $adv_string = "$adv_string > $pov_movfile"; $adv_string ="set startline = `cat $bac_movfile | grep -n Mray_StartCamera | head -1 | cut -d':' -f1`"; $adv_string ="$adv_string\nset endline = `cat $bac_movfile | grep -n Mray_EndCamera | head -1 | cut -d':' -f1`"; $adv_string ="$adv_string\nhead -\$startline $bac_movfile > $pov_movfile"; $adv_string ="$adv_string\ncat << 'EOF' >> $pov_movfile"; $adv_string ="$adv_string\n$new_camera"; $adv_string ="$adv_string\n'EOF'"; $adv_string ="$adv_string\ntail +\$endline $bac_movfile >> $pov_movfile"; # Write out advanced movie commands to shell script #----------------------------------------- chmod (0777, $adv_cshfile); open (CSH,">$adv_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "set echo\n"); print (CSH "#\n$cp_string\n"); print (CSH "#\n$adv_string\n"); print (CSH "#\n$tidy_string\n"); close(CSH); chmod (0511, $adv_cshfile); if ($debug eq "on") { print "
"; open (CSH,"$tmp_cshfile"); while ($line = ) { print "$line
"; } close(CSH); #print "

Exec command debug :
"; #print "%$plt_string
%$filter_string
%$pov_string
%$transp_string
%$convert_string
%$transp_string
%$tidy_string

"; print "


"; } } else { # if not 'do' (ie advwin has only just opened) # Pick up spline points from input file $preview_checked = "CHECKED"; $spline_start = 'no'; open (POV,"$pov_tmpfile"); while ($line = ) { if ($line =~ /Mray_StartSpline/) { $spline_start = 'yes'; $cam_points = ""; } if ($line =~ /Mray_EndSpline/) { $spline_start = 'no'; } if ($spline_start eq 'yes' && $line =~ />/) { $line =~ s/,//g; $line =~ s/>//g; $line =~ s/(\..)[^,]+,/$1,\ /g; # 1 dp $line =~ s/(.+.+\..).+$/$1/; # 1 dp # $line =~ s/\..[^,]*,/$1,/g; # 0 dp # $line =~ s/(.+.+)\...*$/$1/; # 0 dp $line =~ s/ //g; $cam_points = "$cam_points$line"; } } close(POV); } # end if 'do' print << "EOH200";
\n EOH200 if ($mrh_flag eq "yes" || $mrh_flag eq "no") { print ""; } if (! -x $animgif_prog) { print "Warning : $animgif_prog program missing\n"; exit; } $cubic_sel = ""; $default_sel = ""; $bezier_sel = ""; $hermite_sel = ""; if ($spline_function eq 'cubic') { $cubic_sel = "SELECTED"; } elsif ($spline_function eq 'default') { $default_sel = "SELECTED"; } elsif ($spline_function eq 'bezier') { $bezier_sel = "SELECTED"; } elsif ($spline_function eq 'hermite') { $hermite_sel = "SELECTED"; } print << "EOH214";
Advanced Movie Params
In-going POV-Ray input file here
Camera trajectory:
\ \;Preview\ \;distance \ \;Spline\ \;tension \ \;Spline\ \;continuity \ \;Spline\ \;sampling \ \;Banking Function  Headlamp
 Preview
Help
EOH214 # Load JavaScript cookie functions #--------------------------------- ###CookieFunctions(); ############################################################################## # Movi2 Runs movie ############################################################################## } elsif ($page eq "Movi2") { # Send HTML header #----------------- print "Content-TYPE: text/html\n\n"; print << "EOH150"; Movie Output
Movie Output
EOH150 # Interpret form data pairs #-------------------------- @obj_pairs = &User_Data_Array(); $numobj = scalar(@obj_pairs); # Step through the options. Spot special options, rest are objects (Movie page) #----------------------------------------------------------------- for ($iobj=0;$iobj<$numobj;$iobj++) { $oname = $obj_pairs[$iobj]; $ovalue = $obj_pairs[$iobj]; $oname =~ s/=.*//; $oname =~ s/\%24/\$/; $ovalue =~ s/.*=//; if ($oname eq "plt_infile") {$plt_infile = $ovalue} elsif ($oname eq "width") {$width = $ovalue} elsif ($oname eq "quality") {$quality = $ovalue} elsif ($oname eq "alias") {$alias = $ovalue} elsif ($oname eq "stereo") {$stereo = $ovalue} elsif ($oname eq "perspective") {$perspective = $ovalue} elsif ($oname eq "perspangle") {$perspangle = $ovalue} elsif ($oname eq "perspangle_flag") {$perspangle_flag = $ovalue} elsif ($oname eq "morph") {$morph = $ovalue} elsif ($oname eq "ortho_flag") {$ortho_flag = $ovalue} elsif ($oname eq "transparent") {$transparent = $ovalue} elsif ($oname eq "demo_flag") {$demo_flag = $ovalue} elsif ($oname eq "debug") {$debug = $ovalue} elsif ($oname eq "monitor") {$monitor = $ovalue} elsif ($oname eq "mail_flag") {$mail_flag = $ovalue} elsif ($oname eq "mail_addr") {$mail_addr = $ovalue} elsif ($oname eq "tmp_lstfile") {$tmp_lstfile = $ovalue} elsif ($oname eq "xtrans") {$xtrans = $ovalue} elsif ($oname eq "ytrans") {$ytrans = $ovalue} elsif ($oname eq "ztrans") {$ztrans = $ovalue} elsif ($oname eq "xrot") {$xrot = $ovalue} elsif ($oname eq "yrot") {$yrot = $ovalue} elsif ($oname eq "zrot") {$zrot = $ovalue} elsif ($oname eq "xtrans0") {$xtrans0 = $ovalue} elsif ($oname eq "ytrans0") {$ytrans0 = $ovalue} elsif ($oname eq "ztrans0") {$ztrans0 = $ovalue} elsif ($oname eq "xrot0") {$xrot0 = $ovalue} elsif ($oname eq "yrot0") {$yrot0 = $ovalue} elsif ($oname eq "zrot0") {$zrot0 = $ovalue} elsif ($oname eq "steps") {$steps = $ovalue} elsif ($oname eq "frame_start") {$frame_start = $ovalue} elsif ($oname eq "rock") {$rock = $ovalue} elsif ($oname eq "assemble") {$assemble = $ovalue} elsif ($oname eq "append") {$append = $ovalue} elsif ($oname eq "advanced") {$advanced = $ovalue} elsif ($oname eq "cam_points") {$cam_points = $ovalue} elsif ($oname eq "movie_name") {$movie_name = $ovalue} else { } } # decode slashes in plt_filename, manipulate other params #-------------------------------------------------------- $plt_infile =~ s/%2F/\//g; $tmp_lstfile =~ s/%2F/\//g; if ($width > $limit_pixels) { $width = $limit_pixels; $too_wide_flag = "yes"; } $height = $width; if ($alias eq "on") {$alias_flag = "+a"}; if ($thumb_size > $width) {$thumb_size = $width}; if ($rock eq "on") { if (int(($steps+1.5)/2.0) != int(($steps+0.5)/2.0)) {$odd_rock_flag = "yes"} $steps = int(($steps+1.5)/2.0); } if ($steps > $limit_frames) { $steps = $limit_frames; $too_many_flag = "yes"; } $frame_end = $frame_start+$steps-1; # Use old pid for append file #---------------------------- $append_file = ""; if ($append eq "on") { open (TMP,"$pid_file"); $old_pid = ; $old_frames = ; chomp($old_pid); chomp($old_frames); close (TMP); $append_file = $animgif_file; $append_file =~ s/\.([^.]*$)/$old_pid\.$1/; } $animgif_file =~ s/\.([^.]*$)/$$\.$1/; # Pickup old pid if assembly only #-------------------------------- if ($assemble eq "on") { open (TMP,"$pid_file"); $$ = ; $old_frames = ; chomp($$); close (TMP); } # add local pid to final image name to avoid caching problem. Note animgif done above #------------------------------------------------------------------------------------ #$pov_outfile =~ s/\.([^.]*$)/$$\_\.$1/; $pov_outfile =~ s/\.([^.]*$)/\_\.$1/; $jpeg_outfile =~ s/\.([^.]*$)/$$\.$1/; $rgb_outfile =~ s/\.([^.]*$)/$$\.$1/; $gif_outfile =~ s/\.([^.]*$)/$$\.$1/; $gif_thumbfile =~ s/\.([^.]*$)/$$\.$1/; $tiff_outfile =~ s/\.([^.]*$)/$$\.$1/; $png_outfile =~ s/\.([^.]*$)/$$\.$1/; $mng_outfile =~ s/\.([^.]*$)/$$\.$1/; $mpeg_outfile =~ s/\.([^.]*$)/$$\.$1/; $mpeg_tmp_prms =~ s/\.([^.]*$)/$$\.$1/; # Assemble command strings #========================= if ($transmap eq "on") {$cmd_string = "$cmd_string -trans "}; $light_string = " "; $filter_string = " "; $transp_string = " "; $mail_string = " "; # Calculate tga file size #------------------------- $pred_file_size = $width * $height * 3; # Set batch flag #--------------- if ($mail_flag eq "on" && index($remote_cmd,"qsub") != -1) { $batch_flag = "Batch"; } else { $batch_flag = "Online"; } # Tell trustees where to find file #--------------------------------- $animgif_url = $animgif_file; $animgif_url =~ s#$scratch_dev/#$scratch_url/#; if (($Trusted_flag eq "yes") || ($public_flag ne "yes")) { print "$animgif_url
"; } # Check out how busy machine is #------------------------------ if ($batch_flag eq "Online") { $job_count_string = `ps aux | grep povray | grep -v grep | wc`; $job_count_string =~ s/.\s*//; ($job_count,) = split(/\s+/,$job_count_string,2); print "
Number of other POV-Ray jobs running : $job_count
\n"; # Abort if too many other jobs if ($job_count > $limit_other_jobs) { print "

Error - Server is overloaded, please try later...."; open (LOG,">>$Overloadlog"); $string = sprintf("%5d %2s%1d %2s %3s %21s %s\n",$width,"+q",$quality,$alias_flag," ",$date,$ENV{'REMOTE_HOST'}); print (LOG $string); close (LOG); exit; } } # Log movie usage #---------------- $mail_addr =~ s/\%40/\@/; if (!$mrh_flag) { open (LOG,">>$Usagelog"); $string = sprintf("%5d %2s%1d %2s %3s %21s %s %s %s %d\n",$width,"+q",$quality,$alias_flag,$steps,$date,$ENV{'REMOTE_HOST'},$mail_addr,"Movie",$job_count); print (LOG $string); } close (LOG); # Arrange for mailing if chosen #------------------------------ $| = 1; if ($mail_flag eq "on") { chmod (0777, $mail_mov_file); open (CSH,">$mail_mov_file"); print (CSH "Subject: Molray movie results\n"); print (CSH "From: Movie\@molray.com\n"); print (CSH "Your POV-Ray movie files will be available for some time at :\n\n"); $pov_outurl = $animgif_file; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "Animated GIF : $pov_outurl\n"); $pov_outurl = $mng_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "MNG file : $pov_outurl\n"); $pov_outurl = $mpeg_outfile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "MPEG video : $pov_outurl\n"); $pov_outurl = $pov_infile; $pov_outurl =~ s#$scratch_dev/#$scratch_url/#; print (CSH "POV-Ray input file : $pov_outurl\n"); close(CSH); $mail_addr =~ s/\%40/\@/; $mail_string = "/usr/bin/mail $mail_addr < $mail_mov_file"; $exe_cmd = $remote_cmd; } else { if ($odd_rock_flag eq "yes") {print "Warning, your odd stepcount has been rounded up to ".int($steps*2)."
"}; if ($too_many_flag eq "yes") {print "Warning, your illegally-long movie has been shrunk down to ".int($steps*2)." steps
"}; if ($too_wide_flag eq "yes") {print "Warning, your illegally-wide movie has been shrunk down to ".$width." pixels
"}; if (($assemble eq "on") && ($frame_start < 10) && ($frame_start+$steps > 10)) { print "Error - All assembly frames must be numbered between 10 and 99. See help for explanation.
"; exit; } if ($job_count > $limit_other_jobs) { print "

Error - Server is overloaded, please try later...."; open (LOG,">>$Overloadlog"); $string = sprintf("%5d %2s%1d %2s %3s %21s %s\n",$width,"+q",$quality,$alias_flag," ",$date,$ENV{'REMOTE_HOST'}); print (LOG $string); close (LOG); exit; } print "Your movie output is on its way ...
" } $| = 0; # Start sed transform command #---------------------------- if ($pendulum ne "on") { $transform_string = "cat $pov_tmpfile "; $transform_string = "$transform_string | sed /\"Mray_Xtrans\"/s/\\^\\.\\*/\"translate x\*\(\($xtrans\-$xtrans0\)\*clock+$xtrans0\) \\/\\/Mray_Xtrans\"/"; $transform_string = "$transform_string | sed /\"Mray_Ytrans\"/s/\\^\\.\\*/\"translate y\*\(\($ytrans\-$ytrans0\)\*clock+$ytrans0\) \\/\\/Mray_Ytrans\"/"; ##if ($perspective eq "on" || $ortho_flag eq "no" && $perspective ne "Dwizzle") { if ($perspective eq "Dwizzle") { $transform_string = "$transform_string | sed /\"Mray_Ztrans\"/s/\\^\\.\\*/\"translate z\*\(\($ztrans\-$ztrans0\)\*clock+$ztrans0\) \\/\\/Mray_Ztrans\"/"; } else { $transform_string = "$transform_string | sed /\"Mray_ModCamDist\"/s/\\^\\.\\*/\"#declare Camera_Distance = Camera_Distance + \(\(-$ztrans\+$ztrans0\)\*clock-$ztrans0\) \\/\\/Mray_ModCamDist\"/"; } $transform_string = "$transform_string | sed /\"Mray_Xrot\"/s/\\^\\.\\*/\"rotate x\*\(\($xrot\-$xrot0\)\*clock+$xrot0\) \\/\\/Mray_Xrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Yrot\"/s/\\^\\.\\*/\"rotate y\*\(\($yrot\-$yrot0\)\*clock+$yrot0\) \\/\\/Mray_Yrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Zrot\"/s/\\^\\.\\*/\"rotate z\*\(\($zrot\-$zrot0\)\*clock+$zrot0\) \\/\\/Mray_Zrot\"/"; } else { $transform_string = "cat $pov_tmpfile "; $transform_string = "$transform_string | sed /\"Mray_Xtrans\"/s/\\^\\.\\*/\"translate x\*\(\($xtrans\-$xtrans0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$xtrans0\) \\/\\/Mray_Xtrans\"/"; $transform_string = "$transform_string | sed /\"Mray_Ytrans\"/s/\\^\\.\\*/\"translate y\*\(\($ytrans\-$ytrans0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$ytrans0\) \\/\\/Mray_Ytrans\"/"; ##if ($perspective eq "on" || $ortho_flag eq "no" && $perspective ne "Dwizzle") { if ($perspective eq "Dwizzle") { $transform_string = "$transform_string | sed /\"Mray_Ztrans\"/s/\\^\\.\\*/\"translate z\*\(\($ztrans\-$ztrans0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$ztrans0\) \\/\\/Mray_Ztrans\"/"; } else { $transform_string = "$transform_string | sed /\"Mray_ModCamDist\"/s/\\^\\.\\*/\"#declare Camera_Distance = Camera_Distance + \(\(-$ztrans\+$ztrans0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)-$ztrans0\) \\/\\/Mray_ModCamDist\"/"; } $transform_string = "$transform_string | sed /\"Mray_Xrot\"/s/\\^\\.\\*/\"rotate x\*\(\($xrot\-$xrot0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$xrot0\) \\/\\/Mray_Xrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Yrot\"/s/\\^\\.\\*/\"rotate y\*\(\($yrot\-$yrot0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$yrot0\) \\/\\/Mray_Yrot\"/"; $transform_string = "$transform_string | sed /\"Mray_Zrot\"/s/\\^\\.\\*/\"rotate z\*\(\($zrot\-$zrot0\)\*\(\(cos\(clock\*3.1415\)\+1\)\\/2\)+$zrot0\) \\/\\/Mray_Zrot\"/"; } $transform_string = "$transform_string > $scratchfile ; cp $scratchfile $pov_movfile"; # Orthogonal and Transparent GIF command # -------------------------------------- $filter_string = "cat $pov_movfile "; if ($perspective eq "on") { if ($perspangle_flag ne "yes") { $filter_string = "$filter_string | sed /\"Mray_Ortho\"/s/\\^\\.\\*/\" \\/\\/Mray_Ortho\"/"; } } else { $filter_string = "$filter_string | sed /\"Mray_Ortho\"/s/\\^\\.\\*/\"orthographic \\/\\/Mray_Ortho\"/"; } if ($transparent eq "on" && (-x $transgif_prog)) { $filter_string = "$filter_string | sed /\"Mray_Bgrnd\"/s/\\^\\.\\*/\"background \\{Very_Light_Purple\\}\"/"; $transgif_prms = "$transgif_prms -U "; } $filter_string = "$filter_string > $scratchfile ; cp $scratchfile $pov_movfile"; # Assemble animated GIF command # ----------------------------- $padlen = 1; if ($frame_start+$steps-1 > 9) {$padlen = 2}; if ($frame_start+$steps-1 > 99) {$padlen = 3}; if ($frame_start+$steps-1 > 999) {$padlen = 4}; $pov_movroot = $pov_outfile; $pov_movroot =~ s/.tga//; for ($istep=$frame_start-1;$istep<$frame_end;$istep++) { $padstep = sprintf "%0".$padlen."d", $istep+1; $frame_files[$istep] = "$pov_movroot".($padstep).".gif"; $mng_files[$istep] = "$pov_movroot".($padstep).".tga"; $frame_files_back[$frame_end-$istep-1] = "$pov_movroot".($padstep).".gif"; $mng_files_back[$frame_end-$istep-1] = "$pov_movroot".($padstep).".tga"; $frame_roots[$istep] = "$pov_movroot".($padstep); if ($istep == $frame_end-1) {$pov_movone = "$pov_movroot".($padstep).".tga"}; } # Rocking and peduluming #----------------------- if ($rock ne "on") { $anim_string = "$animgif_prog --colors 256 -l$movie_loop -d$movie_rate $append_file @frame_files > $animgif_file"; $mng_string = "$tga_to_png @frame_files mng:$mng_outfile"; } else { $anim_string = "$animgif_prog -l$movie_loop -d$movie_rate $append_file @frame_files @frame_files_back > $animgif_file"; $mng_string = "$tga_to_png @frame_files @frame_files_back mng:$mng_outfile"; } # Assemble conversion and delete strings #---------------------------- $start = $frame_start-1; $convert_string = "set istep = $start;\nloop:\n@ istep ++\nset padstep = `printf \"\%0".$padlen."d\" \$istep`\n@ istep2 = \( $frame_end \* 2 \+ 1 \) - \$istep\nset padstep2 = `printf \"\%0".$padlen."d\" \$istep2`\n"; $delete_string = "rm -f "; $convert_string = "$convert_string $tga_to_other $pov_movroot\$padstep.tga $pov_movroot\$padstep.gif\n" ; $convert_string = "$convert_string $tga_to_other $pov_movroot\$padstep.tga $pov_movroot\$padstep.rgb\n" ; $convert_string = "$convert_string $tga_to_other $pov_movroot\$padstep.tga $pov_movroot\$padstep.ppm\n" ; $delete_string = "$delete_string $pov_movroot\$padstep.tga"; if ($rock eq "yes") { $convert_string = "$convert_string ln -s $pov_movroot\$padstep.ppm $pov_movroot\$padstep2.ppm\n" ; $convert_string = "$convert_string ln -s $pov_movroot\$padstep.tga $pov_movroot\$padstep2.tga\n" ; } if ($transparent eq "on") { $convert_string = "$convert_string $transgif_prog $transgif_prms -o $scratchfile $pov_movroot\$padstep.gif; cp $scratchfile $pov_movroot\$padstep.gif\n"; } $convert_string = " $convert_string if (\$istep < $frame_end) goto loop\n"; # MNG output (Here converts from GIF, just for testing. Real code should be upstairs) #--------- #$mng_string = "$tga_to_png $animgif_file mng:$mng_outfile ;\n"; # Morph enabling #------------ $morph_string = " "; if ($morph eq "on") { $morph_string = " cat $pov_tmpfile | sed /\"Mray_FM\"/s/!=/=/ | sed /\"Mray_FM\"/s/\+999// > $scratchfile ; cp $scratchfile $pov_tmpfile"; } # Advanced enabling #--------------- $advanced_string = " "; if ($advanced eq "on") { $advanced_string = "if -x $adv_cshfile $adv_cshfile"; } # MPEG creation #-------------- $mpeg_string = " "; $local_ppm_files = $pov_movroot."*.ppm"; $local_ppm_files =~ s/$scratch_dev\/$client\///; $range = sprintf "%0".$padlen."d"."-"."%0".$padlen."d",$frame_start,$frame_end; open (PRMO,">$mpeg_tmp_prms"); print (PRMO "OUTPUT $mpeg_outfile\n"); print (PRMO "INPUT_DIR $scratch_dev\/$client\n"); print (PRMO "INPUT\n"); ##print (PRMO "$local_ppm_files \[$range\]\n"); foreach $file (@frame_files) { $file =~ s/$scratch_dev\/$client\///; $file =~ s/.gif/.ppm/; print (PRMO "$file\n"); print (PRMO "$file\n"); } if ($rock eq "on") { foreach $file (@frame_files_back) { $file =~ s/$scratch_dev\/$client\///; $file =~ s/.gif/.ppm/; print (PRMO "$file\n"); print (PRMO "$file\n"); } } if ($append eq "on") {print (PRMO "$old_frames\n")} $old_frames = "$local_ppm_files \[$range\]\n"; print (PRMO "END_INPUT\n"); open (PRMI,"$mpeg_params"); while ($line = ) { print (PRMO "$line"); } close(PRMO); close(PRMI); $mpeg_string = "$mpeg_string $mpeg_prog $mpeg_tmp_prms > $mpeg_lstfile"; # Stereo strings. Does not support rocking at the moment #------------------------------------------------------- $pov_ster_string = "#\n"; $stereo_string = "#\n"; $convert_ster_string = "#\n"; if ($stereo eq "on") { $pov_ster_movfile = $pov_movfile; $pov_ster_movfile =~ s/.mpv/_left.mpv/; $pov_ster_outfile = $pov_outfile; $pov_ster_outfile =~ s/.tga/left_.tga/; $pov_steroot = $pov_ster_outfile; $pov_steroot =~ s/.mpv//; $stereo_string = "cat $pov_movfile | sed /\"Mray_YSMrot\"/s/\\^\\.\\*/\"rotate y\\*4\\.0 \\/\\/Mray_YSMrot\"/ > $pov_ster_movfile"; ## $stereo_string = "cat $pov_movfile | sed /\"location\"/s/\\^\\.\\*/\"camera \\{ location \\<\\-1\\.4\\, \\0\\.0\\, Camera_Distance\\>\"/ | sed /\"look_at\"/s/\\^\\.\\*/\"direction \\<\\-1\\.4 , 0, 1\\.0\\>\"/ > $pov_ster_movfile"; # $pov_ster_string = "$povray +ft +i $pov_ster_movfile +o $pov_ster_outfile +w$width +h$height +q$quality +KFI$frame_start +KFF$frame_end $alias_flag >& $pov_lstfile"; $pov_ster_string = "$povray +ft +i $pov_ster_movfile +o $pov_ster_outfile +w$width +h$height +q$quality +KFI$frame_start +KFF$frame_end $alias_flag "; $convert_ster_string = "set istep = $frame_start-1;\nloops:\n@ istep ++\nset padstep = `printf \"\%0".$padlen."d\" \$istep`\n "; $convert_ster_string = "$convert_ster_string $tga_to_other $pov_steroot\$padstep.tga $pov_steroot\$padstep.gif\n" ; $convert_ster_string = "$convert_ster_string $tga_to_other $pov_steroot\$padstep.tga $pov_steroot\$padstep.rgb\n" ; # Transparency #------------- if ($transparent eq "on" && (-x $transgif_prog)) { $filter_string = "$filter_string | sed /\"Mray_Bgrnd\"/s/\\^\\.\\*/\"background \\{Very_Light_Purple\\} \\/\\/Mray_Bgrnd\"/"; $transp_string = "$transgif_prog $transgif_prms -o $gif_outfile $scratchfile; cp $scratchfile $gif_outfile; $transgif_prog $transgif_prms -o $scratchfile $gif_thumbfile ; cp $scratchfile $gif_thumbfile"; } $convert_ster_string = " $convert_ster_string if (\$istep <= $frame_end) goto loops\n"; } # End sed commands #------------------ #$pov_string = "$povray +ft +i $pov_movfile +o $pov_outfile +w$width +h$height +q$quality +KFI$frame_start +KFF$frame_end $alias_flag >& $pov_lstfile"; $pov_string = "$povray +ft +i $pov_movfile +o $pov_outfile +w$width +h$height +q$quality +KFI$frame_start +KFF$frame_end $alias_flag "; $geom = $thumb_size."x".$thumb_size; $tidy_string = "rm -f $tmp_lstfile"; $cmd_string = "$plt_string; $pov_string; $tidy_string $tmp_cshfile"; # Rename string #-------------- if ($movie_name ne "") { $rename_string = "ln -s $animgif_file $scratch_dev/$client/$movie_name.GIF" } # Disable everything else if "assemble-only" chosen #-------------------------------------------------- if ($assemble eq "on") { $morph_string = ""; $transform_string = ""; $filter_string = ""; $pov_string = ""; $transp_string = ""; $pov_ster_string = ""; $convert_ster_string = ""; } else { # Else write out pid so we can assemble next time #------------------------------------------------ chmod (0777, $pid_file); open (TMP,">$pid_file"); print (TMP "$$\n"); print (TMP "$old_frames\n"); close(TMP); chmod (0511, $pid_file); } # Write out movie commands to shell script #----------------------------------------- chmod (0777, $tmp_cshfile); open (CSH,">$tmp_cshfile"); print (CSH "#!/bin/tcsh -f\n"); print (CSH "set echo\n"); if ($public_flag ne "yesORnoDISABLED") { print (CSH "limit datasize unlimited \n"); print (CSH "limit memoryuse unlimited \n"); # print (CSH "limit vmemoryuse unlimited \n"); } #print (CSH "cp $pov_inc/*.inc ./\n"); print (CSH "##Mray_batch cp movie.pov $pov_tmpfile\n"); ## print (CSH "#\n$delete_string\n"); # doesn't work yet... print (CSH "#\n$morph_string\n"); print (CSH "#\n$transform_string\n"); print (CSH "#\n$filter_string\n"); print (CSH "#\n$advanced_string\n"); print (CSH "#\n$pov_string\n"); print (CSH "#\n$convert_string\n"); print (CSH "#\n$transp_string\n"); print (CSH "#\n$anim_string\n"); print (CSH "#\n$stereo_string\n"); print (CSH "#\n$pov_ster_string\n"); print (CSH "#\n$convert_ster_string\n"); print (CSH "#\n$rename_string\n"); print (CSH "#\n$mpeg_string\n"); print (CSH "#\n$mng_string\n"); print (CSH "#\nchmod o+r $scratch_dev/$client/*\n"); print (CSH "#\n$mail_string\n"); print (CSH "#\n$tidy_string\n"); if (($mrh_flag ne "yes_anything") && ($gunnar_flag ne "yes")) { $final_tidy = "rm -f $scratch/tmpp$id* $scratch/tmppd$id* *.GIF"; system("csh\n"); system("echo $final_tidy | at now + $tidy_time minutes\n"); } close(CSH); chmod (0511, $tmp_cshfile); if ($debug eq "on") { print "


"; open (CSH,"$tmp_cshfile"); while ($line = ) { print "$line
"; } close(CSH); #print "

Exec command debug :
"; #print "%$plt_string
%$filter_string
%$pov_string
%$transp_string
%$convert_string
%$transp_string
%$tidy_string

"; print "


"; } if (! -x $povray) { print "Demo image due to POV-Ray missing
\n"; exit; } # Run the programs #----------------- # Can't submit to DQS from SH, must make CSH wrapper. if ($monitor eq "on") {MonitorGrowth($pov_outfile, $pred_file_size, $scratch_url, $batch_flag, $frame_start, $frame_end)}; if ($batch_flag eq "Batch") { system("$exe_cmd $tmp_cshfile"); } else { system("$exe_cmd $tmp_cshfile 2> $tmp_logfile"); } if ($mail_flag eq "on") { print "
The location of your output will be mailed to you
"; exit; } if (! -e $pov_tmpfile) { print "No POV-Ray input file
"; print "Failure during pre-processing
"; print "

Check out the log file

"; exit; } elsif (-z $pov_tmpfile) { print "Empty POV-Ray input file
"; print "Failure probably during sed operations
"; print "

Check out the log file

"; exit; } if (! -e "$pov_movone") { print "No output TARGA file $pov_movone
"; print "Failure probably before POV-Ray execution
"; print "

Check out the log file

"; exit; } elsif (-z $frame_files[0]) { print "Empty TARGA file
"; print "Failure probably during POV-Ray execution
"; print "

Check out the log file

"; exit; } if (! -e $animgif_file) { print "No output GIF file
"; print "Failure probably during movie assembly
"; print "

Check out the log file

"; exit; } elsif (-z $animgif_file) { print "Empty animated-GIF file
"; print "Failure probably during movie assembly
"; print "

Check out the log file

"; exit; } # Write some blurb #----------------- print << "EOF39"; \n

Get your output here :
GIF MPEG MNG POVin CSH Help
EOF39 print ""; # Some more tidying. BUG, won't return.... #------------------ $final_tidy = "rm -f $scratch/tmpp$id* $scratch/tmpp$id* *.GIF"; if (($mrh_flag ne "yes") && ($gunnar_flag ne "yes")) { system("echo $final_tidy | at now + $tidy_time minutes"); } ###################################################################### # And home ###################################################################### } exit; ###################################################################### # Subroutine pov_opts() MRH ###################################################################### sub pov_opts { # Make new form to select POV-Ray options #---------------------------------------- ##print ":id: $id :: $idd :f:$frames_type:p:$page:$tmp:$page_num"; print << "EOF2";

\n EOF2 if ($mrh_flag eq "yes") { print "" } print "
POV-Ray Parameters
In-going POV-Ray input file here
"; if ($plt_pov_flag eq "yes") { print << "EOF31"; Camera distance
EOF31 print << "EOF36"; X Y Z Translate
X Y Z Rotate
EOF36 } print << "EOF32";
R G B  Background colour
EOF32 if ($plt_pov_flag eq "yes") { $mapcol_checked = ""; print << "EOF38";  Texture    Dist
R G B    New line colour  Line thickness

EOF38 if ($transmap eq "on") { print << "EOF33"; Map transparency
EOF33 } print << "EOF42";
 Stereo sep  Stereo on  No shadows  Transparent GIF  Perspective EOF42 } print " Angle"; print << "EOF22";

save restore Debug Monitor EOF22 if ($public_flag ne "yesORnoIEdisabled") { print << "EOF23";
Mail results to :
EOF23 } print << "EOF24";
Image width (pixels)
Quality Antialiasing
\n \n \n \n \n
Help
EOF24 # Load JavaScript cookie functions #--------------------------------- CookieFunctions(); } ###################################################################### # Subroutine other_progs() MRH ###################################################################### sub other_progs { # Offer other progs if their exes are good #----------------------------------------- my $pcount; my $ncols; $pcount = 0; $ncols = 3; print "\n"; if (-x $plt_pov) { print "\n"; $pcount++; } if ($public_flag eq "yes") {$pcount++}; # why ?? if (($public_flag eq "no") || ($Trusted_flag eq "yes")) { if (-x $molscript) { print "\n"; $pcount++; } } if ($pcount == $ncols) { print "\n"; $pcount = 0; } if ($public_flag ne "yes") { if (-x $surfout) { print "\n"; $pcount++; } } if ($pcount == $ncols) { print "\n"; $pcount = 0; } if ($public_flag ne "yes") { if (-x $ligplot) { print "\n"; $pcount++; } } if ($pcount == $ncols) { print "\n"; $pcount = 0; } print "\n"; $pcount++; print "\n"; #print << "EOHT"; # #\n"; $pcount=0; print "\n"; print "\n"; $pcount++; if ($pcount == $ncols) { print "\n"; $pcount = 0; } print "\n"; $pcount++; if ($pcount == $ncols) { print "\n"; $pcount = 0; } print "\n"; print "
Other input forms
Plt_povMolscript
Grasp
Ligplot
POV-Ray scriptCleanup
# #EOHT $pcount++; print "
Display type
Frames
New windows
1 window
\n"; } ###################################################################### # Subroutine monitor_growth(file, predicted_size) MRH ###################################################################### sub MonitorGrowth ($file, $size, $url, $exe, $start, $end) { my ($file, $size, $url, $exe, $start, $end) = @_; $| = 1; if (-x $file_growth_monitor) { print << "FGM"; FGM } } ###################################################################### # Subroutine CookieFunctions() MRH ###################################################################### sub CookieFunctions () { print << "EOC"; EOC } ###################################################################### # Subroutine ForkOff(command) MRH ###################################################################### sub ForkOff { my ($command) = @_; $| = 1; if ((fork) == 0) { exec($command); } } ###################################################################### # Subroutine User_Data sorts out form data-pairs. ###################################################################### ## Use as follows : ## %data_received = &User_Data(); ## $value = $data_received{item_name}; sub User_Data { local (%user_data, $user_string, $name_value_pair, @name_value_pairs, $name, $value); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $user_string, $ENV{'CONTENT_LENGTH'}); } else { $user_string = $ENV{'QUERY_STRING'}; } $user_string =~ s/\+/ /g; @name_value_pairs = split(/&/, $user_string); foreach $name_value_pair (@name_value_pairs) { ($name, $value) = split(/=/, $name_value_pair); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; if (defined($user_data{$name})) { $user_data{$name} .= " : " . $value; } else { $user_data{$name} = $value; } } return %user_data; } ###################################################################### # Subroutine User_Data_Array sorts out form data-pairs and returns array ###################################################################### sub User_Data_Array { local (%user_data, $user_string, $name_value_pair, @name_value_pairs, $name, $value); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $user_string, $ENV{'CONTENT_LENGTH'}); } else { $user_string = $ENV{'QUERY_STRING'}; } $user_string =~ s/\+/ /g; @name_value_pairs = split(/&/, $user_string); foreach $name_value_pair (@name_value_pairs) { ($name, $value) = split(/=/, $name_value_pair); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; if (defined($user_data{$name})) { $user_data{$name} .= " : " . $value; } else { $user_data{$name} = $value; } } return @name_value_pairs; } ###################################################################### # Subroutine URLDecode decodes special characters in URL ###################################################################### sub URLDecode { my $theURL = $_[0]; $theURL =~ tr/+/ /; $theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg; $theURL =~ s///g; return $theURL; }