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

Annotation of /Sprout/DeleteGenomes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 : parrello 1.4 =head1 Delete Genomes from Sapling
4 : parrello 1.1
5 : parrello 1.4 This method deletes genomes from the Sapling database. Simply list the genomes
6 : parrello 1.1 as command-line parameters.
7 :    
8 :     The currently-supported command-line options are as follows.
9 :    
10 :     =over 4
11 :    
12 :     =item showOnly
13 :    
14 :     If specified, the DELETE statements will be displayed but no records will be deleted.
15 :    
16 :     =item trace
17 :    
18 :     Numeric trace level. A higher trace level causes more messages to appear. The
19 :     default trace level is 2.
20 :    
21 :     =item sql
22 :    
23 :     If specified, turns on tracing of SQL activity.
24 :    
25 :     =item h
26 :    
27 :     Display this commands parameters and options.
28 :    
29 :     =back
30 :    
31 :     =cut
32 :    
33 :     use strict;
34 :     use Tracer;
35 :     use Cwd;
36 :     use FIG;
37 :     use Stats;
38 : parrello 1.4 use Sapling;
39 : parrello 1.1 use File::Copy;
40 :     use File::Path;
41 :    
42 :     # Get the command-line options.
43 : parrello 1.4 my ($options, @parameters) = StandardSetup(['ERDB'],
44 : parrello 1.1 {
45 : parrello 1.2 showOnly => [0, 'Display DELETE statements without deleting.'],
46 :     trace => [2, 'tracing level'],
47 : parrello 1.1 },
48 :     '<genome1> <genome2> ...',
49 :     @ARGV);
50 :     # Get the Sprout object.
51 : parrello 1.4 my $sprout = Sapling->new();
52 : parrello 1.1 # Save the show-only flag.
53 :     my $showOnly = $options->{showOnly};
54 :     # Create the statistics object.
55 :     my $retVal = Stats->new('genomesFound', 'genomesNotFound');
56 :     # Loop through the genome IDs.
57 :     for my $genomeID (@parameters) {
58 :     # Find out if the genome is real.
59 :     if (! $sprout->Exists('Genome', $genomeID)) {
60 :     # Warn the user. Nothing can get deleted if the genome is not in the Genome
61 :     # table.
62 :     Trace("Genome $genomeID not found in the genome table.") if T(1);
63 :     $retVal->Add('genomesNotFound');
64 :     } else {
65 :     # Here we can delete it.
66 : parrello 1.5 my $stats = $sprout->Delete(Genome => $genomeID, testMode => $showOnly);
67 : parrello 1.1 # Update the statistics.
68 :     $retVal->Add('genomesFound');
69 :     $retVal->Accumulate($stats);
70 :     }
71 :     }
72 :     # Display the statistcs.
73 :     Trace($retVal->Show()) if T(0);
74 :    
75 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3