[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.14, Thu Dec 6 14:58:03 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 96  Line 91 
91    
92  use SFXlate;  use SFXlate;
93    
94    # The return type (error/no error) will be put in here.
95    my $rtype;
96    eval {
97  # Get the target directory.  # Get the target directory.
98  my $targetDir = $options->{target};  my $targetDir = $options->{target};
99  # Verify the parameters.  # Verify the parameters.
# Line 107  Line 105 
105      Trace("Output going to $targetDir.") if T(2);      Trace("Output going to $targetDir.") if T(2);
106      # Get the Sprout object.      # Get the Sprout object.
107      my $sfx = SFXlate->new_sprout_only();      my $sfx = SFXlate->new_sprout_only();
108            # Get the old Sprout.
109            my $oldSprout = SFXlate->old_sprout_only();
110      # Create the counts file.      # Create the counts file.
111      CreateCounts($sfx, $options->{age}, $parameters[0], "$targetDir/version.inc");          CreateCounts($sfx, $oldSprout, $parameters[0], "$targetDir/version.inc");
112      # Create the subsystem summary file.      # Create the subsystem summary file.
113      CreateSubForm($sfx, "$targetDir/forms/subsystems.inc");      CreateSubForm($sfx, "$targetDir/forms/subsystems.inc");
114            # Create the organism summary file.
115            CreateOrgForm($sfx, "$targetDir/forms/all_genomes.inc");
116      # Create the database documentation file.      # Create the database documentation file.
117      CreateSproutDoc($sfx, "$targetDir/sproutdb.inc");      CreateSproutDoc($sfx, "$targetDir/sproutdb.inc");
118      # Tell the user we're done.      # Tell the user we're done.
119      Trace("File creation complete.") if T(2);      Trace("File creation complete.") if T(2);
120  }  }
121    };
122    if ($@) {
123        Trace("Counts failed with error: $@") if T(0);
124        $rtype = "error";
125    } else {
126        Trace("Counts complete.") if T(2);
127        $rtype = "no error";
128    }
129    if ($options->{phone}) {
130        my $msgID = Tracer::SendSMS($options->{phone}, "ShowCounts terminated with $rtype.");
131        if ($msgID) {
132            Trace("Phone message sent with ID $msgID.") if T(2);
133        } else {
134            Trace("Phone message not sent.") if T(2);
135        }
136    }
137    
138  =head3 CreateCounts  =head3 CreateCounts
139    
140  C<< CreateCounts($fig, $fileName); >>      CreateCounts($fig, $fileName);
141    
142  Create the count and version display for the front page of the NMPDR.  Create the count and version display for the front page of the NMPDR.
143    
# Line 129  Line 147 
147    
148  A Sprout object for accessing the database.  A Sprout object for accessing the database.
149    
150  =item age  =item oldSfx
151    
152  The maximum age for an annotation to be considered new.  A Sprout object for accessing the previous database.
153    
154  =item versionDate  =item versionDate
155    
# Line 147  Line 165 
165    
166  sub CreateCounts {  sub CreateCounts {
167      # Get the parameters.      # Get the parameters.
168      my ($sfx, $age, $versionDate, $fileName) = @_;      my ($sfx, $oldSfx, $versionDate, $fileName) = @_;
169      # Open the output file.      # Open the output file.
170      my $handle = Open(undef, ">$fileName");      my $handle = Open(undef, ">$fileName");
171      # Start the heading.      # Start the heading.
# Line 175  Line 193 
193      print $handle "<br />$output";      print $handle "<br />$output";
194      # Get the number of subsystems.      # Get the number of subsystems.
195      my $subsystems = $sfx->GetCount(['Subsystem'], "", []);      my $subsystems = $sfx->GetCount(['Subsystem'], "", []);
196      print $handle "<br />$subsystems subsystems";      print $handle "<br />$subsystems active subsystems";
197      # Get the current time and subtract the number of days indicated by the age.      # Count the number of new annotations, genomes, and features.
198      my $time = time() - $age * 86400;      my %things = ( Annotation => 'annotations',
199      # Count the number of new annotations.                     Feature => 'features',
200      my $newAnnotations = $sfx->GetCount(['Annotation'], "Annotation(time) >= ?",                     Genome => 'organisms'
201                                          [$time]);                   );
202        for my $thing (sort keys %things) {
203            my $newCount = $sfx->GetCount([$thing], "", []);
204            my $oldCount = $oldSfx->GetCount([$thing], "", []);
205            my $delta = $newCount - $oldCount;
206      # Only display them if there's a reasonable number.      # Only display them if there's a reasonable number.
207      if ($newAnnotations > 5) {          if ($delta > 5) {
208          print $handle ", $newAnnotations new annotations";              print $handle ", $delta&nbsp;new&nbsp;$things{$thing}";
209            }
210      }      }
211        # Add the docking results.
212        my $pdbCount = $sfx->GetCount(['PDB'], "PDB(docking-count) > ?", [0]);
213        print $handle ", $pdbCount drug targets with in silico docking results";
214      # Terminate the heading.      # Terminate the heading.
215      print $handle ".</h3>\n";      print $handle ".</h3>\n";
216      # Close the output file.      # Close the output file.
# Line 193  Line 219 
219    
220  =head3 CreateSubForm  =head3 CreateSubForm
221    
222  C<< CreateSubForm($sfx, $fileName); >>      CreateSubForm($sfx, $fileName);
223    
224  Output the subsystem summary form. The subsystem summary form allows the user  Output the subsystem summary form. The subsystem summary form allows the user
225  to select an organism and view a summary of its subsystems.  to select an organism and view a summary of its subsystems.
# Line 223  Line 249 
249      push @page, input({type => "hidden", name => "SPROUT", value => "1"});      push @page, input({type => "hidden", name => "SPROUT", value => "1"});
250      # Surround the form parts with a table.      # Surround the form parts with a table.
251      push @page, "<table><tr><td>";      push @page, "<table><tr><td>";
252        # Add the buttons.
253        push @page, CGI::p("For the genome selected below, show " .
254                    input({type => "submit", name => "show_subsystems",
255                           value => "Subsystems", class => "button"}) .
256                    input({type => "submit", name => "show_reactions",
257                           value => "Reactions", class => "button"}));
258        # End the first table cell.
259        push @page, "</td></tr><tr><td>";
260      # Create the gene menu.      # Create the gene menu.
261      push @page, $sfx->GeneMenu({ name => 'genome', size => 10 }, "", []);      push @page, $sfx->GeneMenu({ name => 'genome', size => 10 }, "", []);
262        # Close the table.
263        push @page, "</td></tr></table>";
264        # Close the form.
265        push @page, end_form();
266        # Put together all the pieces.
267        my $wholePage = join("\n", @page);
268        # Open the output file.
269        my $handle = Open(undef, ">$fileName");
270        # Write out the HTML.
271        print $handle $wholePage;
272        # Close the file.
273        close $handle;
274    
275    }
276    
277    =head3 CreateOrgForm
278    
279        CreateOrgForm($sfx, $fileName);
280    
281    Output the organism summary form. The organism summary form allows the user
282    to select an organism and view its statistics.
283    
284    =over 4
285    
286    =item sfx
287    
288    A Sprout object that can be used to access the NMPDR database.
289    
290    =item fileName
291    
292    The name of the file to create with the form HTML in it.
293    
294    =back
295    
296    =cut
297    
298    sub CreateOrgForm {
299        # Get the parameters.
300        my ($sfx, $fileName) = @_;
301        # Start the form.
302        my @page = ();
303        push @page, start_form({method => "post", action => "../FIG/genome_statistics.cgi",
304                                enctype=> "application/x-www-form-urlencoded"});
305        # Make sure the script knows it's for SPROUT.
306        push @page, input({type => "hidden", name => "SPROUT", value => "1"});
307        # Surround the form parts with a table.
308        push @page, "<table><tr><td>";
309        # Add the button.
310        push @page, CGI::p("Search or view statistics for the genome selected below " .
311                           input({type => "submit", name => "statistics",
312                           value => "Go", class => "button"}));
313      # End the first table cell.      # End the first table cell.
314      push @page, "</td></tr><tr><td>";      push @page, "</td></tr><tr><td>";
315      # Add the buttons.      # Create the gene menu.
316      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"});  
317      # Close the table.      # Close the table.
318      push @page, "</td></tr></table>";      push @page, "</td></tr></table>";
319      # Close the form.      # Close the form.
# Line 249  Line 331 
331    
332  =head3 CreateSproutDoc  =head3 CreateSproutDoc
333    
334  C<< CreateSproutDoc($sfx, $fileName); >>      CreateSproutDoc($sfx, $fileName);
335    
336  Output the Sprout database documentation.  Output the Sprout database documentation.
337    
# Line 279  Line 361 
361  }  }
362    
363    
   
364  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3