[Bio] / Sprout / GenomeStats.pl Repository:
ViewVC logotype

Diff of /Sprout/GenomeStats.pl

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

revision 1.28, Tue Apr 10 06:01:56 2007 UTC revision 1.29, Mon Aug 20 23:14:33 2007 UTC
# Line 93  Line 93 
93  use SFXlate;  use SFXlate;
94  use CGI qw(:standard);  use CGI qw(:standard);
95  use FIG;  use FIG;
 no warnings 'once'; # only when coding  
96    
97  # Get the command-line options and parameters.  # Get the command-line options and parameters.
98  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB) ],  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB) ],
# Line 116  Line 115 
115                                              },                                              },
116                                             "",                                             "",
117                                             @ARGV);                                             @ARGV);
118    # This table controls the special attribute columns. For each we need to know the attribute name and the
119    # column title. If any genomes in a group have a value for one of the special columns, that column is
120    # displayed along with the attribute values.
121    my %specialCols = (Serotype => 'Serotype_code',
122                       Phenotype => 'Phenotype');
123  # Verify the directory name.  # Verify the directory name.
124  my $targetDir = $options->{targetDir};  my $targetDir = $options->{targetDir};
125  if (! $targetDir) {  if (! $targetDir) {
# Line 176  Line 180 
180          # Create the output file.          # Create the output file.
181          my $outFileName = "stats-" . lc($groupID) . ".inc";          my $outFileName = "stats-" . lc($groupID) . ".inc";
182          Open(\*GROUPFILE, ">$targetDir/$outFileName");          Open(\*GROUPFILE, ">$targetDir/$outFileName");
183          # Get the serotypes.          # Get the special columns. We'll stuff them in a hash keyed by column name. Each column name will contain
184          my %serotypes = map { $_->[0] => $_->[2] } $fig->get_attributes(\@newGenomes, "Serotype_code");          # a sub-hash that translates each genome ID to its applicable attribute value (if any).
185          my $hasSeroData = (scalar(keys %serotypes) > 0);          my %specialData = ();
186          # If we have serotypes, we add an extra column.          for my $specialColumn (keys %specialCols) {
187          my @columnNames = "Strain annotated in NMPDR";              # Get the attribute mapping.
188          if ($hasSeroData) {              my %specialDataList = map { $_->[0] => $_->[2] } $fig->get_attributes(\@newGenomes, $specialCols{$specialColumn});
189              push @columnNames, "Serotype";              # We only proceed if some attributes were found. As a result, the keys in %specialData will only be keys
190                # for columns that exist in the output.
191                if (scalar(keys %specialDataList)) {
192                    $specialData{$specialColumn} = \%specialDataList;
193                }
194          }          }
195            # Set up the column names.
196            my @columnNames = "Strain annotated in NMPDR";
197            push @columnNames, sort keys %specialData;
198          push @columnNames,  "Genome size, bp",          push @columnNames,  "Genome size, bp",
199                              "Protein Encoding Genes (PEGs)",                              "Protein Encoding Genes (PEGs)",
200                              "Named genes in subsystems",            # s0                              "Named genes in subsystems",            # s0
# Line 276  Line 287 
287              my $ssCol = "<a href=\"$ssLink\">$ssCount</a>";              my $ssCol = "<a href=\"$ssLink\">$ssCount</a>";
288              # Start creating the table cells.              # Start creating the table cells.
289              my $rowHtml = td("$genomeText$new");              my $rowHtml = td("$genomeText$new");
290              # Check for a serotype.              # Add any special columns.
291              if ($hasSeroData) {              for my $specialCol (keys %specialData) {
292                  my $seroType = $serotypes{$genomeID} || "&nbsp;";                  # Here we get the attribute value. If there is none, we leave the column blank.
293                  $rowHtml .= td($seroType);                  my $attribute = $specialData{$specialCol}->{$genomeID} || "&nbsp;";
294                    $rowHtml .= td($attribute);
295              }              }
296              # Now add the data columns.              # Now add the data columns.
297              $rowHtml .= join("",              $rowHtml .= join("",

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3