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

Diff of /FigWebServices/subsys_summary.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Sat Feb 12 19:28:04 2005 UTC revision 1.3, Sat Feb 12 20:18:22 2005 UTC
# Line 81  Line 81 
81   push @th, 'Subsystem'; # we should have this, at least   push @th, 'Subsystem'; # we should have this, at least
82   if ($cgi->param('genomes')) {push @th, ('Organisms')}   if ($cgi->param('genomes')) {push @th, ('Organisms')}
83   if ($cgi->param('stats')) {push @th, ('Roles', 'Total Pegs', @wants)}   if ($cgi->param('stats')) {push @th, ('Roles', 'Total Pegs', @wants)}
84   elsif ($cgi->param('roles')) {push @th, ('Roles', @wants)}   elsif ($cgi->param('korgs')) {push @th, ('Roles', @wants)}
85    
86   my $tableheader="<tr><th>". (join "</th><th>", @th) . "</th></tr>\n\n";   my $tableheader="<tr><th>". (join "</th><th>", @th) . "</th></tr>\n\n";
87    
# Line 89  Line 89 
89   my $table;   my $table;
90   foreach my $subsys ($fig->all_subsystems) {   foreach my $subsys ($fig->all_subsystems) {
91    
   # add a header  
   unless ($cgi->param('stats')) {$table .= "<tr><td colspan=$cols align=center><strong>Subsystem: $subsys</strong></td></tr>\n"}  
   
92    # figure out how many roles we have, as this will determine the number of rows in the table    # figure out how many roles we have, as this will determine the number of rows in the table
93    my @roles=$fig->subsystem_to_roles($subsys);    my @roles=$fig->subsystem_to_roles($subsys);
94    my $rows=1;    my $rows=1;
95    if (!$cgi->param('stats') && $cgi->param('roles')) {$rows=scalar @roles}    if (!$cgi->param('stats') && $cgi->param('korgs')) {$rows=scalar @roles}
96    
97    # figure out which genomes are in this subsystem    # figure out which genomes are in this subsystem
98    my %genomes;    my %genomes;
99    foreach my $gen (@{$fig->subsystem_genomes($subsys)}) {$genomes{$gen->[0]}=$gen->[1]}    foreach my $gen (@{$fig->subsystem_genomes($subsys)}) {$genomes{$gen->[0]}=$gen->[1]}
100    
101    # start a new row for this data    # start a new row for this data
102    $table .= "\n<tr>\n";    # tablerows is a refence to an array.
103      # each element is an array of tablecells with the following values colspan rowspan value
104      my $tablerows;
105    
106    # get the classification if required    # get the classification if required
107    if ($cgi->param('levels')) {    if ($cgi->param('levels')) {
# Line 114  Line 113 
113     # remove anything more than $$class[1];     # remove anything more than $$class[1];
114     @$class=($$class[0], $$class[1]); # could have done this with splice. Ech.     @$class=($$class[0], $$class[1]); # could have done this with splice. Ech.
115    
116     $table .= "\n\t<td rowspan='$rows'>" . (join "</td>\n\t<td rowspan='$rows'>", (@$class)) . "</td>";     foreach my $c (@$class) {
117        push @$tablerows, ['1', $rows, $c];
118       }
119    }    }
120    
121    # add the subsystem to the table    # add the subsystem to the table
122    $table .= "\n\t<td><strong>$subsys<strong></td>";    push @$tablerows, ['1', $rows, "<strong>$subsys<strong>"];
123    
124    # add the genomes in the subsystem    # add the genomes in the subsystem
125    if ($cgi->param('genomes') && $cgi->param('stats')) {$table .= "\n\t<td rowspan='$rows'>" . (scalar keys %genomes) . " </td>"}    if ($cgi->param('genomes') && $cgi->param('stats')) {push @$tablerows, ['1', $rows, (scalar keys %genomes)]}
126    elsif ($cgi->param('genomes')) {$table .= "\n\t<td rowspan='$rows'> &nbsp; " . (join "<br>\n", sort {$a cmp $b} values %genomes) . "</td>"}    elsif ($cgi->param('genomes')) {
127       my $c=join "<br>\n", sort {$a cmp $b} values %genomes;
128       push @$tablerows, ['1', $rows, $c];
129      }
130    
131    
132      #
133      # This is convolvuted because we may want to skip some empty cells, but we won't know whether
134      # we want to skip them. Also, we are using rowspan/colspan to determine the size of the cells
135      # so we need everything defined
136      #
137      # I store the table initially in @$tablerows, and then push it into @$table. Later on we
138      # reconstruct @$table with <td> etc....
139      #
140      # Now I am going to store the rows in @$toadd, and if we want them I will add them to @$table.
141      #
142      # For stats, there is only one row in @$toadd, but for other data there are several because
143      # of the use of rowspan
144    
145      my $pegcount;
146      my $toadd; #this is what we will add if we need to
147    if ($cgi->param('stats')) {    if ($cgi->param('stats')) {
148     my $pegcount=0;     push @$tablerows, ['1', $rows, (scalar @roles)];
149     $table .= "\n\t<td>" . (scalar @roles) . "</td>"; #number of roles in the subsystem     my $totalpegs;
    my $pegcount; my $totalpegs;  
150     # there should be a quicker way of getting this ... ?     # there should be a quicker way of getting this ... ?
151     foreach my $role (@roles) {     foreach my $role (@roles) {
152      foreach my $genome (keys %genomes) {      foreach my $genome (keys %genomes) {
# Line 137  Line 156 
156      }      }
157     }     }
158    
159     $table .= "\n\t<td>$totalpegs</td>"; # all the pegs in the subsystem     push @$tablerows, ['1', $rows, $totalpegs];
160     foreach my $w (@wants) {     foreach my $w (@wants) {
161      $table .= "\n\t<td>$pegcount->{$w}</td>"; # pegs for each of the chosen genomes      push @$tablerows, ['1', $rows, $pegcount->{$w}]; # pegs for each of the chosen genomes
162     }     }
163     $table .= "</tr>\n";     push @$toadd, $tablerows;
164    }    }
165    elsif ($cgi->param('roles')) {    elsif ($cgi->param('korgs')) {
166     # now add the roles     # now add the roles
167     my $first=1;     my $first=1;
168     foreach my $role (@roles) {     foreach my $role (@roles) {
# Line 155  Line 174 
174         $cell .= &HTML::fid_link($cgi,$peg) . "; ";         $cell .= &HTML::fid_link($cgi,$peg) . "; ";
175        }        }
176       }       }
177       $genomeroles .= "\n\t<td>$cell</td>";       push @$genomeroles, [1, 1, $cell];
178      }      }
179      # because I am using rowspan to make long columns, we don't want the tr on the first of these.      # because I am using rowspan to make long columns, we don't want the tr on the first of these.
180      if ($first) {$table .= "\n\t<td>$role</td>" . $genomeroles . "</tr>\n"; $first=0}      if ($first) {
181      else {$table .= "\n\t<tr><td>$role</td>" . $genomeroles . "</tr>\n"}       push @$tablerows, (['1', '1', $role], @$genomeroles);
182         push @$toadd, $tablerows;
183        }
184        else {
185         my $tr=[('1', '1', $role), @$genomeroles];
186         push @$toadd, $tr;
187     }     }
188    }    }
   else {$table .= "</tr>\n"}  
