######################################################################## use CGI; use FIG_Config; if (-f "$FIG_Config::data/Global/why_down") { local $/; open my $fh, "<$FIG_Config::data/Global/why_down"; my $down_msg = <$fh>; print CGI::header(); print CGI::head(CGI::title("SEED Server down")); print CGI::start_body(); print CGI::h1("SEED Server down"); print CGI::p("The seed server is not currently running:"); print CGI::pre($down_msg); print CGI::end_body(); exit; } if ($FIG_Config::readonly) { CGI::param("user", undef); } # -*- perl -*- # # Copyright (c) 2003-2008 University of Chicago and Fellowship # for Interpretations of Genomes. All Rights Reserved. # # This file is part of the SEED Toolkit. # # The SEED Toolkit is free software. You can redistribute # it and/or modify it under the terms of the SEED Toolkit # Public License. # # You should have received a copy of the SEED Toolkit Public License # along with this program; if not write to the University of Chicago # at info@ci.uchicago.edu or the Fellowship for Interpretation of # Genomes at veronika@thefig.info or download a copy from # http://www.theseed.org/LICENSE.TXT. # use strict; use Data::Dumper; use FIG; use FIG_CGI; use URI::Escape; # uri_escape use HTML; my $fig = new FIG; use CGI; my $cgi = new CGI; if (0) { print $cgi->header; my @params = $cgi->param; print "
\n";
    foreach $_ (@params)
    {
	print "$_\t:",join(",",$cgi->param($_)),":\n";
    }
    exit;
}

my $subsys = "$FIG_Config::data/Subsystems"; 
#my $subsys = "/vol/core-seed/FIGdisk/FIG/Data/Subsystems";

my $html = [];
unshift @$html, "Subsystem-based compare-regions\n";
my $ss = $cgi->param('ss');
my $abbr = $cgi->param('abbr');

if ((! $ss) || (! $abbr))
{   
    push(@$html,"

ERROR: You need to use ss= and abbr= parameters

"); &HTML::show_page($cgi,$html); exit; } if (! -s "$subsys/$ss/spreadsheet") { push(@$html,"

ERROR: No such subsystemp in coreSEED ($subsys)

"); &HTML::show_page($cgi,$html); exit; } my @pegs = &pegs_in_spreadsheet("$subsys/$ss",$abbr); if (@pegs == 0) { push(@$html,"

ERROR: No pegs in $abbr of $subsys

"); &HTML::show_page($cgi,$html); exit; } my $number_pegs = $cgi->param('n'); if (! $number_pegs) { $number_pegs = 10 } while (@pegs > 0) { my $sz = (@pegs > $number_pegs) ? $number_pegs : @pegs; my @batch = splice(@pegs,0,$sz); my $start_href = &link(\@batch); my $start_link = "$batch[0]\n"; push(@$html,"

",$start_link,"
\n"); } &HTML::show_page($cgi,$html); sub link { my($pegs) = @_; my $features = join('&feature=',@$pegs); return "$FIG_Config::cgi_url/seedviewer.cgi?page=Regions&feature=" . $features; #return "http://core.theseed.org/FIG/seedviewer.cgi?page=Regions&feature=" . $features; } sub pegs_in_spreadsheet { my($ssF,$abbr) = @_; my $spreadsheet = join("",`cat $ssF/spreadsheet`); my($hdrs,undef,$genomes) = split(/\n\/\/\n/,$spreadsheet); my @hdrs = map { ($_ =~ /^(\S+)/) ? $1 : () } split(/\n/,$hdrs); my $i; for ($i=0; ($i < @hdrs) && ($hdrs[$i] ne $abbr); $i++) {} my @pegs; foreach $_ (split(/\n/,$genomes)) { my @rows = split(/\t/,$_); my $g = shift @rows; shift @rows; # dump variant code push(@pegs,map { "fig|$g.peg.$_" } split(/,/,$rows[$i])); } return @pegs; }