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

Annotation of /Sprout/NmpdrStatus.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     =head1 NMPDR Status Checker
21 :    
22 :     This script examines all of the genomes and displays the NMPDR group for each.
23 :    
24 :     The currently-supported command-line options are as follows.
25 :    
26 :     =over 4
27 :    
28 :     =item user
29 :    
30 :     Name suffix to be used for log files. If omitted, the PID is used.
31 :    
32 :     =item trace
33 :    
34 :     Numeric trace level. A higher trace level causes more messages to appear. The
35 :     default trace level is 2. Tracing will be directly to the standard output
36 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
37 :     where I<User> is the value of the B<user> option above.
38 :    
39 :     =item sql
40 :    
41 :     If specified, turns on tracing of SQL activity.
42 :    
43 :     =item background
44 :    
45 :     Save the standard and error output to files. The files will be created
46 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
47 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
48 :     B<user> option above.
49 :    
50 :     =item h
51 :    
52 :     Display this command's parameters and options.
53 :    
54 :     =item phone
55 :    
56 :     Phone number to message when the script is complete.
57 :    
58 :     # TODO: more options (use =item directive and add them to the StandardSetup
59 :     # call below)
60 :    
61 :     =back
62 :    
63 :     =cut
64 :    
65 :     use strict;
66 :     use Tracer;
67 :     use DocUtils;
68 :     use TestUtils;
69 :     use FIG;
70 :     use Cwd;
71 :     use File::Copy;
72 :     use File::Path;
73 :    
74 :     # Get the command-line options and parameters.
75 :     my ($options, @parameters) = StandardSetup([qw(FIG) ],
76 :     {
77 :     phone => ["", "phone number (international format) to call when load finishes"],
78 :     },
79 :     "",
80 :     @ARGV);
81 :     # Set a variable to contain return type information.
82 :     my $rtype;
83 :     # Insure we catch errors.
84 :     eval {
85 :     # Get the FIG object.
86 :     my $fig = FIG->new();
87 :     # Get a list of all the genomes.
88 :     my $genomes = $fig->genome_list();
89 :     Trace(scalar(@{$genomes}) . " found.") if T(3);
90 :     # Loop through the list.
91 :     for my $genome (@{$genomes}) {
92 :     # Get the genome ID and name.
93 :     my ($genomeID, $genomeName) = @{$genome};
94 :     # Only proceed if the genome is complete. Otherwise, it's not part of NMPDR.
95 :     my $flag = $fig->is_complete($genomeID);
96 :     Trace("Complete flag for $genomeID is $flag.") if T(4);
97 :     if ($flag) {
98 :     # Compute the NMPDR group.
99 :     my $nmpdrFile = "$FIG_Config::organisms/$genomeID/NMPDR";
100 :     if (-e $nmpdrFile) {
101 :     # Get the NMPDR group from the file contents.
102 :     my ($nmpdrGroup) = Tracer::GetFile($nmpdrFile);
103 :     # Trace the result.
104 :     Trace("$genomeID ($genomeName) = $nmpdrGroup") if T(2);
105 :     }
106 :     } else {
107 :     # Denote this is not an NMPDR genome.
108 :     Trace("$genomeID ($genomeName) not used.") if T(3);
109 :     }
110 :     }
111 :     Trace("Processing complete.") if T(2);
112 :     };
113 :     if ($@) {
114 :     Trace("Script failed with error: $@") if T(0);
115 :     $rtype = "error";
116 :     } else {
117 :     Trace("Script complete.") if T(2);
118 :     $rtype = "no error";
119 :     }
120 :     if ($options->{phone}) {
121 :     my $msgID = Tracer::SendSMS($options->{phone}, "NMPDR Status Checker terminated with $rtype.");
122 :     if ($msgID) {
123 :     Trace("Phone message sent with ID $msgID.") if T(2);
124 :     } else {
125 :     Trace("Phone message not sent.") if T(2);
126 :     }
127 :     }
128 :    
129 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3