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

Annotation of /FigWebServices/ss_directed_compare_regions.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : overbeek 1.1 ########################################################################
2 :     use CGI;
3 :    
4 :    
5 :     if (-f "$FIG_Config::data/Global/why_down")
6 :     {
7 :     local $/;
8 :     open my $fh, "<$FIG_Config::data/Global/why_down";
9 :     my $down_msg = <$fh>;
10 :    
11 :     print CGI::header();
12 :     print CGI::head(CGI::title("SEED Server down"));
13 :     print CGI::start_body();
14 :     print CGI::h1("SEED Server down");
15 :     print CGI::p("The seed server is not currently running:");
16 :     print CGI::pre($down_msg);
17 :     print CGI::end_body();
18 :     exit;
19 :     }
20 :    
21 :     if ($FIG_Config::readonly)
22 :     {
23 :     CGI::param("user", undef);
24 :     }
25 :     # -*- perl -*-
26 :     #
27 :     # Copyright (c) 2003-2008 University of Chicago and Fellowship
28 :     # for Interpretations of Genomes. All Rights Reserved.
29 :     #
30 :     # This file is part of the SEED Toolkit.
31 :     #
32 :     # The SEED Toolkit is free software. You can redistribute
33 :     # it and/or modify it under the terms of the SEED Toolkit
34 :     # Public License.
35 :     #
36 :     # You should have received a copy of the SEED Toolkit Public License
37 :     # along with this program; if not write to the University of Chicago
38 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
39 :     # Genomes at veronika@thefig.info or download a copy from
40 :     # http://www.theseed.org/LICENSE.TXT.
41 :     #
42 :    
43 :    
44 :     use strict;
45 :     use Data::Dumper;
46 :    
47 :     use FIG;
48 :     use FIG_CGI;
49 :    
50 :     use URI::Escape; # uri_escape
51 :     use HTML;
52 :     my $fig = new FIG;
53 :     use CGI;
54 :     my $cgi = new CGI;
55 :    
56 :     if (0)
57 :     {
58 :     print $cgi->header;
59 :     my @params = $cgi->param;
60 :     print "<pre>\n";
61 :     foreach $_ (@params)
62 :     {
63 :     print "$_\t:",join(",",$cgi->param($_)),":\n";
64 :     }
65 :     exit;
66 :     }
67 :    
68 :     my $subsys = "/vol/core-seed/FIGdisk/FIG/Data/Subsystems";
69 :    
70 :     my $html = [];
71 :     unshift @$html, "<TITLE>Subsystem-based compare-regions</TITLE>\n";
72 :     my $ss = $cgi->param('ss');
73 :     my $abbr = $cgi->param('abbr');
74 :    
75 :     if ((! $ss) || (! $abbr))
76 :     {
77 :     push(@$html,"<h1> ERROR: You need to use ss= and abbr= parameters</h1>");
78 :     &HTML::show_page($cgi,$html);
79 :     exit;
80 :     }
81 :     if (! -s "$subsys/$ss/spreadsheet")
82 :     {
83 :     push(@$html,"<h1> ERROR: No such subsystemp in coreSEED ($subsys)</h1>");
84 :     &HTML::show_page($cgi,$html);
85 :     exit;
86 :     }
87 :     my @pegs = &pegs_in_spreadsheet("$subsys/$ss",$abbr);
88 :    
89 :     if (@pegs == 0)
90 :     {
91 :     push(@$html,"<h1> ERROR: No pegs in $abbr of $subsys</h1>");
92 :     &HTML::show_page($cgi,$html);
93 :     exit;
94 :     }
95 :    
96 :     my $number_pegs = $cgi->param('n');
97 :     if (! $number_pegs) { $number_pegs = 10 }
98 :     while (@pegs > 0)
99 :     {
100 :     my $sz = (@pegs > $number_pegs) ? $number_pegs : @pegs;
101 :     my @batch = splice(@pegs,0,$sz);
102 :     my $start_href = &link(\@batch);
103 :     my $start_link = "<a target=_blank href=$start_href>$batch[0]</a>\n";
104 :     push(@$html,"<br><br>",$start_link,"<br>\n");
105 :     }
106 :    
107 :     &HTML::show_page($cgi,$html);
108 :    
109 :     sub link {
110 :     my($pegs) = @_;
111 :    
112 :     my $features = join('&feature=',@$pegs);
113 :     return "http://core.theseed.org/FIG/seedviewer.cgi?page=Regions&feature=" . $features;
114 :     }
115 :    
116 :     sub pegs_in_spreadsheet {
117 :     my($ssF,$abbr) = @_;
118 :    
119 :     my $spreadsheet = join("",`cat $ssF/spreadsheet`);
120 :     my($hdrs,undef,$genomes) = split(/\n\/\/\n/,$spreadsheet);
121 :     my @hdrs = map { ($_ =~ /^(\S+)/) ? $1 : () } split(/\n/,$hdrs);
122 :     my $i;
123 :     for ($i=0; ($i < @hdrs) && ($hdrs[$i] ne $abbr); $i++) {}
124 :     my @pegs;
125 :     foreach $_ (split(/\n/,$genomes))
126 :     {
127 :     my @rows = split(/\t/,$_);
128 :     my $g = shift @rows;
129 :     shift @rows; # dump variant code
130 :     push(@pegs,map { "fig|$g.peg.$_" } split(/,/,$rows[$i]));
131 :     }
132 :     return @pegs;
133 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3