[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.1, Sat Feb 12 06:49:27 2005 UTC revision 1.2, Sat Feb 12 19:28:04 2005 UTC
# Line 77  Line 77 
77    
78    
79   my @th;   my @th;
80   if ($cgi->param('levels')) {push @th, ('Level 1', 'Level 2', 'Level 3')}   if ($cgi->param('levels')) {push @th, ('Level 1', 'Level 2')}
81   if ($cgi->param('genomes')) {push @th, ('Genomes')}   push @th, 'Subsystem'; # we should have this, at least
82   if ($cgi->param('roles')) {push @th, ('roles', @wants)}   if ($cgi->param('genomes')) {push @th, ('Organisms')}
83     if ($cgi->param('stats')) {push @th, ('Roles', 'Total Pegs', @wants)}
84     elsif ($cgi->param('roles')) {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 88  Line 90 
90   foreach my $subsys ($fig->all_subsystems) {   foreach my $subsys ($fig->all_subsystems) {
91    
92    # add a header    # add a header
93    $table .= "<tr><td colspan=$cols align=center><strong>Subsystem: $subsys</strong></td></tr>\n";    unless ($cgi->param('stats')) {$table .= "<tr><td colspan=$cols align=center><strong>Subsystem: $subsys</strong></td></tr>\n"}
94    
95    # 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
96    my @roles=$fig->subsystem_to_roles($subsys);    my @roles=$fig->subsystem_to_roles($subsys);
97    my $rows=1;    my $rows=1;
98    if ($cgi->param('roles')) {$rows=scalar @roles}    if (!$cgi->param('stats') && $cgi->param('roles')) {$rows=scalar @roles}
99    
100    # figure out which genomes are in this subsystem    # figure out which genomes are in this subsystem
101    my %genomes;    my %genomes;
102    foreach my $gen (@{$fig->subsystem_genomes($subsys)}) {$genomes{$gen->[0]}=$gen->[1]}    foreach my $gen (@{$fig->subsystem_genomes($subsys)}) {$genomes{$gen->[0]}=$gen->[1]}
103    
104      # start a new row for this data
105      $table .= "\n<tr>\n";
106    
107    # get the classification if required    # get the classification if required
108    if ($cgi->param('levels')) {    if ($cgi->param('levels')) {
109     # get the classification and make sure there are 3 columns     # get the classification and make sure there are now 2 columns as andrei doesn't like #3.
110     my $class=$fig->subsystem_classification($subsys);     my $class=$fig->subsystem_classification($subsys);
111     unless ($class) {@$class=(' &nbsp; ','','')}     unless ($class) {@$class=(' &nbsp; ',' &nbsp; ')}
112     for (my $i=0; $i <=2; $i++) {unless ($$class[$i]) {$$class[$i] = " &nbsp; "}}     unless ($$class[0]) {$$class[0] = " &nbsp; "}
113     $table .= "<tr>\n\t<td rowspan='$rows'>" . (join "</td>\n\t<td rowspan='$rows'>", (@$class)) . "</td>";     unless ($$class[1]) {$$class[1] = " &nbsp; "}
114       # remove anything more than $$class[1];
115       @$class=($$class[0], $$class[1]); # could have done this with splice. Ech.
116    
117       $table .= "\n\t<td rowspan='$rows'>" . (join "</td>\n\t<td rowspan='$rows'>", (@$class)) . "</td>";
118    }    }
119    
120      # add the subsystem to the table
121      $table .= "\n\t<td><strong>$subsys<strong></td>";
122    
123    # add the genomes in the subsystem    # add the genomes in the subsystem
124    if ($cgi->param('genomes')) {$table .= "\n\t<td rowspan='$rows'> &nbsp; " . (join "<br>\n", sort {$a cmp $b} values %genomes) . "</td>"}    if ($cgi->param('genomes') && $cgi->param('stats')) {$table .= "\n\t<td rowspan='$rows'>" . (scalar keys %genomes) . " </td>"}
125      elsif ($cgi->param('genomes')) {$table .= "\n\t<td rowspan='$rows'> &nbsp; " . (join "<br>\n", sort {$a cmp $b} values %genomes) . "</td>"}
126    
127      if ($cgi->param('stats')) {
128       my $pegcount=0;
129       $table .= "\n\t<td>" . (scalar @roles) . "</td>"; #number of roles in the subsystem
130       my $pegcount; my $totalpegs;
131       # there should be a quicker way of getting this ... ?
132       foreach my $role (@roles) {
133        foreach my $genome (keys %genomes) {
134         my $count = scalar ($fig->pegs_in_subsystem_cell($subsys, $genome, $role));
135         $pegcount->{$genome} += $count;
136         $totalpegs += $count;
137        }
138       }
139    
140    if ($cgi->param('roles')) {     $table .= "\n\t<td>$totalpegs</td>"; # all the pegs in the subsystem
141       foreach my $w (@wants) {
142        $table .= "\n\t<td>$pegcount->{$w}</td>"; # pegs for each of the chosen genomes
143       }
144       $table .= "</tr>\n";
145      }
146      elsif ($cgi->param('roles')) {
147     # now add the roles     # now add the roles
148     my $first=1;     my $first=1;
149     foreach my $role (@roles) {     foreach my $role (@roles) {
150      my $genomeroles;      my $genomeroles;
151      foreach my $gen (@wants) {      foreach my $gen (@wants) {
152       my $cell;       my $cell = ' &nbsp; ';
153       if ($genomes{$gen}) {       if ($genomes{$gen}) {
154        foreach my $peg ($fig->pegs_in_subsystem_cell($subsys, $gen, $role)) {        foreach my $peg ($fig->pegs_in_subsystem_cell($subsys, $gen, $role)) {
155         $cell .= &HTML::fid_link($cgi,$peg) . "; ";         $cell .= &HTML::fid_link($cgi,$peg) . "; ";
156        }        }
157       }       }
158       if ($cell) {$genomeroles .= "\n\t<td>$cell</td>"}       $genomeroles .= "\n\t<td>$cell</td>";
      else {$genomeroles .= "\n\t<td> &nbsp; </td>"}  
159      }      }
160      # 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.
161      if ($first) {$table .= "\n\t<td>$role</td>" . $genomeroles . "</tr>\n"; $first=0}      if ($first) {$table .= "\n\t<td>$role</td>" . $genomeroles . "</tr>\n"; $first=0}
# Line 221  Line 251 
251                    "   </TR>\n",                    "   </TR>\n",
252                    "</TABLE>\n",                    "</TABLE>\n",
253                    $cgi->p,                    $cgi->p,
254                      $cgi->checkbox(-name=>"stats", -label=>"Only show statistics", -checked=>'on'), $cgi->p,
255                    $cgi->checkbox(-name=>"levels", -label=>"Show subsystem classification", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"levels", -label=>"Show subsystem classification", -checked=>'on'), $cgi->p,
256                    $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,
257                    $cgi->checkbox(-name=>"roles", -label=>"Show roles in subsystem", -checked=>'on'), $cgi->p,                    $cgi->checkbox(-name=>"roles", -label=>"Show roles in subsystem", -checked=>'on'), $cgi->p,

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3