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

Annotation of /Sprout/BBHCheck.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 :     =head1 BBH Check
4 :    
5 :     Find all genomes in Sprout without any BBHs. This can be an indicator of bad
6 :     data in the SEED.
7 :    
8 :     The currently-supported command-line options are as follows.
9 :    
10 :     =over 4
11 :    
12 :     =item user
13 :    
14 :     Name suffix to be used for log files. If omitted, the PID is used.
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. Tracing will be directly to the standard output
20 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
21 :     where I<User> is the value of the B<user> option above.
22 :    
23 :     =item sql
24 :    
25 :     If specified, turns on tracing of SQL activity.
26 :    
27 :     =item background
28 :    
29 :     Save the standard and error output to files. The files will be created
30 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
31 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
32 :     B<user> option above.
33 :    
34 :     =item h
35 :    
36 :     Display this command's parameters and options.
37 :    
38 :     =item phone
39 :    
40 :     Phone number to message when the script is complete.
41 :    
42 :     =back
43 :    
44 :     =cut
45 :    
46 :     use strict;
47 :     use Tracer;
48 :     use DocUtils;
49 :     use TestUtils;
50 :     use Cwd;
51 :     use File::Copy;
52 :     use File::Path;
53 :     use FIG;
54 :     use Sprout;
55 :     use SFXlate;
56 : parrello 1.5 use FIGRules;
57 : parrello 1.1
58 :     # Get the command-line options and parameters.
59 :     my ($options, @parameters) = StandardSetup([qw(Sprout) ],
60 :     {
61 : parrello 1.2 fig => [0, "check the SEED database as well as the Sprout"],
62 : parrello 1.1 phone => ["", "phone number (international format) to call when load finishes"],
63 :     },
64 :     "",
65 :     @ARGV);
66 :     # Set a variable to contain return type information.
67 :     my $rtype;
68 :     # Insure we catch errors.
69 :     eval {
70 :     # Get a sprout object.
71 :     my $sprout = SFXlate->new_sprout_only();
72 : parrello 1.2 # Get the FIG object's DB handle.
73 :     my $fig = FIG->new();
74 : parrello 1.1 # Get the list of genomes.
75 :     my @genomes = $sprout->Genomes();
76 :     # Get the genome names.
77 :     my %genomeNames = ();
78 :     for my $genome (@genomes) {
79 :     my $name = $sprout->GenusSpecies($genome) . " [$genome]";
80 :     $genomeNames{$name} = $genome;
81 :     }
82 :     # Count the bad genomes.
83 :     my $badGenomes = 0;
84 :     # Process the genomes in name order.
85 :     for my $name (sort keys %genomeNames) {
86 :     my $genome = $genomeNames{$name};
87 :     # Count this genome's BBHs.
88 : parrello 1.5 my $count = FIGRules::BatchBBHs("fig|$genome.%", 1e-10);
89 : parrello 1.1 # Get the genome name.
90 :     my $name = $sprout->GenusSpecies($genome) . " [$genome]";
91 :     # A count of 0 is bad.
92 : parrello 1.5 if (! $count) {
93 :     Trace("$name has no BBHs. ***") if T(1);
94 :     $badGenomes++;
95 :     } else {
96 : parrello 1.1 Trace("$name BBH count is $count.") if T(3);
97 :     }
98 :     }
99 :     # Tell the user how bad things are.
100 :     my $total = scalar @genomes;
101 :     Trace("$badGenomes out of $total genomes had no BBHs.") if T(2);
102 :     };
103 :     if ($@) {
104 :     Trace("Script failed with error: $@") if T(0);
105 :     $rtype = "error";
106 :     } else {
107 :     Trace("Script complete.") if T(2);
108 :     $rtype = "no error";
109 :     }
110 :     if ($options->{phone}) {
111 :     my $msgID = Tracer::SendSMS($options->{phone}, "BBH Check terminated with $rtype.");
112 :     if ($msgID) {
113 :     Trace("Phone message sent with ID $msgID.") if T(2);
114 :     } else {
115 :     Trace("Phone message not sent.") if T(2);
116 :     }
117 :     }
118 :    
119 :    
120 :    
121 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3