[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.16, Sun Mar 23 16:18:16 2008 UTC revision 1.17, Tue Sep 16 18:59:01 2008 UTC
# Line 60  Line 60 
60    
61  Display this command's parameters and options.  Display this command's parameters and options.
62    
 =item target  
   
 Target directory for the include files. The default is C<includes> in the  
 C<$FIG_Config::nmpdr_pages> directory.  
   
63  =back  =back
64    
65  =cut  =cut
# Line 76  Line 71 
71  use File::Path;  use File::Path;
72  use FIG;  use FIG;
73  use CGI qw(:standard);  use CGI qw(:standard);
74    use WikiTools;
75    
76  # Get the command-line options and parameters.  # Get the command-line options and parameters.
77  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB SFXlate) ],  my ($options, @parameters) = StandardSetup([qw(Sprout ERDB SFXlate WikiTools) ],
78                                             {                                             {
79                                              trace => [2, 'tracing level'],                                              trace => [2, 'tracing level'],
                                             target => ["$FIG_Config::nmpdr_pages/includes",  
                                                           'output directory'],  
80                                             },                                             },
81                                             "<version date>",                                             "<version date>",
82                                             @ARGV);                                             @ARGV);
# Line 97  Line 91 
91      # Verify the parameters.      # Verify the parameters.
92      if (! $parameters[0]) {      if (! $parameters[0]) {
93          Confess("Please specify a version date.");          Confess("Please specify a version date.");
     } elsif (! -d $targetDir) {  
         Confess("Target directory $targetDir does not exist.");  
94      } else {      } else {
95          Trace("Output going to $targetDir.") if T(2);          Trace("Connecting to Sprout.") if T(2);
96          # Get the Sprout object.          # Get the Sprout object.
97          my $sfx = SFXlate->new_sprout_only();          my $sfx = SFXlate->new_sprout_only();
98          # Get the old Sprout.          # Get the old Sprout.
99          my $oldSprout = SFXlate->old_sprout_only();          my $oldSprout = SFXlate->old_sprout_only();
100          # Create the counts file.          # Create the counts page.
101          CreateCounts($sfx, $oldSprout, $parameters[0], "$targetDir/version.inc");          my $page = CreateCounts($sfx, $oldSprout, $parameters[0]);
102          # Create the subsystem summary file.          # Put it in the wiki.
103          CreateSubForm($sfx, "$targetDir/forms/subsystems.inc");          my $wiki = WikiTools->new();
104          # Create the organism summary file.          my $rc = $wiki->Save('NmpdrVersion', 'Main', 'WebHome', $page);
105          CreateOrgForm($sfx, "$targetDir/forms/all_genomes.inc");          if ($rc) {
106          # Create the database documentation file.              Trace("Page creation complete.") if T(2);
107          CreateSproutDoc($sfx, "$targetDir/sproutdb.inc");          } else {
108          # Tell the user we're done.              Confess("Page creation failed: " . $wiki->{error});
109          Trace("File creation complete.") if T(2);          }
110      }      }
111  };  };
112  if ($@) {  if ($@) {
# Line 135  Line 127 
127    
128  =head3 CreateCounts  =head3 CreateCounts
129    
130      CreateCounts($fig, $fileName);      my $content = CreateCounts($sprout, $oldSprout, $versionDate);
131    
132  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.
133    
134  =over 4  =over 4
135    
136  =item sfx  =item sprout
137    
138  A Sprout object for accessing the database.  A Sprout object for accessing the database.
139    
140  =item oldSfx  =item oldSprout
141    
142  A Sprout object for accessing the previous database.  A Sprout object for accessing the previous database.
143    
# Line 157  Line 149 
149    
150  The name of the output file.  The name of the output file.
151    
152    =item RETURN
153    
154    Returns a string that can be published for inclusion in the front page of the wiki.
155    
156  =back  =back
157    
158  =cut  =cut
159    
160  sub CreateCounts {  sub CreateCounts {
161      # Get the parameters.      # Get the parameters.
162      my ($sfx, $oldSfx, $versionDate, $fileName) = @_;      my ($sprout, $oldSprout, $versionDate) = @_;
     # Open the output file.  
     my $handle = Open(undef, ">$fileName");  
163      # Start the heading.      # Start the heading.
164      print $handle "<h3 class=\"home\">Version $versionDate\n";      my $retVal = "<h3 class=\"home\">Version of $versionDate\n";
165      # Get the counts.      # Get the counts.
166      my @counts = $sfx->GenomeCounts();      my @counts = $sprout->GenomeCounts();
167      my @names = qw(archaeal bacterial eukaryal viral environmental);      my @names = qw(archaeal bacterial eukaryal viral environmental);
168      # Get a list of named counts for all the categories with nonzero values.      # Get a list of named counts for all the categories with nonzero values.
169      my @namedCounts = ();      my @namedCounts = ();
# Line 188  Line 182 
182      }      }
183      $output .= " genomes.";      $output .= " genomes.";
184      # Output the counts.      # Output the counts.
185      print $handle "<br />$output";      $retVal .= "<br />$output";
186      # Get the number of subsystems.      # Get the number of subsystems.
187      my $subsystems = $sfx->GetCount(['Subsystem'], "", []);      my $subsystems = $sprout->GetCount(['Subsystem'], "", []);
188      print $handle "<br />$subsystems active subsystems";      $retVal .= "<br />$subsystems active subsystems";
189      # Count the number of new annotations, genomes, and features.      # Count the number of new annotations, genomes, and features.
190      my %things = ( Annotation => 'annotations',      my %things = ( Annotation => 'annotations',
191                     Feature => 'features',                     Feature => 'features',
192                     Genome => 'organisms'                     Genome => 'organisms'
193                   );                   );
194      for my $thing (sort keys %things) {      for my $thing (sort keys %things) {
195          my $newCount = $sfx->GetCount([$thing], "", []);          my $newCount = $sprout->GetCount([$thing], "", []);
196          my $oldCount = $oldSfx->GetCount([$thing], "", []);          my $oldCount = $oldSprout->GetCount([$thing], "", []);
197          my $delta = $newCount - $oldCount;          my $delta = $newCount - $oldCount;
198          # Only display them if there's a reasonable number.          # Only display them if there's a reasonable number.
199          if ($delta > 5) {          if ($delta > 5) {
200              print $handle ", $delta&nbsp;new&nbsp;$things{$thing}";              $retVal .= ", $delta&nbsp;new&nbsp;$things{$thing}";
201          }          }
202      }      }
     # Add the docking results.  
     my $pdbCount = $sfx->GetCount(['PDB'], "PDB(docking-count) > ?", [0]);  
     print $handle ", $pdbCount drug targets with in silico docking results";  
203      # Terminate the heading.      # Terminate the heading.
204      print $handle ".</h3>\n";      $retVal .= ".</h3>\n";
205      # Close the output file.      # Return it.
206      close $handle;      return $retVal;
 }  
   
 =head3 CreateSubForm  
   
     CreateSubForm($sfx, $fileName);  
   
 Output the subsystem summary form. The subsystem summary form allows the user  
 to select an organism and view a summary of its subsystems.  
   
 =over 4  
   
 =item sfx  
   
 A Sprout object that can be used to access the NMPDR database.  
   
 =item fileName  
   
 The name of the file to create with the form HTML in it.  
   
 =back  
   
 =cut  
   
 sub CreateSubForm {  
     # Get the parameters.  
     my ($sfx, $fileName) = @_;  
     # Start the form.  
     my @page = ();  
     push @page, start_form({method => "post", action => "../FIG/genome_statistics.cgi",  
                             enctype=> "application/x-www-form-urlencoded"});  
     # Make sure the script knows it's for SPROUT.  
     push @page, input({type => "hidden", name => "SPROUT", value => "1"});  
     # Surround the form parts with a table.  
     push @page, "<table><tr><td>";  
     # Add the buttons.  
     push @page, CGI::p("For the genome selected below, show " .  
                 input({type => "submit", name => "show_subsystems",  
                        value => "Subsystems", class => "button"}) .  
                 input({type => "submit", name => "show_reactions",  
                        value => "Reactions", class => "button"}));  
     # End the first table cell.  
     push @page, "</td></tr><tr><td>";  
     # Create the gene menu.  
     push @page, $sfx->GenomeMenu(id => 'genome', size => 10);  
     # Close the table.  
     push @page, "</td></tr></table>";  
     # Close the form.  
     push @page, end_form();  
     # Put together all the pieces.  
     my $wholePage = join("\n", @page);  
     # Open the output file.  
     my $handle = Open(undef, ">$fileName");  
     # Write out the HTML.  
     print $handle $wholePage;  
     # Close the file.  
     close $handle;  
   
 }  
   
 =head3 CreateOrgForm  
   
     CreateOrgForm($sfx, $fileName);  
   
 Output the organism summary form. The organism summary form allows the user  
 to select an organism and view its statistics.  
   
 =over 4  
   
 =item sfx  
   
 A Sprout object that can be used to access the NMPDR database.  
   
 =item fileName  
   
 The name of the file to create with the form HTML in it.  
   
 =back  
   
 =cut  
   
 sub CreateOrgForm {  
     # Get the parameters.  
     my ($sfx, $fileName) = @_;  
     # Start the form.  
     my @page = ();  
     push @page, start_form({method => "post", action => "../FIG/genome_statistics.cgi",  
                             enctype=> "application/x-www-form-urlencoded"});  
     # Make sure the script knows it's for SPROUT.  
     push @page, input({type => "hidden", name => "SPROUT", value => "1"});  
     # Surround the form parts with a table.  
     push @page, "<table><tr><td>";  
     # Add the button.  
     push @page, CGI::p("Search or view statistics for the genome selected below " .  
                        input({type => "submit", name => "statistics",  
                        value => "Go", class => "button"}));  
     # End the first table cell.  
     push @page, "</td></tr><tr><td>";  
     # Create the gene menu.  
     push @page, $sfx->GenomeMenu(id => 'genome', size => 10);  
     # Close the table.  
     push @page, "</td></tr></table>";  
     # Close the form.  
     push @page, end_form();  
     # Put together all the pieces.  
     my $wholePage = join("\n", @page);  
     # Open the output file.  
     my $handle = Open(undef, ">$fileName");  
     # Write out the HTML.  
     print $handle $wholePage;  
     # Close the file.  
     close $handle;  
   
207  }  }
208    
 =head3 CreateSproutDoc  
   
     CreateSproutDoc($sfx, $fileName);  
   
 Output the Sprout database documentation.  
   
 =over 4  
   
 =item sfx  
   
 A Sprout object that can be used to access the NMPDR database.  
   
 =item fileName  
   
 The name of the file to create with the documentation in it.  
   
 =back  
   
 =cut  
   
 sub CreateSproutDoc {  
     # Get the parameters.  
     my ($sfx, $fileName) = @_;  
     # Open the output file.  
     my $handle = Open(undef, ">$fileName");  
     # Write the Sprout database document into it.  
     print $handle $sfx->DisplayMetaData();  
     # Close the file.  
     close $handle;  
 }  
209    
210    
211  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3