[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.3, Sun Jun 18 07:01:33 2006 UTC revision 1.16, Tue Jun 27 16:44:18 2006 UTC
# Line 61  Line 61 
61    
62  Style to use for small-text markers (e.g. NEW!)  Style to use for small-text markers (e.g. NEW!)
63    
64    =item numStyle
65    
66    Style to use for numeric cells.
67    
68    =item counterStyle
69    
70    Style to use for counter cells.
71    
72  =item linkCGI  =item linkCGI
73    
74  Path to the CGI script for displaying detailed statistics.  Path to the CGI script for displaying detailed statistics.
# Line 90  Line 98 
98                                              evenStyle => ['even', 'style for even rows'],                                              evenStyle => ['even', 'style for even rows'],
99                                              tableStyle => ['genomestats', 'style for whole table'],                                              tableStyle => ['genomestats', 'style for whole table'],
100                                              markerStyle => ['tinytext', 'style for markers'],                                              markerStyle => ['tinytext', 'style for markers'],
101                                                numStyle => ['numcell', 'style for cells with numeric values'],
102                                                counterStyle => ['countercell', 'style for cells with counter values'],
103                                              linkCGI => ['../FIG/genome_statistics.cgi',                                              linkCGI => ['../FIG/genome_statistics.cgi',
104                                                          'path to CGI script for detailed statistics'],                                                          'path to CGI script for detailed statistics'],
105                                             },                                             },
# Line 102  Line 112 
112  } elsif (! -d $targetDir) {  } elsif (! -d $targetDir) {
113      Confess("Target directory $targetDir not found.");      Confess("Target directory $targetDir not found.");
114  } else {  } else {
115      # *Get the old Sprout.      # Get the old Sprout.
116      my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB);      my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB);
117      # Extract the genome group data from the old Sprout.      # Extract the genome group data from the old Sprout.
118      my %oldGroupHash = $oldSprout->GetGroups();      my %oldGroupHash = $oldSprout->GetGroups();
# Line 127  Line 137 
137              %oldGenomes = map { $_ => 1 } @{$oldGroupHash{$groupID}};              %oldGenomes = map { $_ => 1 } @{$oldGroupHash{$groupID}};
138          }          }
139          # Create the output file.          # Create the output file.
140          Open(\*GROUPFILE, ">$targetDir/$groupID.inc");          my $outFileName = "stats-" . lc($groupID) . ".inc";
141            Open(\*GROUPFILE, ">$targetDir/$outFileName");
142          # Get the styles.          # Get the styles.
143          my ($tableStyle, $markerStyle, @rowStyle) = ($options->{tableStyle}, $options->{markerStyle},          my ($tableStyle, $markerStyle, @rowStyle) = ($options->{tableStyle}, $options->{markerStyle},
144                                                       $options->{evenStyle}, $options->{oddStyle});                                                       $options->{evenStyle}, $options->{oddStyle});
145            my ($numStyle, $counterStyle) = ($options->{numStyle}, $options->{counterStyle});
146          # Start the table.          # Start the table.
147          print GROUPFILE "<table class=\"$tableStyle\">\n";          print GROUPFILE "<table class=\"$tableStyle\">\n";
148          # Create the header row.          # Create the header row.
149          print GROUPFILE Tr( { class => 'odd' }, th("Strain annotated in NMPDR",          print GROUPFILE Tr( { class => 'odd' }, th(["Strain annotated in NMPDR",
150                                                   "Genome size, bp",                                                   "Genome size, bp",
151                                                   "Protein Encoding Genes (PEGs)",                                                   "Protein Encoding Genes (PEGs)",
152                                                   "Named genes in subsystems",            # s0                                                   "Named genes in subsystems",            # s0
153                                                   "Named genes not in subsystems",        # n0                                                   "Named genes not in subsystems",        # n0
154                                                   "Hypothetical genes in subsystems",     # s1                                                   "Hypothetical genes in subsystems",     # s1
155                                                   "Hypothetical genes not in subsystems", # n1                                                   "Hypothetical genes not in subsystems", # n1
156                                                   "RNAs")) . "\n";                                                   "RNAs",
157                                                       ])) . "\n";
158          # Set up some useful stuff for the four count columns.          # Set up some useful stuff for the four count columns.
159          my %linkParms = ( s0 => "nohypo_sub", n0 => "nohypo_nosub",          my %linkParms = ( s0 => "nothypo_sub", n0 => "nothypo_nosub",
160                            s1 => "hypo_sub", n1 => "hypo_nosub" );                            s1 => "hypo_sub", n1 => "hypo_nosub" );
161          my @columnTypes = ('s0', 'n0', 's1', 'n1');          my @columnTypes = ('s0', 'n0', 's1', 'n1');
162          # The data rows will be built next. We'll be putting them into a hash keyed by          # The data rows will be built next. We'll be putting them into a hash keyed by
# Line 161  Line 174 
174                  $new = " <span class=\"$markerStyle\">NEW!</span>";                  $new = " <span class=\"$markerStyle\">NEW!</span>";
175              }              }
176              # Get the genome length.              # Get the genome length.
177              my $genomeLen = $sprout->GenomeLength($genomeID);              my $genomeLen = Tracer::CommaFormat($sprout->GenomeLength($genomeID));
178              # Get the number of PEGs.              # Get the number of PEGs.
179              my $pegCount = $sprout->FeatureCount($genomeID, 'peg');              my $pegCount = Tracer::CommaFormat($sprout->FeatureCount($genomeID, 'peg'));
180              # Get the number of RNAs.              # Get the number of RNAs.
181              my $rnaCount = $sprout->FeatureCount($genomeID, 'rna');              my $rnaCount = Tracer::CommaFormat($sprout->FeatureCount($genomeID, 'rna'));
182              # Now we have four categories of features to work with, for each              # Now we have four categories of features to work with, for each
183              # combination of named or hypothetical vs. in-subsystem or              # combination of named or hypothetical vs. in-subsystem or
184              # not-in-subsystem. First, we get all of the feature assignments for              # not-in-subsystem. First, we get all of the feature assignments for
# Line 190  Line 203 
203                  $counters{$ss} += 1;                  $counters{$ss} += 1;
204                  $totalFeatures++;                  $totalFeatures++;
205              }              }
206                Trace("$totalFeatures total features found for $genomeID.") if T(3);
207              # We have all our data. Next we need to compute the percentages and the links.              # We have all our data. Next we need to compute the percentages and the links.
208              # First, the link stuff.              # First, the link stuff.
209              my $linkPrefix = "$options->{linkCGI}?user=\&genome=$genomeID&SPROUT=1&request=";              my $linkPrefix = "$options->{linkCGI}?user=\&genome=$genomeID&SPROUT=1&request=";
# Line 197  Line 211 
211              for my $type (keys %linkParms) {              for my $type (keys %linkParms) {
212                  $counters{$type} = a( { href => "$linkPrefix$linkParms{$type}" },                  $counters{$type} = a( { href => "$linkPrefix$linkParms{$type}" },
213                                       sprintf("%d(%.1f%%)", $counters{$type},                                       sprintf("%d(%.1f%%)", $counters{$type},
214                                               $counters{$type} * 100 / $totalFeatures));                                               Tracer::Percent($counters{$type}, $totalFeatures)));
215              }              }
216              # Create the row text.              my @counterValues = map { $counters{$_} } @columnTypes;
217              my $rowHtml = td( "$genomeName$new", $genomeLen, $pegCount,              # Create the row text. Note that we use the distributive capability of the TD
218                                map { $counters{$_} } @columnTypes,              # function to apply the same style to each one.
219                                $rnaCount );              my $rowHtml = join("",
220                                   td("$genomeName$new"),
221                                   td({ class => $numStyle }, $genomeLen),
222                                   td({ class => $numStyle }, $pegCount),
223                                   td({ class => $counterStyle }, \@counterValues),
224                                   td({ class => $numStyle }, $rnaCount),
225                                  );
226              # Put it in the row hash.              # Put it in the row hash.
227              $rows{$genomeName} = $rowHtml;              $rows{$genomeName} = $rowHtml;
228          }          }
# Line 221  Line 241 
241              # Count the row.              # Count the row.
242              $rowCount++;              $rowCount++;
243          }          }
244          # All done, close the file.          # All done, terminate the table and close the file.
245            print GROUPFILE "</table>\n";
246          close GROUPFILE;          close GROUPFILE;
247          Trace("$rowCount genomes processed.") if T(2);          Trace("$rowCount genomes processed.") if T(2);
248      }      }
# Line 264  Line 285 
285              $realGroupID = $1;              $realGroupID = $1;
286          }          }
287          # Append this group's genomes into the result hash.          # Append this group's genomes into the result hash.
288          Tracer::AddToListMap(\%retVal, $realGroupID, $groupHash{$groupID});          Tracer::AddToListMap(\%retVal, $realGroupID, @{$groupHash{$groupID}});
289      }      }
290      # Return the result hash.      # Return the result hash.
291      return %retVal;      return %retVal;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3