[Bio] / FigWebServices / graph_exp.cgi Repository:
ViewVC logotype

View of /FigWebServices/graph_exp.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Tue May 25 21:21:13 2010 UTC (9 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
expression data grapher

use FIG;
use CGI;
use strict;
use Data::Dumper;

my $fig = new FIG;

my $cgi = new CGI;

my @checked = $cgi->param("checked");
my $sort_by = $cgi->param("sort_by");

print $cgi->header;

if ((grep { $_ eq $sort_by } @checked) == 0)
{
    push(@checked, $sort_by);
}

my $genome = $fig->genome_of($sort_by);

# my $orgdir = $FIG_Config::organisms;
my $orgdir = "/home/overbeek/Proj/FIGdisk/FIG/Data/Organisms";

if (!open(R, "<", "$orgdir/$genome/UserSpace/ExpressionData/raw_data.tab"))
{
    print "No expression data found for $sort_by\n";
    exit;
}

my %dat;
my $n_left = @checked;
my %want = map { $_ => 1 } @checked;

my $n;
while (<R>)
{
    chomp;
    my($id, @dat) = split(/\t/);
    if ($want{$id})
    {
	$dat{$id} = [@dat];
	$n = @dat;
	$n_left--;
	last if $n_left == 0;
    }
}

my $base = "graph_exp.$$";
my $out_s = "$FIG_Config::temp/$base.dat";

my @dat_order = ($sort_by);
delete $want{$sort_by};
push(@dat_order, keys %want);

open(OS, "| sort -n > $out_s") or die $!;

my @plots;
my $col = 1;
for my $peg (@dat_order)
{
    push(@plots, qq("$out_s" using $col with points title "$peg"));
    $col++;
}

#print Dumper(\@dat_order, \%dat);
for my $i (1..$n)
{
    my @row;
    for my $peg (@dat_order)
    {
	push(@row, shift @{$dat{$peg}});
    }
    print OS join("\t", @row), "\n";
}
close(OS);

my $plot = "$FIG_Config::temp/$base.png";

my $plots = join(", ", @plots);

open(G, "|/opt/bcr/2008-0612/linux-debian-x86_64/bin/gnuplot") or die $!;
print G <<END;
set term png
set output "$plot"
plot $plots
set output
END
    
close(G);

my $tmp = "$FIG_Config::temp_url/$base.png";
print "<img src='$tmp'>\n";

unlink($out_s);


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3