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

Annotation of /Sprout/NmpdrFix.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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 :     use strict;
21 :     use Tracer;
22 :     use DocUtils;
23 :    
24 :     =head1 NmpdrFix Script
25 :    
26 :     =head2 Introduction
27 :    
28 :     This script makes small changes to the NMPDR configuration. It is used in
29 :     several standard operating procedures.
30 :    
31 :     =head2 Command-Line Options
32 :    
33 :     =over 4
34 :    
35 :     =item trace
36 :    
37 :     Specifies the tracing level. The higher the tracing level, the more messages
38 :     will appear in the trace log. Use E to specify emergency tracing.
39 :    
40 :     =item ff
41 :    
42 :     If specified, the new release number for FigFams. The NMPDR will be pointed to
43 :     the specified release.
44 :    
45 : parrello 1.2 =item sectionTest
46 :    
47 :     If specified, a comma-delimited list of genome IDs to be used for testing
48 :     the Sprout loader. A C<sections.tbl> file will be created using the specified
49 :     genome IDs.
50 :    
51 : parrello 1.1 =item user
52 :    
53 :     Name suffix to be used for log files. If omitted, the PID is used.
54 :    
55 :     =item sql
56 :    
57 :     If specified, turns on tracing of SQL activity.
58 :    
59 :     =item background
60 :    
61 :     Save the standard and error output to files. The files will be created
62 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
63 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
64 :     B<user> option above.
65 :    
66 :     =item help
67 :    
68 :     Display this command's parameters and options.
69 :    
70 :     =item warn
71 :    
72 :     Create an event in the RSS feed when an error occurs.
73 :    
74 :     =item phone
75 :    
76 :     Phone number to message when the script is complete.
77 :    
78 :     =back
79 :    
80 :     =cut
81 :    
82 :     # Get the command-line options and parameters.
83 :     my ($options, @parameters) = StandardSetup([qw(DocUtils) ],
84 :     {
85 :     trace => ["2", "tracing level"],
86 : parrello 1.2 sectionTest => ["", "comma-delimited list of genomes for load testing"],
87 : parrello 1.1 ff => ["", "new figfam release number"],
88 :     phone => ["", "phone number (international format) to call when load finishes"]
89 :     },
90 :     "",
91 :     @ARGV);
92 :     # Set a variable to contain return type information.
93 :     my $rtype;
94 :     # Insure we catch errors.
95 :     eval {
96 :     # Check the options.
97 :     if ($options->{ff}) {
98 :     # Here there's a new FIGfams release.
99 :     my $release = $options->{ff};
100 :     # Compute the new FIGfams directory name.
101 :     my $ffDir = "/disks/nmpdr/figfams/Release$release/FigfamsData.Release.$release";
102 :     # Insure it exists.
103 :     if (! -d $ffDir) {
104 :     Trace("Error: FIGfams release $release is unavailable or in the wrong directory.") if T(0);
105 :     } else {
106 :     # It does, so stash it in the FIG_Config.
107 :     my $config_file = "$FIG_Config::fig_disk/config/FIG_Config.pm";
108 :     Trace("Updating $config_file for FIGfams release $release.") if T(2);
109 :     DocUtils::ModifyConfigFile($config_file, { FigfamsData => $ffDir }, []);
110 :     }
111 :     }
112 : parrello 1.2 if ($options->{sectionTest}) {
113 :     # Here we need to create the sections.tbl file.
114 :     my $sectionFile = "$FIG_Config::sproutData/sections.tbl";
115 :     my $oh = Open(undef, ">$sectionFile");
116 :     # Get the genome IDs to put in it.
117 :     my @genomes = split /\s*,\s*/, $options->{sectionTest};
118 :     Trace(scalar(@genomes) . " found for load test: " . join(", ", @genomes)) if T(3);
119 :     print $oh join("\n", @genomes, "Globals");
120 :     close $oh;
121 :     Trace("Test file \"$sectionFile\" created.") if T(2);
122 :     }
123 : parrello 1.1 };
124 :     if ($@) {
125 :     Trace("Script failed with error: $@") if T(0);
126 :     $rtype = "error";
127 :     } else {
128 :     Trace("Script complete.") if T(2);
129 :     $rtype = "no error";
130 :     }
131 :     if ($options->{phone}) {
132 :     my $msgID = Tracer::SendSMS($options->{phone}, "NmpdrFix terminated with $rtype.");
133 :     if ($msgID) {
134 :     Trace("Phone message sent with ID $msgID.") if T(2);
135 :     } else {
136 :     Trace("Phone message not sent.") if T(2);
137 :     }
138 :     }
139 :    
140 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3