189   }   }
190   push @$html, ("\n<table border=1>" . $tableheader . $table . "</table>\n");    unless ($toadd) {$toadd=$tablerows} # in case we didn't define it
191      # now decide if we want the table
192      if ($cgi->param('orgpegs')) {
193       my $mustadd;
194       foreach my $org (@wants) {if ($pegcount->{$org}) {$mustadd=1}} # we'll add it if one of the orgs has a role
195       if ($mustadd) {push @$table, @$toadd}
196      }
197      elsif ($cgi->param("haveroles")) {
198       if (scalar(@roles)) {push @$table, @$toadd}
199      }
200      else {
201       push @$table, @$toadd;
202      }
203     }
204    
205     # now convert $table into a table
206    
207     my $tab;
208     foreach my $row (@$table) {
209      $tab .= "\n<tr>";
210      foreach my $cell (@$row) {
211       $tab .= "\n\t<td colspan=$cell->[0] rowspan=$cell->[1]>$cell->[2]</td>";
212      }
213      $tab .= "\n</tr>\n";
214     }
215    
216     push @$html, ("\n<table border=1>" . $tableheader . $tab . "</table>\n");
217  }  }
218    
219    
# Line 254  Line 303 
303                    $cgi->checkbox(-name=>"stats", -label=>"Only show statistics", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"stats", -label=>"Only show statistics", -checked=>'on'), $cgi->p,
304                    $cgi->checkbox(-name=>"levels", -label=>"Show subsystem classification", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"levels", -label=>"Show subsystem classification", -checked=>'on'), $cgi->p,
305                    $cgi->checkbox(-name=>"genomes", -label=>"Show genomes in subsystem", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"genomes", -label=>"Show genomes in subsystem", -checked=>'on'), $cgi->p,
306                    $cgi->checkbox(-name=>"roles", -label=>"Show roles in subsystem", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"haveroles", -label=>"Show only subsystems that have roles defined", -checked=>'on'), $cgi->p,
307                      $cgi->checkbox(-name=>"orgpegs", -label=>"Show only subsystems that have roles in the organism(s) you have chosen", -checked=>'on'), $cgi->p,
308    
309                    $cgi->end_form,                    $cgi->end_form,
310    
311  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3