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

Diff of /FigWebServices/heat_map.cgi

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

revision 1.12, Mon Jun 19 21:19:22 2006 UTC revision 1.13, Tue Jun 20 03:34:43 2006 UTC
# Line 201  Line 201 
201              push @row, [" $cell ", "td bgcolor='#$bgcolor' align='center'"]              push @row, [" $cell ", "td bgcolor='#$bgcolor' align='center'"]
202  #push @row, [" $cell ($hue) ", "td"]  #push @row, [" $cell ($hue) ", "td"]
203          }          }
204          elsif (!defined $cell) {push @row, ["   ", "td"]}          elsif ($cell) {push @row, [$cell, "td"]}
205          else {push @row, [$cell, "td"]}          else {push @row, ["   ", "td"]}
206      }      }
207      push @$tab, \@row;      push @$tab, \@row;
208  }  }
# Line 214  Line 214 
214  # skip the data columns  # skip the data columns
215  my $skip;  my $skip;
216  map {$skip->{$_}=1} (2..10);  map {$skip->{$_}=1} (2..10);
217  unless ($cgi->param('create_excel')) {$tab=&HTML::merge_table_rows($tab, $skip)}  $tab=&HTML::merge_table_rows($tab, $skip);
218    
219  # generate the table of significant differences;  # generate the table of significant differences;
220  my $sigtab=&significant_difference();  my $sigtab=&significant_difference();
# Line 285  Line 285 
285  sub significant_difference {  sub significant_difference {
286      # identify those things with a significant difference and make a cool table of them      # identify those things with a significant difference and make a cool table of them
287    
288        my $idx; # the index of each genome in the table. just the column number. note that col 0 == header column
289        for (my $i=0; $i<=$#genomes; $i++)
290        {
291            $idx->{$genomes[$i]}=$i+1;
292        }
293    
294    
295    
296      # read the xipe attribute for significant differences      # read the xipe attribute for significant differences
297      my $xipe; my $seen;      my $xipe; my $seen;
298      foreach my $i (0 .. $#genomes)      foreach my $i (0 .. $#genomes)
299      {      {
300          foreach my $attr ($fig->get_attributes($genomes[$i], "xipe"))          foreach my $attr (sort {lc($a->[2]) cmp lc($b->[2])} $fig->get_attributes($genomes[$i], "xipe"))
301          {          {
302              my @pieces=split /\:/, $attr->[2];              my @pieces=split /\:/, $attr->[2];
303    
304                next unless ($idx->{$pieces[0]});
305              # this is a hack to ignore things with > 1 entry. We should clean this up and show based on confidence              # this is a hack to ignore things with > 1 entry. We should clean this up and show based on confidence
306              next if ($seen->{$genomes[$i]}->{$pieces[0]}->{$pieces[1]});              next if ($seen->{$genomes[$i]}->{$pieces[0]}->{$pieces[1]});
307              $seen->{$genomes[$i]}->{$pieces[0]}->{$pieces[1]}=1;              $seen->{$genomes[$i]}->{$pieces[0]}->{$pieces[1]}=1;
             # note that pieces has lots of information about confidence etc that we are ignoring right now  
             if (@pieces)  
             {  
                 my $htmlstring=&HTML::sub_link($cgi, $pieces[1])." <small>(".(join(", ", @pieces[2,3,4])).")</small><br />\n";  
                 my $textstring=$pieces[1] . " (".(join(", ", @pieces[2,3,4]))."),\n";  
                 push @{$xipe->{$genomes[$i]}->{$pieces[0]}}, [$htmlstring, $textstring];  
             }  
             else  
             {  
                 push @{$xipe->{$genomes[$i]}->{$pieces[0]}}, [" &nbsp; ", ""];  
             }  
         }  
     }  
308    
309      foreach my $g (keys %$xipe)              push @{$xipe->{$genomes[$i]}->[$idx->{$pieces[0]}]}, $pieces[1];
     {  
         foreach my $f (keys %{$xipe->{$g}})  
         {  
             @{$xipe->{$g}->{$f}} = sort {lc($a->[0]) cmp lc($b->[0]) || lc($a->[1]) cmp lc($b->[1])} @{$xipe->{$g}->{$f}};  
310          }          }
311      }      }
312    
313      my $hdrs=["UP IN", map {$fig->genus_species($_)."<br />($_)\n"} @genomes];      my $tab;
314      map {$_=[$_, "th class=\"bordered\""]} @$hdrs;      foreach my $genome (keys %$xipe)
     my $tab=[]; my $texttab=[]; # texttab is for the excel file and doesn't have links  
     foreach my $i (0 .. $#genomes)  
315      {      {
316          my $hrow=[[$fig->genus_species($genomes[$i]) . "($genomes[$i])", "th class=\"bordered\""]];          my $added=1;
317          my $trow=[$fig->genus_species($genomes[$i]) . "($genomes[$i])"]; # t is text for excel          while ($added)
         foreach my $j (0 .. $#genomes)  
318          {          {
319              #$matches=join("<br />\n", map {&HTML::sub_link($cgi, $_)} @{$xipe->{$genomes[$i]}->{$genomes[$j]}});              undef $added;
320              my ($hmatches, $tmatches)=(" &nbsp; ", "");              my $row=[[$genome, "td class=\"bordered\""]];
321              if (defined $xipe->{$genomes[$i]}->{$genomes[$j]})              for (my $i=1; $i<=$#genomes+1; $i++)
322              {              {
323                  $hmatches=join("", map {$_->[0]} @{$xipe->{$genomes[$i]}->{$genomes[$j]}}); # this is the html version for web                  my $cell=shift @{$xipe->{$genome}->[$i]};
324                  $tmatches=join("", map {$_->[1]} @{$xipe->{$genomes[$i]}->{$genomes[$j]}}); # this is the text version for excel                  if ($cell) {$row->[$i]=[$cell, "td class=\"bordered\""]; $added=1}
325                    else {$row->[$i]=" &nbsp; "}
326              }              }
327              push @$hrow, [$hmatches, "td class=\"bordered\""];              if ($added) {push @$tab, $row}
             push @$trow, $tmatches;  
328          }          }
         push @$tab, $hrow;  
         push @$texttab, $trow;  
329      }      }
330      my %options=("border"=>1);  
331      if ($cgi->param('create_excel')) {$options{'excelfile'}="SubsystemConnections"}  
332        # merge the tables based on identical rows
333        $tab=&HTML::merge_table_rows($tab);
334    
335    
336        my $hdrs=["UP IN", map {$fig->genus_species($_)."<br />($_)\n"} @genomes];
337        map {$_=[$_, "th class=\"bordered\""]} @$hdrs;
338    
339        my %options=("border"=>1, "excelfile"=>"SubsystemConnections");
340      return &HTML::make_table($hdrs, $tab, "Subsystems with significant difference", %options);      return &HTML::make_table($hdrs, $tab, "Subsystems with significant difference", %options);
341    
342        # use the text table not the html table
343        #$options{"excelfile"}="SubsystemConnections";
344        #$raelib->tab2excel($hdrs, $texttab, "SigDiff", \%options, $options{"excelfile"});
345  }  }
346    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3