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

View of /Sprout/DeleteGenomes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sat Jan 28 08:58:07 2006 UTC (13 years, 8 months ago) by parrello
Branch: MAIN
Added as a utility for deleting Sprout genomes.

#!/usr/bin/perl -w

=head1 Delete Genomes from Sprout

This method deletes genomes from the Sprout database. Simply list the genomes
as command-line parameters.

The currently-supported command-line options are as follows.

=over 4

=item showOnly

If specified, the DELETE statements will be displayed but no records will be deleted.

=item trace

Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is 2.

=item sql

If specified, turns on tracing of SQL activity.

=item h

Display this commands parameters and options.

=back

=cut

use strict;
use Tracer;
use DocUtils;
use TestUtils;
use Cwd;
use FIG;
use Stats;
use Sprout;
use SFXlate;
use File::Copy;
use File::Path;

# Get the command-line options.
my ($options, @parameters) = StandardSetup(['ERDB', 'Sprout'],
                                        {
                                            showOnly => [0, 'Display DELETE statements without deleting.']
                                        },
                                            '<genome1> <genome2> ...',
                                            @ARGV);
# Get the Sprout object.
my $sprout = SFXlate->new_sprout_only();
# Save the show-only flag.
my $showOnly = $options->{showOnly};
# Create the statistics object.
my $retVal = Stats->new('genomesFound', 'genomesNotFound');
# Loop through the genome IDs.
for my $genomeID (@parameters) {
    # Find out if the genome is real.
    if (! $sprout->Exists('Genome', $genomeID)) {
        # Warn the user. Nothing can get deleted if the genome is not in the Genome
        # table.
        Trace("Genome $genomeID not found in the genome table.") if T(1);
        $retVal->Add('genomesNotFound');
    } else {
        # Here we can delete it.
        my $stats = $sprout->DeleteGenome($genomeID, $showOnly);
        # Update the statistics.
        $retVal->Add('genomesFound');
        $retVal->Accumulate($stats);
    }
}
# Display the statistcs.
Trace($retVal->Show()) if T(0);

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3