[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.5 - (view) (download)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3