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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3