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

View of /FigWebServices/fusions.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Mon Dec 1 16:57:09 2003 UTC (16 years ago) by efrank
Branch: MAIN
Branch point for: initial
Initial revision

use FIG;
my $fig = new FIG;

use HTML;
use CGI;
my $cgi = new CGI;
use GenoGraphics;


if (0)
{
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params)
    {
	print "$_\t:",join(",",$cgi->param($_)),":\n";
    }
    exit;
}

my $html = [];
my $peg = $cgi->param('peg');
if (! $peg)
{
    push(@$html,$cgi->h1("Sorry, but you need to specify a PEG"));
    &HTML::show_page($cgi,$html);
    exit;
}

my @fusions = `$FIG_Config::bin/compute_potential_fusions \'$peg\'`;
if (@fusions < 1)
{
    push(@$html,$cgi->h1("Sorry, no fusions detected"));
    &HTML::show_page($cgi,$html);
    exit;
}

my(@contains,@contained_in);
my($x,$genes,$b,$e,$peg1,$gg);
foreach $_ (@fusions)
{
    chop;
    my($contains,$ln,@parts) = split(/\t/,$_);
    if ($contains eq $peg)
    {
	push(@contains,[@parts]);
	$peg_ln = $ln;
    }
    else
    {
	$key = join(",",map { @f = split(/,/,$_); $f[2] } @parts);
	push(@{$contained_in{$key}}, [$contains,$ln,@parts]);
    }
}

#print &Dumper(["contains",\@contains]);
if (@contains > 0)
{
    push(@$html,$cgi->h1("Given PEG is the Potential Fusion (RED)"));
    if (@contains > 10)
    {
	$_ = @contains;
	push(@$html,$cgi->h1("Truncating from $_ to 10 Cases"));
	$#contains = 9;
    }
	
    $gg = [[&FIG::abbrev($fig->org_of($peg)),1,$peg_ln,[[1,$peg_ln,"rightArrow","red",$peg,&HTML::fid_link($cgi,$peg,0,1)]]]];

    ($x,$genes,$b,$e,$peg1);
    foreach $x (@contains)
    {
	$genes = [];
	foreach $y (@$x)
	{
	    ($b,$e,$peg1) = split(/,/,$y);
	    push(@$genes,[$b,$e,"rightArrow","blue",$peg1,&HTML::fid_link($cgi,$peg1,0,1)]);
	}
	push(@$gg,[&FIG::abbrev($fig->org_of($peg1)),1,$peg_ln,$genes]);
    }
#   print &Dumper(["contains-gg",$gg]);
    push(@$html,@{ &GenoGraphics::render($gg,700,4,0,1) });
    push(@$html,$cgi->hr);
}

#print &Dumper(["contained-in",\%contained_in]);
my(@keys,$key,$contains,@parts);
@keys = keys(%contained_in);
if (@keys > 0)
{
    push(@$html,$cgi->h1("Given PEG (RED) is Potentially Part of a Fusion in Another Genome"));
    foreach $key (@keys)
    {
	$x = $contained_in{$key};
	if (@$x > 10) { $#{$x} = 9 }
	$gg = [];
	foreach $y (@$x)
	{
	    ($contains,$ln,@parts) = @$y;
	    push(@$gg,[&FIG::abbrev($fig->org_of($contains)),1,$ln,[[1,$ln,"rightArrow","blue",$contains,&HTML::fid_link($cgi,$contains,0,1)]]]);
	}
	$genes = [];
	my @just_first = @{$x->[0]};
	splice(@just_first,0,2);
	foreach $part (@just_first)
	{
	    ($b,$e,$peg1) = split(/,/,$part);
	    $color = ($peg1 eq $peg) ? "red" : "green";
	    push(@$genes,[$b,$e,"rightArrow",$color,$peg1,&HTML::fid_link($cgi,$peg1,0,1)]);
	}
	push(@$gg,[&FIG::abbrev($fig->org_of($peg)),1,$x->[0]->[1],$genes]);
#	print STDERR &Dumper($gg);
	push(@$html,@{ &GenoGraphics::render($gg,700,4,0,2) });
	push(@$html,$cgi->hr);
    }
}

&HTML::show_page($cgi,$html);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3