#!/usr/bin/perl -w
=head1 Genome Data Generator
This script creates a set of HTML include files that list the statistics for
the genomes in each of the genome groups. Genomes that are new to this version
of the Sprout will be specially marked. In order for this to work, both the
current and previous Sprout databases must be available on this machine.
This is one positional parameter: the name of a directory in which to place
the include files.
The currently-supported command-line options are as follows.
=over 4
=item user
Name suffix to be used for log files. If omitted, the PID is used.
=item trace
Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is 2. Tracing will be directly to the standard output
as well as to a CIC file in the FIG temporary directory,
where I is the value of the B option above.
=item sql
If specified, turns on tracing of SQL activity.
=item background
Save the standard and error output to files. The files will be created
in the FIG temporary directory and will be named CIC and
CIC, respectively, where I is the value of the
B option above.
=item h
Display this command's parameters and options.
=item strict
If specified, strict groups will be used; otherwise, groups with a common primary name
will be combined into a single group. (The primary name of the group is the first
capitalized word.)
=item oddStyle
Style to use for odd rows of the table.
=item evenStyle
Style to use for even rows of the table.
=item tableStyle
Style to use for the table itself.
=item markerStyle
Style to use for small-text markers (e.g. NEW!)
=item numStyle
Style to use for numeric cells.
=item counterStyle
Style to use for counter cells.
=item linkCGI
Path to the CGI script for displaying detailed statistics.
=back
=cut
use strict;
use Tracer;
use DocUtils;
use TestUtils;
use Cwd;
use File::Copy;
use File::Path;
use Sprout;
use SFXlate;
use CGI qw(:standard);
use FIG;
no warnings 'once'; # only when coding
# Get the command-line options and parameters.
my ($options, @parameters) = StandardSetup([qw(Sprout ERDB) ],
{
strict => [0, 'keep related groups separate'],
oddStyle => ['odd', 'style for odd rows'],
evenStyle => ['even', 'style for even rows'],
tableStyle => ['genomestats', 'style for whole table'],
markerStyle => ['tinytext', 'style for markers'],
numStyle => ['numcell', 'style for cells with numeric values'],
counterStyle => ['countercell', 'style for cells with counter values'],
linkCGI => ['../FIG/genome_statistics.cgi',
'path to CGI script for detailed statistics'],
},
"",
@ARGV);
# Verify the directory name.
my $targetDir = $parameters[0];
if (! $targetDir) {
Confess("No target directory specified.");
} elsif (! -d $targetDir) {
Confess("Target directory $targetDir not found.");
} else {
# *Get the old Sprout.
my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB);
# Extract the genome group data from the old Sprout.
my %oldGroupHash = $oldSprout->GetGroups();
if (! $options->{strict}) {
%oldGroupHash = Fix(%oldGroupHash);
}
# Get the new Sprout.
my $sprout = SFXlate->new_sprout_only();
my %newGroupHash = $sprout->GetGroups();
if (! $options->{strict}) {
%newGroupHash = Fix(%newGroupHash);
}
# Loop through the groups.
for my $groupID (keys %newGroupHash) {
Trace("Processing group $groupID.") if T(2);
# Get the genomes from the new hash.
my @newGenomes = @{$newGroupHash{$groupID}};
# Create a hash for finding if a genome is in the old group. If the entire group is
# new, we just use an empty hash.
my %oldGenomes = ();
if (exists $oldGroupHash{$groupID}) {
%oldGenomes = map { $_ => 1 } @{$oldGroupHash{$groupID}};
}
# Create the output file.
Open(\*GROUPFILE, ">$targetDir/$groupID.inc");
# Get the styles.
my ($tableStyle, $markerStyle, @rowStyle) = ($options->{tableStyle}, $options->{markerStyle},
$options->{evenStyle}, $options->{oddStyle});
my ($numStyle, $counterStyle) = ($options->{numStyle}, $options->{counterStyle});
# Start the table.
print GROUPFILE "