[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.5, Fri Sep 13 18:54:12 2013 UTC revision 1.6, Fri Nov 8 18:42:26 2013 UTC
# 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 44  Line 49 
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 = Sapling->new();  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 63  Line 84 
84          $retVal->Add('genomesNotFound');          $retVal->Add('genomesNotFound');
85      } else {      } else {
86          # Here we can delete it.          # Here we can delete it.
87            Trace("Deleting $genomeID.") if T(3);
88          my $stats = $sprout->Delete(Genome => $genomeID, testMode => $showOnly);          my $stats = $sprout->Delete(Genome => $genomeID, testMode => $showOnly);
89          # Update the statistics.          # Update the statistics.
90          $retVal->Add('genomesFound');          $retVal->Add('genomesFound');

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3