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

View of /FigWebServices/ss_directed_compare_regions.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Tue Feb 10 16:50:41 2015 UTC (4 years, 10 months ago) by disz
Branch: MAIN
Changes since 1.1: +5 -2 lines
Changed to use FIG_Config for data source

########################################################################
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 "<pre>\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, "<TITLE>Subsystem-based compare-regions</TITLE>\n";
my $ss = $cgi->param('ss');
my $abbr = $cgi->param('abbr');

if ((! $ss) || (! $abbr))
{   
    push(@$html,"<h1> ERROR: You need to use ss= and abbr= parameters</h1>");
    &HTML::show_page($cgi,$html);
    exit;
}
if (! -s "$subsys/$ss/spreadsheet")
{
    push(@$html,"<h1> ERROR: No such subsystemp in coreSEED ($subsys)</h1>");
    &HTML::show_page($cgi,$html);
    exit;
}
my @pegs = &pegs_in_spreadsheet("$subsys/$ss",$abbr);

if (@pegs == 0)
{
    push(@$html,"<h1> ERROR: No pegs in $abbr of $subsys</h1>");
    &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 = "<a target=_blank href=$start_href>$batch[0]</a>\n";
    push(@$html,"<br><br>",$start_link,"<br>\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;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3