<& $url_root . "/menu" &>
% if($m->dhandler_arg eq "settings") { <& $url_root . "/page-settings", cookie_data=>$cookie_data &> % } elsif ($m->dhandler_arg eq "archive") { <& $url_root . "/page-archive", cookie_data=>$cookie_data, usrimg_sub=>$usrimg_sub, usrimg_root=>$usrimg_root, temp_dirroot=>$temp_dirroot &> % } elsif ($m->dhandler_arg eq "docs") { <& $url_root . "/page-documentation" &> % } elsif ($m->dhandler_arg eq "samples") { <& $url_root . "/page-samples", system_is_free=>$system_is_free &> % } elsif (! param("tablefile")) {

4 what is this?

<& $url_root . "/page-intro" &>

5 panel

<& $url_root . "/panel" &>

6 privacy

<& $url_root . "/page-privacy" &>

7 updates

<& $url_root . "/page-updates" &>

0 read slogan badges

<& $url_root . "/page-slogan" &>

1 check data format

<& $url_root . "/page-format_warning" &>

2a upload your file

% if ($system_is_free) { <& $url_root . "/uploadform" &> % } else {
System is busy drawing tables. Try again later.
% }

2b try random data

% if ($system_is_free) { <& $url_root . "/random_form" &> % } else {
System is busy drawing tables. Try again later.
% }

3 wait 4-7 seconds

Current load is <% int(@pids) %>/5. System is <% $system_is_free ? "" : "un" %>available.


% } else { %################################################################ %# %# write the uploaded file to a local temporary file in /tmp %# convert the uploaded file to text %# %################################################################ % my ($converted_text,$trouble); <%perl> $m->comp("$url_root/timers",timers=>$timers,name=>"total",action=>"start"); # register our job pid $m->comp("SELF:add_pid"); # if we have an uploaded file, write it to a temporary file in ~/www/htdocs/tmp if(param("tablefile") && ( upload("tablefile") || param("sample") )) { $tempfilename = $m->comp( $url_root . "/write-uploaded-file", random_string=>$random_string, temp_dirroot=>$temp_dirroot ); } elsif (param("tablefile") =~ /(\d+) x (\d+)/) { my ($rows,$cols) = (int($1),int($2)); $rows = 15 if $rows > 15; $cols = 15 if $cols > 15; $rows = 1 if $rows < 0; $cols = 1 if $cols < 0; $tempfilename = sprintf("%s/%s/uploads/table.txt",$temp_dirroot,$random_string); mkpath(dirname($tempfilename),0,0777); my $options; $options = "-unique" if ($rows == 15 && $cols == 1) || ($rows == 10 && $cols == 2); my $make_table_cmd = qq{/usr/bin/perl $bin_dir/make-table -rows $rows -cols $cols -rule_set websample -brief $options > $tempfilename ; chmod a+rw $tempfilename}; `$make_table_cmd`; } # if the temporary file exists and is not zero, read it into @tabledata # and strip leading spaces my @tabledata; if ($tempfilename) { if(-e $tempfilename && ! -z _) { open(F,$tempfilename); @tabledata = map { s/^\s+//g; $_; } ; close(F); } else { push @errors, "Error writing to temporary file."; } } ################################################################ # # if we have table data, show it, otherwise show the title page # ################################################################ my $verbose_options = []; if (@tabledata) { mkpath("$temp_dirroot/$random_string/data",0,0777); mkpath("$temp_dirroot/$random_string/etc",0,0777); mkpath("$temp_dirroot/$random_string/results",0,0777); # parse table data into input data files my $options; ($options,$verbose_options) = $m->comp( $url_root."/parse-options", params=>{Vars()}, cookie_data=>$cookie_data ); my $option_text = join(" ",@$options); my $err_file = "$temp_dirroot/$random_string/data/stderr.txt"; my $conf_file = $m->comp("SELF:comp_file_dir")."/samplefiles/etc/parse-table.conf"; my $parsed_file = "$temp_dirroot/$random_string/data/parsed.txt"; my $cmd = "/usr/bin/perl $bin_dir/parse-table -conf $conf_file -file $tempfilename $option_text > $parsed_file 2> $err_file"; #$m->out($cmd); $m->comp("$url_root/timers",timers=>$timers,name=>"parse",action=>"start"); `$cmd`; $m->comp("$url_root/timers",timers=>$timers,name=>"parse",action=>"stop"); if(-s $err_file) { # crap - some error! open(F,$err_file); push @errors, ; close(F); } elsif ( ! -e $parsed_file ) { push @errors, "Could not parse the table file. Table parser failed fatally?"; } else { $m->comp("$url_root/timers",timers=>$timers,name=>"conf",action=>"start"); `cat $parsed_file | $bin_dir/make-conf -dir $temp_dirroot/$random_string/data`; $m->comp("$url_root/timers",timers=>$timers,name=>"conf",action=>"stop"); # create circos configuration $m->comp("$url_root/timers",timers=>$timers,name=>"fileprep",action=>"start"); my $etc_root = $m->comp("SELF:comp_file_dir") . "/samplefiles/etc"; copy("$etc_root/colors.conf","$temp_dirroot/$random_string/etc/colors.conf"); copy("$etc_root/ideogram.conf","$temp_dirroot/$random_string/etc/ideogram.conf"); copy("$etc_root/ticks.conf","$temp_dirroot/$random_string/etc/ticks.conf"); copy("$etc_root/circos.conf","$temp_dirroot/$random_string/etc/circos.conf"); # replace usertext* keywords in configuration with values # $CONF{usertext1} -> random string # $CONF{usertext2} -> tmp dir my $sed_command = qq{cat $temp_dirroot/$random_string/etc/circos.conf | sed 's/__\$CONF{usertext1}__/$random_string/g' | sed 's,__\$CONF{usertext2}__,$temp_dirroot,g' > $temp_dirroot/$random_string/etc/tmp.conf ; \\cp $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf}; `$sed_command`; # process circos.conf, replacing elements as necessary based on cookie values # no absolute tick marks if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"hide_ticks_absolute")) { `sed 's/^show.*=.*\#.*tick_absolute/show = no/' $temp_dirroot/$random_string/etc/ticks.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/ticks.conf`; } # no relative ticks if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"hide_ticks_relative")) { `sed 's/^show.*=.*\#.*tick_relative/show = no/' $temp_dirroot/$random_string/etc/ticks.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/ticks.conf`; } # no tick labels if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"hide_tick_labels")) { `sed 's/^show_tick_labels.*/show_tick_labels = no/' $temp_dirroot/$random_string/etc/ticks.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/ticks.conf`; } # no cell/row labels if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"hide_labels")) { `sed 's/^show.*=.*\#.*cell_label.*/show = no/' $temp_dirroot/$random_string/etc/circos.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf`; } # no contribution highlights if ($m->comp("incookie",cd=>$cookie_data,s=>"contribution_tracks",v=>"hide_highlights")) { `sed 's/^show.*=.*\#.*highlights.*/show = no/' $temp_dirroot/$random_string/etc/circos.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf`; `sed 's/^offset.*=.*\#.*relative_offset.*/offset = 60p/' $temp_dirroot/$random_string/etc/ticks.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/ticks.conf`; } # no stroke on contribution highlights if ($m->comp("incookie",cd=>$cookie_data,s=>"contribution_tracks",v=>"no_stroke_on_highlights")) { `sed 's/^stroke_thickness.*\#.*highlight_stroke/stroke_thickness = 0/g' $temp_dirroot/$random_string/etc/circos.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf`; } # no stroke on elements if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"no_stroke")) { `sed 's/^stroke_thickness.*/stroke_thickness = 0/' $temp_dirroot/$random_string/etc/circos.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf`; `sed 's/^stroke_thickness.*/stroke_thickness = 0/' $temp_dirroot/$random_string/etc/ideogram.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/ideogram.conf`; } # angle start 0 if ($m->comp("incookie",cd=>$cookie_data,s=>"format",v=>"angle_start")) { `sed 's/^angle_offset.*=.*/angle_offset = 0/' $temp_dirroot/$random_string/etc/circos.conf > $temp_dirroot/$random_string/etc/tmp.conf ; \\mv $temp_dirroot/$random_string/etc/tmp.conf $temp_dirroot/$random_string/etc/circos.conf`; } $m->comp("$url_root/timers",timers=>$timers,name=>"fileprep",action=>"stop"); $m->comp("$url_root/timers",timers=>$timers,name=>"draw",action=>"start"); # draw image # generate a large 2000 x 2000 image my $cmd_circos = qq{/usr/bin/perl /home/martink/work/circos/svn-tags/release-0.52-tableviewer/bin/circos -conf $temp_dirroot/$random_string/etc/circos.conf 2>&1 > $file_report}; `$cmd_circos`; #$m->out($cmd_circos); $m->comp("$url_root/timers",timers=>$timers,name=>"draw",action=>"stop"); # rescale image to 790 x 790 pixels for web my $waited = $m->comp( $url_root . "/wait_for_file", file=> $file_img_large ); #"$temp_dirroot/$random_string/results/circos-table-$random_string-large.png" ); #$m->out("waited $waited for -large"); if(-e $file_img_large ) { $m->comp("$url_root/timers",timers=>$timers,name=>"resize1",action=>"start"); `/usr/bin/convert $file_img_large -scale 780x780 $file_img_medium 2>&1 >> $file_report`; $m->comp("$url_root/timers",timers=>$timers,name=>"resize1",action=>"stop"); } else { push @errors, "Circos image output ($file_img_large) could not be found."; } $waited = $m->comp( $url_root . "/wait_for_file", file=>$file_img_medium); #$m->out("waited $waited for smaller"); if(! -e $file_img_medium) { push @errors, "There was a problem creating resized image."; } # rescale further to 390 x 390 pixels for userimg archive my $cmd = "/usr/bin/convert $file_img_medium -scale 195x195 -quality 80 $file_img_archive 2>&1 >> $file_report"; $m->comp("$url_root/timers",timers=>$timers,name=>"resize2",action=>"start"); `$cmd`; $m->comp("$url_root/timers",timers=>$timers,name=>"resize2",action=>"stop"); $cmd = "cd $temp_dirroot/$random_string ; tar cvfz $tarball *"; $m->comp("$url_root/timers",timers=>$timers,name=>"archive",action=>"start"); `$cmd`; $m->comp("$url_root/timers",timers=>$timers,name=>"archive",action=>"stop"); #$m->out($cmd); `chmod -R a+rw $temp_dirroot/$random_string`; $m->out(""); } # we're done - delete the job file $m->comp("SELF:del_pid"); $m->comp("$url_root/timers",timers=>$timers,name=>"total",action=>"stop"); # create timing data my @timing_names = qw(parse conf fileprep draw resize1 resize2 archive); my $timefile = sprintf("%s/timing/%s.txt",$m->comp("SELF:comp_file_dir"),$random_string); if(open(F,">>$timefile")) { my $stamp = strftime "%Y%m%d-%H%M%S", localtime; my @timings = map { $m->comp("$url_root/timers",timers=>$timers,name=>$_) } ("total",@timing_names); print F join(" ",$stamp,$r->connection->remote_ip,$random_string,@timings),"\n"; close(F); } else { push @errors, "Problem writing to timing file."; } % if (@errors) {

An error has occurred. No image has been created.

<% join("\n",@errors) | h %>

if your data file contains order, size and/or color information for rows and/or columns please check off the appropriate options in the upload form. If you have set these options, make sure that your data file has the required information.

Please read the data samples section to read about data format requirements.

You can try again or write to me (attach your file and the error report). % } else {

Your table image is ready!

% for my $timing_name (@timing_names,"total") {
<% $timing_name %>
<% sprintf("%0.2f s",$m->comp("$url_root/timers",timers=>$timers,name=>$timing_name)) %>
% } % my $file = sprintf("%s/tmp/%s/circos-tableviewer-data-%s.tar.gz",$m->comp("SELF:comp_file_dir"),$random_string,$random_string); <%doc> % # do not show the size of the tarball - it is being created in the background and the file % # is not yet ready at this stage % if(-e $file) { % my $file_size = -s $file;
output
<% int($file_size/1000) %> kb
% }
% my $dataurl = sprintf("%s/tmp/%s",$m->comp("SELF:comp_url_dir"),$random_string); % my $fileurl = sprintf("%s/circos-tableviewer-data-%s.tar.gz",$dataurl,$random_string);

