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

Annotation of /Sprout/SetGroup.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 :     =head1 Set Primary Group
4 :    
5 :     This script takes as parameters an NMPDR group name and a list of genome IDs and
6 :     updates the Sprout database to put the genomes into that group.
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 Cwd;
49 :     use File::Copy;
50 :     use File::Path;
51 :     use FIG;
52 :     use Sprout;
53 :     use SFXlate;
54 :    
55 :     # Get the command-line options and parameters.
56 :     my ($options, @parameters) = StandardSetup([qw(Sprout) ],
57 :     {
58 :     phone => ["", "phone number (international format) to call when load finishes"],
59 :     },
60 :     "<groupName> <genome1> <genome2> ... <genomeN>",
61 :     @ARGV);
62 :     # Set a variable to contain return type information.
63 :     my $rtype;
64 :     # Insure we catch errors.
65 :     eval {
66 :     # Get the sprout database.
67 :     my $sprout = SFXlate->new_sprout_only();
68 :     # Save the group name.
69 :     my $groupName = shift @parameters;
70 :     # Loop through the genomes, doing the update.
71 :     for my $genome (@parameters) {
72 :     Trace("Converting $genome to $groupName.") if T(3);
73 :     $sprout->UpdateEntity('Genome', $genome, { 'primary-group' => $groupName });
74 :     }
75 :     Trace("Processing complete.") if T(2);
76 :     };
77 :     if ($@) {
78 :     Trace("Script failed with error: $@") if T(0);
79 :     $rtype = "error";
80 :     } else {
81 :     Trace("Script complete.") if T(2);
82 :     $rtype = "no error";
83 :     }
84 :     if ($options->{phone}) {
85 :     my $msgID = Tracer::SendSMS($options->{phone}, "Set Primary Group terminated with $rtype.");
86 :     if ($msgID) {
87 :     Trace("Phone message sent with ID $msgID.") if T(2);
88 :     } else {
89 :     Trace("Phone message not sent.") if T(2);
90 :     }
91 :     }
92 :    
93 :    
94 :    
95 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3