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

Diff of /Sprout/DeleteGenomes.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Tue Oct 3 02:48:59 2006 UTC revision 1.6, Fri Nov 8 18:42:26 2013 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  =head1 Delete Genomes from Sprout  =head1 Delete Genomes from Sapling
4    
5  This method deletes genomes from the Sprout database. Simply list the genomes  This method deletes genomes from the Sapling database. Simply list the genomes
6  as command-line parameters.  as command-line parameters.
7    
8  The currently-supported command-line options are as follows.  The currently-supported command-line options are as follows.
# Line 24  Line 24 
24    
25  =item h  =item h
26    
27  Display this commands parameters and options.  Display this command's parameters and options.
28    
29    =item file
30    
31    The list of genomes will be taken from the first column of the specified tab-delimited file,
32    instead of from the command line.
33    
34  =back  =back
35    
# Line 32  Line 37 
37    
38  use strict;  use strict;
39  use Tracer;  use Tracer;
 use DocUtils;  
 use TestUtils;  
40  use Cwd;  use Cwd;
41  use FIG;  use FIG;
42  use Stats;  use Stats;
43  use Sprout;  use Sapling;
 use SFXlate;  
44  use File::Copy;  use File::Copy;
45  use File::Path;  use File::Path;
46    
47  # Get the command-line options.  # Get the command-line options.
48  my ($options, @parameters) = StandardSetup(['ERDB', 'Sprout'],  my ($options, @parameters) = StandardSetup(['ERDB'],
49                                          {                                          {
50                                              showOnly => [0, 'Display DELETE statements without deleting.'],                                              showOnly => [0, 'Display DELETE statements without deleting.'],
51                                              trace => [2, 'tracing level'],                                              trace => [2, 'tracing level'],
52                                                file => ['', 'genome ID file']
53                                          },                                          },
54                                              '<genome1> <genome2> ...',                                              '<genome1> <genome2> ...',
55                                              @ARGV);                                              @ARGV);
56  # Get the Sprout object.  # Get the Sapling object.
57  my $sprout = SFXlate->new_sprout_only();  my $sprout = Sapling->new();
58  # Save the show-only flag.  # Save the show-only flag.
59  my $showOnly = $options->{showOnly};  my $showOnly = $options->{showOnly};
60  # Create the statistics object.  # Create the statistics object.
61  my $retVal = Stats->new('genomesFound', 'genomesNotFound');  my $retVal = Stats->new('genomesFound', 'genomesNotFound');
62    # The list of genome IDs will be put in here.
63    my @genomes;
64    # Look for a genome ID file.
65    if ($options->{file}) {
66        # We found one. Read the genome IDs.
67        my $ih = Open(undef, "<$options->{file}");
68        while (! eof $ih) {
69            my ($genomeID) = Tracer::GetLine($ih);
70            push @genomes, $genomeID;
71        }
72        Trace(scalar(@genomes) . " genome IDs read from $options->{file}.") if T(2);
73    } else {
74        @genomes = @parameters;
75        Trace(scalar(@genomes) . " genome IDs found on command line.") if T(2);
76    }
77  # Loop through the genome IDs.  # Loop through the genome IDs.
78  for my $genomeID (@parameters) {  for my $genomeID (@genomes) {
79      # Find out if the genome is real.      # Find out if the genome is real.
80      if (! $sprout->Exists('Genome', $genomeID)) {      if (! $sprout->Exists('Genome', $genomeID)) {
81          # Warn the user. Nothing can get deleted if the genome is not in the Genome          # Warn the user. Nothing can get deleted if the genome is not in the Genome
# Line 66  Line 84 
84          $retVal->Add('genomesNotFound');          $retVal->Add('genomesNotFound');
85      } else {      } else {
86          # Here we can delete it.          # Here we can delete it.
87          my $stats = $sprout->DeleteGenome($genomeID, $showOnly);          Trace("Deleting $genomeID.") if T(3);
88            my $stats = $sprout->Delete(Genome => $genomeID, testMode => $showOnly);
89          # Update the statistics.          # Update the statistics.
90          $retVal->Add('genomesFound');          $retVal->Add('genomesFound');
91          $retVal->Accumulate($stats);          $retVal->Accumulate($stats);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3