Download: large image | data, images (PNG/SVG) and configuration

% }

table data used for figure

<& $url_root . "/page-samples:showfile", dir=>"tmp/$random_string/uploads", file=>"table.txt", nobuttons=>1 &>

display options

% if(@$verbose_options) {
    % for my $vo (@$verbose_options) {
  • <%$vo%> % }
% } else {

Default formatting values used for figure generation. % }

You can change the settings at any time. If you require finer control over the image, you should download Circos and use the bundled /intro/tabular_visualization">tableviewer utility.

% } % }
<%doc> % if ($connection_is_local) {
<% Dumper($params) %>
<% Dumper($cookie_data) %>
<& "/tools:ShowCGIParam" &> <& "/tools:ShowEnv" &> <& "/tools:ShowCookie", cookie=>$cookie, name=>$cookiename &> % } <%init> use Apache2::Cookie; use Apache2::Connection; use Math::VecStat qw(sum min max); use Time::HiRes qw(gettimeofday tv_interval); use String::Random qw(random_string); use File::Copy; use File::Temp qw(tempfile tempdir); use File::Path qw(mkpath); use File::Basename; use Data::Dumper; use IO::File; use CGI qw/:all :cgi-lib/; use Storable qw(freeze thaw); use MIME::Base64; use POSIX qw(strftime); use vars qw($tempfh $tempfilename $tempfilename_root $params); my @errors; my $timers = {}; my $version = 0.52; my $url_root = $m->comp("SELF:url_root"); my @param_keys = $m->comp( sprintf("%s/configuration:getsections",$url_root) ); my $params = Vars(); my $remote_ip = $r->connection->remote_ip; my $connection_is_local = $remote_ip =~ /^10\.9\./; my (@cookie_values,$cookie_data); my $cookie = Apache2::Cookie->fetch($r); my $cookiename = basename($url_root); if(exists $cookie->{$cookiename} && param('submit') ne "reset") { eval { $cookie_data = thaw(MIME::Base64::decode($cookie->{$cookiename}->value)); }; # supplement cookie data with cgi parameters for my $key (@param_keys) { my @list = param($key); if(@list) { $cookie_data->{$key} = \@list; } } } if ($@ || ! $cookie->{$cookiename} || ! $cookie_data || defined param('submit')) { my $param_hash = {}; if(param('submit') ne "reset") { for my $key (@param_keys) { my @list = param($key); $param_hash->{$key} = \@list; } } my $newcookie = Apache2::Cookie->new($r,-name=>$cookiename,-expires=>"+30d",-path=>"/", -value=>MIME::Base64::encode(freeze($param_hash))); $cookie_data = thaw(MIME::Base64::decode($newcookie->value)); $newcookie->bake($r); } #$m->out("
".Dumper($cookie_data)."
"); my $random_string = random_string("ccccccc"); $random_string .= "samp" if param("sample"); $random_string .= "rand" if param("tablefile") =~ /(\d+) x (\d+)/; my $usrimg_sub = "userimg"; my $usrimg_root = $m->comp("SELF:comp_file_dir") . "/$usrimg_sub"; my $temp_dirroot = $m->comp("SELF:comp_file_dir") . "/tmp"; my $file_report = "$temp_dirroot/$random_string/results/report.txt"; my $file_img_large = "$temp_dirroot/$random_string/results/circos-table-$random_string-large.png"; my $file_img_medium = "$temp_dirroot/$random_string/results/circos-table-$random_string.png"; my $file_img_archive = "$usrimg_root/circos-table-$random_string.jpg"; my $tarball = "circos-tableviewer-data-$random_string.tar.gz"; my $bin_dir = "/home/martink/work/circos/svn-tags/release-0.52-tableviewer/tools/tableviewer/bin"; my $transparency = 2; my $fade_transparency = 4; my $max_load = 5; # check whether the system is free - first expire old files $m->comp("SELF:expire_pids"); my @pids = $m->comp("SELF:get_pids"); my $system_is_free = @pids < $max_load; <%method title> Circos Table Viewer - Using Circles to Visualize Tabular Data