#!/usr/bin/perl -T ################################################### $program_name = "comp.cgi"; # COMPosition $program_path = "/web/genome/tmstat/"; #$program_path = "/csb/dme/granule/web/tmstat/cgi-bin/"; $program_ver = "v.1.00"; $program_date = "000720"; $program_author = "Alessandro Senes"; $program_description .= " "; ################################################### ################################################### # VARIABLES ################################################### ############################ # 4 letter codes of genomes ############################ @genomeCodes = ( aaeo, aful, bbur, bsub, cele, cpne, ctra, ecol, hinf, hpyl, mgen, mjan, mpne, mthe, mtub, phor, rpro, scer, syne, tpal ); ############################ # codes of the 3 Sprot databases # all, single-span and multi-span ############################ @sprotCodes = ( sprot, sprotsingle, sprotmulti ); ############################ # Name of database ############################ $database_string{aaeo} = "A.aeolicus"; $database_string{aful} = "A.fulgidus"; $database_string{bbur} = "B.burgdorferi"; $database_string{bsub} = "B.subtilis"; $database_string{cele} = "C.elegans"; $database_string{cpne} = "C.pneumoniae"; $database_string{ctra} = "C.trachomatis"; $database_string{ecol} = "E.coli"; $database_string{hinf} = "H.influenzae"; $database_string{hpyl} = "H.pylori"; $database_string{mgen} = "M.genitalium"; $database_string{mjan} = "M.jannaschii"; $database_string{mpne} = "M.pneumoniae"; $database_string{mthe} = "M.thermoautotrophicum"; $database_string{mtub} = "M.tuberculosis"; $database_string{phor} = "P.horikoshii"; $database_string{rpro} = "R.prowazekii"; $database_string{scer} = "S.cerevisiae"; $database_string{syne} = "Synechocystis sp."; $database_string{tpal} = "T.pallidum"; ############################ # Name of database ############################ $database_tm_string{aaeo} = "A.aeolicus (1227 TMs)"; $database_tm_string{aful} = "A.fulgidus (2122 TMs)"; $database_tm_string{bbur} = "B.burgdorferi (864 TMs)"; $database_tm_string{bsub} = "B.subtilis (5044 TMs)"; $database_tm_string{cele} = "C.elegans (21197 TMs)"; $database_tm_string{cpne} = "C.pneumoniae (1000 TMs)"; $database_tm_string{ctra} = "C.trachomatis (840 TMs)"; $database_tm_string{ecol} = "E.coli (5525 TMs)"; $database_tm_string{hinf} = "H.influenzae (1747 TMs)"; $database_tm_string{hpyl} = "H.pylori (1268 TMs)"; $database_tm_string{mgen} = "M.genitalium (490 TMs)"; $database_tm_string{mjan} = "M.jannaschii (1089 TMs)"; $database_tm_string{mpne} = "M.pneumoniae (616 TMs)"; $database_tm_string{mthe} = "M.thermoautotrophicum (1398 TMs)"; $database_tm_string{mtub} = "M.tuberculosis (3114 TMs)"; $database_tm_string{phor} = "P.horikoshii (1703 TMs)"; $database_tm_string{rpro} = "R.prowazekii (972 TMs)"; $database_tm_string{scer} = "S.cerevisiae (4520 TMs)"; $database_tm_string{syne} = "Synechocystis sp. (2891 TMs)"; $database_tm_string{tpal} = "T.pallidum (749 TMs)"; ############################ # Links to genome pages ############################ $database_url{aaeo} = " [Aaeo]"; $database_url{aful} = " [Aful]"; $database_url{bbur} = " [Bbur]"; $database_url{bsub} = " [Bsub]"; $database_url{cele} = " [Cele]"; $database_url{cpne} = " [Cpne]"; $database_url{ctra} = " [Ctra]"; $database_url{ecol} = " [Ecol]"; $database_url{hinf} = " [Hinf]"; $database_url{hpyl} = " [Hpyl]"; $database_url{mgen} = " [Mgen]"; $database_url{mjan} = " [Mjan]"; $database_url{mpne} = " [Mpne]"; $database_url{mthe} = " [Mthe]"; $database_url{mtub} = " [Mtub]"; $database_url{phor} = " [Phor]"; $database_url{rpro} = " [Rpro]"; $database_url{scer} = " [Scer]"; $database_url{syne} = " [Syne]"; $database_url{tpal} = " [Tpal]"; ############################ # Links to gif ############################ $data_path = $program_path."data/comp/"; $orf_gif_location{aaeo} = $data_path."aaeo_comp.gif"; $orf_gif_location{aful} = $data_path."aful_comp.gif"; $orf_gif_location{bbur} = $data_path."bbur_comp.gif"; $orf_gif_location{bsub} = $data_path."bsub_comp.gif"; $orf_gif_location{cele} = $data_path."cele_comp.gif"; $orf_gif_location{cpne} = $data_path."cpne_comp.gif"; $orf_gif_location{ctra} = $data_path."ctra_comp.gif"; $orf_gif_location{ecol} = $data_path."ecol_comp.gif"; $orf_gif_location{hinf} = $data_path."hinf_comp.gif"; $orf_gif_location{hpyl} = $data_path."hpyl_comp.gif"; $orf_gif_location{mgen} = $data_path."mgen_comp.gif"; $orf_gif_location{mjan} = $data_path."mjan_comp.gif"; $orf_gif_location{mpne} = $data_path."mpne_comp.gif"; $orf_gif_location{mthe} = $data_path."mthe_comp.gif"; $orf_gif_location{mtub} = $data_path."mtub_comp.gif"; $orf_gif_location{phor} = $data_path."phor_comp.gif"; $orf_gif_location{rpro} = $data_path."rpro_comp.gif"; $orf_gif_location{scer} = $data_path."scer_comp.gif"; $orf_gif_location{syne} = $data_path."syne_comp.gif"; $orf_gif_location{tpal} = $data_path."tpal_comp.gif"; $orf_gif_location{null} = $data_path."null_comp.gif"; $tm_gif_location{aaeo} = $data_path."aaeo_tm_comp.gif"; $tm_gif_location{aful} = $data_path."aful_tm_comp.gif"; $tm_gif_location{bbur} = $data_path."bbur_tm_comp.gif"; $tm_gif_location{bsub} = $data_path."bsub_tm_comp.gif"; $tm_gif_location{cele} = $data_path."cele_tm_comp.gif"; $tm_gif_location{cpne} = $data_path."cpne_tm_comp.gif"; $tm_gif_location{ctra} = $data_path."ctra_tm_comp.gif"; $tm_gif_location{ecol} = $data_path."ecol_tm_comp.gif"; $tm_gif_location{hinf} = $data_path."hinf_tm_comp.gif"; $tm_gif_location{hpyl} = $data_path."hpyl_tm_comp.gif"; $tm_gif_location{mgen} = $data_path."mgen_tm_comp.gif"; $tm_gif_location{mjan} = $data_path."mjan_tm_comp.gif"; $tm_gif_location{mpne} = $data_path."mpne_tm_comp.gif"; $tm_gif_location{mthe} = $data_path."mthe_tm_comp.gif"; $tm_gif_location{mtub} = $data_path."mtub_tm_comp.gif"; $tm_gif_location{phor} = $data_path."phor_tm_comp.gif"; $tm_gif_location{rpro} = $data_path."rpro_tm_comp.gif"; $tm_gif_location{scer} = $data_path."scer_tm_comp.gif"; $tm_gif_location{syne} = $data_path."syne_tm_comp.gif"; $tm_gif_location{tpal} = $data_path."tpal_tm_comp.gif"; $tm_gif_location{null} = $data_path."null_tm_comp.gif"; ############################ # Links to data ############################ $data_path = $program_path."data/comp/"; $orf_data_location{aaeo} = $data_path."aaeo_comp.dat"; $orf_data_location{aful} = $data_path."aful_comp.dat"; $orf_data_location{bbur} = $data_path."bbur_comp.dat"; $orf_data_location{bsub} = $data_path."bsub_comp.dat"; $orf_data_location{cele} = $data_path."cele_comp.dat"; $orf_data_location{cpne} = $data_path."cpne_comp.dat"; $orf_data_location{ctra} = $data_path."ctra_comp.dat"; $orf_data_location{ecol} = $data_path."ecol_comp.dat"; $orf_data_location{hinf} = $data_path."hinf_comp.dat"; $orf_data_location{hpyl} = $data_path."hpyl_comp.dat"; $orf_data_location{mgen} = $data_path."mgen_comp.dat"; $orf_data_location{mjan} = $data_path."mjan_comp.dat"; $orf_data_location{mpne} = $data_path."mpne_comp.dat"; $orf_data_location{mthe} = $data_path."mthe_comp.dat"; $orf_data_location{mtub} = $data_path."mtub_comp.dat"; $orf_data_location{phor} = $data_path."phor_comp.dat"; $orf_data_location{rpro} = $data_path."rpro_comp.dat"; $orf_data_location{scer} = $data_path."scer_comp.dat"; $orf_data_location{syne} = $data_path."syne_comp.dat"; $orf_data_location{tpal} = $data_path."tpal_comp.dat"; $orf_data_location{null} = $data_path."null_comp.dat"; $tm_data_location{aaeo} = $data_path."aaeo_tm_comp.dat"; $tm_data_location{aful} = $data_path."aful_tm_comp.dat"; $tm_data_location{bbur} = $data_path."bbur_tm_comp.dat"; $tm_data_location{bsub} = $data_path."bsub_tm_comp.dat"; $tm_data_location{cele} = $data_path."cele_tm_comp.dat"; $tm_data_location{cpne} = $data_path."cpne_tm_comp.dat"; $tm_data_location{ctra} = $data_path."ctra_tm_comp.dat"; $tm_data_location{ecol} = $data_path."ecol_tm_comp.dat"; $tm_data_location{hinf} = $data_path."hinf_tm_comp.dat"; $tm_data_location{hpyl} = $data_path."hpyl_tm_comp.dat"; $tm_data_location{mgen} = $data_path."mgen_tm_comp.dat"; $tm_data_location{mjan} = $data_path."mjan_tm_comp.dat"; $tm_data_location{mpne} = $data_path."mpne_tm_comp.dat"; $tm_data_location{mthe} = $data_path."mthe_tm_comp.dat"; $tm_data_location{mtub} = $data_path."mtub_tm_comp.dat"; $tm_data_location{phor} = $data_path."phor_tm_comp.dat"; $tm_data_location{rpro} = $data_path."rpro_tm_comp.dat"; $tm_data_location{scer} = $data_path."scer_tm_comp.dat"; $tm_data_location{syne} = $data_path."syne_tm_comp.dat"; $tm_data_location{tpal} = $data_path."tpal_tm_comp.dat"; $tm_data_location{null} = $data_path."null_tm_comp.dat"; ################################################### # Done with variables ################################################### $time = localtime(); ################################################### # Call the subroutine that parses the web input ################################################### $errorCode = &ReadParse; if ($errorCode) { &Error($errorCode); exit; } $field{db} =~ tr/A-Z/a-z/; $field{dbtype} =~ tr/A-Z/a-z/; $field{opt} =~ tr/A-Z/a-z/; $dbOK = 0; for ($i=0;$i<@genomeCodes;$i++) { if ($field{db} eq $genomeCodes[$i]) { $dbOK = 1; $selected_option{$field{db}} = "SELECTED"; $i = @genomeCodes; } } if ($field{dbtype} ne "tm") { $field{dbtype} = "orfs"; } if ($field{opt} ne "gif") { $field{opt} = "page"; } if (!$dbOK) { $field{db} = "null"; } if ($field{opt} eq "gif") { if ($field{dbtype} eq "tm") { open GIF, "$tm_gif_location{$field{db}}"; } else { open GIF, "$orf_gif_location{$field{db}}"; } @gif = ; close GIF; $gif = join("", @gif); print "Content-type: image/gif\n\n"; print $gif; exit; } else { if ($field{dbtype} eq "tm") { open DATA, "$tm_data_location{$field{db}}"; open GIF, "$tm_gif_location{$field{db}}"; $tm_checked = "CHECKED"; $title = "Composition of all transmembrane domains in $database_tm_string{$field{db}} $database_url{$field{db}}"; } else { open DATA, "$orf_data_location{$field{db}}"; open GIF, "$orf_gif_location{$field{db}}"; $orf_checked = "CHECKED"; $title = "Composition of all ORFs in $database_string{$field{db}} $database_url{$field{db}}"; } @data = ; close DATA; @gif = ; close GIF; $gif = join("", @gif); if ($dbOK) { for ($i=1;$i<21;$i++) { $line = $data[$i]; $line =~ s/\n//g; ($res[$i-1], $count[$i-1]) = split("\t", $line); $total += $count[$i-1]; } for ($i=0;$i<20;$i++) { $frac[$i] = 100 * $count[$i] / $total; $frac[$i] = &RoundNumber($frac[$i], 1); } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "TMSTAT - Composition\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "
\"Yale\"\"Gerstein\n"; print "\n"; print "\"Parts\"GeneCensus\"\n"; print "\"help\"\"download\"
\n"; print "Composition of genome ORFs and transmebrane domains
\n"; print "
\n"; print "$title
\n"; print "
\n"; print "\n"; print "Genome:
\n"; print "\n"; print " Composition of ORFs
\n"; print " Composition of transmembrane domains
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($dbOK) { for ($i=0;$i<20;$i++) { print "\n"; print "\n"; print "\n"; } } print "
ResidueTotal%
$res[$i]$count[$i]$frac[$i]
\n"; print "
\n"; } sub ReadParse { my $buffer; my $pair; my @pairs; my $name; my $value; my $ErrorCode; if ($ENV{'REQUEST_METHOD'} eq 'POST') { if ($ENV{'CONTENT_LENGTH'} > 1000) { $ErrorCode = "24"; return ($ErrorCode); } read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { if (length($ENV{'QUERY_STRING'}) < 1000) { $buffer = $ENV{'QUERY_STRING'}; } else { $ErrorCode = "25"; return ($ErrorCode); } } @pairs = split (/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split (/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\r\n/\n/g; $field{$name} .= $value; } return (0); } sub RoundNumber { my $number = shift; my $decimals = shift; my $pos; $number *= (10 ** int($decimals)); if ($number > 0) { $number += 0.5; } else { $number -= 0.5; } $number = int($number); $number /= (10 ** int($decimals)); if ($number =~ /\./g) { $pos = pos($number); while (length($number) < $pos + $decimals) { $number .= "0"; } } else { $number .= "."; $number =~ /\./g; $pos = length($number); while (length($number) < $pos + $decimals) { $number .= "0"; } } return $number; } sub Error() { my $code = shift; print "Error $code
\n"; }