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

Annotation of /Sprout/GeneFile.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 GenomeFile
4 :    
5 :     This script generates a genome file. The file will include all complete genomes
6 : parrello 1.2 plus the ones listed as parameters.
7 : parrello 1.1
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 :     =item geneFile
43 :    
44 :     Name of the gene file to produce. The default is C<genes.tbl> in the SproutData
45 :     directory.
46 :    
47 :     =item code
48 :    
49 :     Access code to assign to the genomes.
50 :    
51 :     =back
52 :    
53 :     =cut
54 :    
55 :     use strict;
56 :     use Tracer;
57 :     use DocUtils;
58 :     use TestUtils;
59 :     use Cwd;
60 :     use File::Copy;
61 :     use File::Path;
62 :     use FIG;
63 :    
64 :     # Get the command-line options and parameters.
65 :     my ($options, @parameters) = StandardSetup([qw() ],
66 :     {
67 : parrello 1.3 trace => [2, 'tracing level'],
68 : parrello 1.1 phone => ["", "phone number (international format) to call when load finishes"],
69 :     code => ["1", "genome access code"],
70 :     geneFile => ["$FIG_Config::sproutData/genes.tbl", "output file"],
71 :     },
72 : parrello 1.2 "<include1> <include2> ...",
73 : parrello 1.1 @ARGV);
74 :     # Set a variable to contain return type information.
75 :     my $rtype;
76 :     # Insure we catch errors.
77 :     eval {
78 :     my $fig = FIG->new();
79 :     # Get the access code.
80 :     my $code = $options->{code};
81 :     # Get a list of the complete genomes.
82 :     my @genes = $fig->genomes(1);
83 : parrello 1.2 # Add the genomes in the parameter list, taking care to avoid
84 :     # duplicates.
85 :     for my $parm (@parameters) {
86 :     if (grep { $_ eq $parm } @genes) {
87 :     Trace("Genome $parm is now in the standard list.") if T(2);
88 :     } else {
89 :     push @genes, $parm;
90 :     }
91 :     }
92 : parrello 1.1 # Start a counter.
93 :     my $counter = 0;
94 :     # Open the output file.
95 :     my $outFile = $options->{geneFile};
96 :     Open(\*GENEFILE, ">$outFile");
97 :     # Loop through the genes, creating output.
98 :     for my $gene (@genes) {
99 : parrello 1.2 print GENEFILE "$gene\t$code\n";
100 :     $counter++;
101 : parrello 1.1 }
102 :     # Close the output file.
103 :     close GENEFILE;
104 :     Trace("$counter genomes written to $outFile.") if T(2);
105 :     };
106 :     if ($@) {
107 :     Trace("Script failed with error: $@") if T(0);
108 :     $rtype = "error";
109 :     } else {
110 :     Trace("Script complete.") if T(2);
111 :     $rtype = "no error";
112 :     }
113 :     if ($options->{phone}) {
114 :     my $msgID = Tracer::SendSMS($options->{phone}, "GenomeFile terminated with $rtype.");
115 :     if ($msgID) {
116 :     Trace("Phone message sent with ID $msgID.") if T(2);
117 :     } else {
118 :     Trace("Phone message not sent.") if T(2);
119 :     }
120 :     }
121 :    
122 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3