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

Diff of /Sprout/ShowCounts.pl

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

revision 1.5, Fri Jun 23 19:08:58 2006 UTC revision 1.12, Tue Apr 10 06:08:06 2007 UTC
# Line 17  Line 17 
17  and the number of new annotations. This file is included in the  and the number of new annotations. This file is included in the
18  C<index.php> document.  C<index.php> document.
19    
20  =item forms/subsystems.inc  =item forms/all_genomes.inc
21    
22  Displays a form allowing the user to select an organism and see a summary of  Displays a form allowing the user to select an organism and see a summary of
23  its subsystems and reactions. This file is included in the  its subsystems and reactions. This file is included in the
# Line 60  Line 60 
60    
61  Display this command's parameters and options.  Display this command's parameters and options.
62    
 =item age  
   
 Maximum age in days of an annotation for it to be considered new. The default is  
 C<14>.  
   
63  =item target  =item target
64    
65  Target directory for the include files. The default is C<includes> in the  Target directory for the include files. The default is C<includes> in the
# Line 87  Line 82 
82  # Get the command-line options and parameters.  # Get the command-line options and parameters.
83  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB SFXlate) ],  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB SFXlate) ],
84                                             {                                             {
85                                              age => [14, 'maximum age of a new annotation'],                                              trace => [2, 'tracing level'],
86                                              target => ["$FIG_Config::nmpdr_pages/includes",                                              target => ["$FIG_Config::nmpdr_pages/includes",
87                                                            'output directory'],                                                            'output directory'],
88                                             },                                             },
# Line 107  Line 102 
102      Trace("Output going to $targetDir.") if T(2);      Trace("Output going to $targetDir.") if T(2);
103      # Get the Sprout object.      # Get the Sprout object.
104      my $sfx = SFXlate->new_sprout_only();      my $sfx = SFXlate->new_sprout_only();
105        # Get the old Sprout.
106        my $oldSprout = SFXlate->old_sprout_only();
107      # Create the counts file.      # Create the counts file.
108      CreateCounts($sfx, $options->{age}, $parameters[0], "$targetDir/version.inc");      CreateCounts($sfx, $oldSprout, $parameters[0], "$targetDir/version.inc");
109      # Create the subsystem summary file.      # Create the subsystem summary file.
110      CreateSubForm($sfx, "$targetDir/forms/subsystems.inc");      CreateSubForm($sfx, "$targetDir/forms/subsystems.inc");
111        # Create the organism summary file.
112        CreateOrgForm($sfx, "$targetDir/forms/all_genomes.inc");
113      # Create the database documentation file.      # Create the database documentation file.
114      CreateSproutDoc($sfx, "$targetDir/sproutdb.inc");      CreateSproutDoc($sfx, "$targetDir/sproutdb.inc");
115      # Tell the user we're done.      # Tell the user we're done.
# Line 129  Line 128 
128    
129  A Sprout object for accessing the database.  A Sprout object for accessing the database.
130    
131  =item age  =item oldSfx
132    
133  The maximum age for an annotation to be considered new.  A Sprout object for accessing the previous database.
134    
135  =item versionDate  =item versionDate
136    
# Line 147  Line 146 
146    
147  sub CreateCounts {  sub CreateCounts {
148      # Get the parameters.      # Get the parameters.
149      my ($sfx, $age, $versionDate, $fileName) = @_;      my ($sfx, $oldSfx, $versionDate, $fileName) = @_;
150      # Open the output file.      # Open the output file.
151      my $handle = Open(undef, ">$fileName");      my $handle = Open(undef, ">$fileName");
152      # Start the heading.      # Start the heading.
# Line 175  Line 174 
174      print $handle "<br />$output";      print $handle "<br />$output";
175      # Get the number of subsystems.      # Get the number of subsystems.
176      my $subsystems = $sfx->GetCount(['Subsystem'], "", []);      my $subsystems = $sfx->GetCount(['Subsystem'], "", []);
177      print $handle "<br />$subsystems subsystems";      print $handle "<br />$subsystems active subsystems";
178      # Get the current time and subtract the number of days indicated by the age.      # Count the number of new annotations and features.
179      my $time = time() - $age * 86400;      my %things = ( Annotation => 'annotations',
180      # Count the number of new annotations.                     Feature => 'features',
181      my $newAnnotations = $sfx->GetCount(['Annotation'], "Annotation(time) >= ?",                     Genome => 'organisms'
182                                          [$time]);                   );
183        for my $thing (sort keys %things) {
184            my $newCount = $sfx->GetCount([$thing], "", []);
185            my $oldCount = $oldSfx->GetCount([$thing], "", []);
186            my $delta = $newCount - $oldCount;
187      # Only display them if there's a reasonable number.      # Only display them if there's a reasonable number.
188      if ($newAnnotations > 5) {          if ($delta > 5) {
189          print $handle ", $newAnnotations new annotations";              print $handle ", $delta&nbsp;new&nbsp;$things{$thing}";
190            }
191      }      }
192      # Terminate the heading.      # Terminate the heading.
193      print $handle ".</h3>\n";      print $handle ".</h3>\n";
# Line 223  Line 227 
227      push @page, input({type => "hidden", name => "SPROUT", value => "1"});      push @page, input({type => "hidden", name => "SPROUT", value => "1"});
228      # Surround the form parts with a table.      # Surround the form parts with a table.
229      push @page, "<table><tr><td>";      push @page, "<table><tr><td>";
230        # Add the buttons.
231        push @page, CGI::p("For the genome selected below, show " .
232                    input({type => "submit", name => "show_subsystems",
233                           value => "Subsystems", class => "button"}) .
234                    input({type => "submit", name => "show_reactions",
235                           value => "Reactions", class => "button"}));
236        # End the first table cell.
237        push @page, "</td></tr><tr><td>";
238      # Create the gene menu.      # Create the gene menu.
239      push @page, $sfx->GeneMenu({ name => 'genome', size => 10 }, "", []);      push @page, $sfx->GeneMenu({ name => 'genome', size => 10 }, "", []);
240        # Close the table.
241        push @page, "</td></tr></table>";
242        # Close the form.
243        push @page, end_form();
244        # Put together all the pieces.
245        my $wholePage = join("\n", @page);
246        # Open the output file.
247        my $handle = Open(undef, ">$fileName");
248        # Write out the HTML.
249        print $handle $wholePage;
250        # Close the file.
251        close $handle;
252    
253    }
254    
255    =head3 CreateOrgForm
256    
257    C<< CreateOrgForm($sfx, $fileName); >>
258    
259    Output the organism summary form. The organism summary form allows the user
260    to select an organism and view its statistics.
261    
262    =over 4
263    
264    =item sfx
265    
266    A Sprout object that can be used to access the NMPDR database.
267    
268    =item fileName
269    
270    The name of the file to create with the form HTML in it.
271    
272    =back
273    
274    =cut
275    
276    sub CreateOrgForm {
277        # Get the parameters.
278        my ($sfx, $fileName) = @_;
279        # Start the form.
280        my @page = ();
281        push @page, start_form({method => "post", action => "../FIG/genome_statistics.cgi",
282                                enctype=> "application/x-www-form-urlencoded"});
283        # Make sure the script knows it's for SPROUT.
284        push @page, input({type => "hidden", name => "SPROUT", value => "1"});
285        # Surround the form parts with a table.
286        push @page, "<table><tr><td>";
287        # Add the button.
288        push @page, CGI::p("Search or view statistics for the genome selected below " .
289                           input({type => "submit", name => "statistics",
290                           value => "Go", class => "button"}));
291      # End the first table cell.      # End the first table cell.
292      push @page, "</td></tr><tr><td>";      push @page, "</td></tr><tr><td>";
293      # Add the buttons.      # Create the gene menu.
294      push @page, input({type => "submit", name => "show_subsystems",      push @page, $sfx->GeneMenu({ name => 'genome', size => 10 }, "", []);
                        value => "Show Subsystems"});  
     push @page, input({type => "submit", name => "show_reactions",  
                        value => "Show Reactions"});  
295      # Close the table.      # Close the table.
296      push @page, "</td></tr></table>";      push @page, "</td></tr></table>";
297      # Close the form.      # Close the form.

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3