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

Annotation of /Sprout/GeneFile.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 :     =head1 GenomeFile
4 :    
5 :     This script generates a genome file. The file will include all complete genomes
6 :     except the ones listed as parameters.
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 :     =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 :     phone => ["", "phone number (international format) to call when load finishes"],
68 :     code => ["1", "genome access code"],
69 :     geneFile => ["$FIG_Config::sproutData/genes.tbl", "output file"],
70 :     },
71 :     "<exclude1> <exclude2> ...",
72 :     @ARGV);
73 :     # Set a variable to contain return type information.
74 :     my $rtype;
75 :     # Insure we catch errors.
76 :     eval {
77 :     my $fig = FIG->new();
78 :     # Get the access code.
79 :     my $code = $options->{code};
80 :     # Get a list of the complete genomes.
81 :     my @genes = $fig->genomes(1);
82 :     # Start a counter.
83 :     my $counter = 0;
84 :     # Open the output file.
85 :     my $outFile = $options->{geneFile};
86 :     Open(\*GENEFILE, ">$outFile");
87 :     # Loop through the genes, creating output.
88 :     for my $gene (@genes) {
89 :     # Check to see if this gene is being excluded.
90 :     if (grep { $_ eq $gene } @parameters) {
91 :     Trace("Genome $gene excluded.") if T(3);
92 :     } else {
93 :     print GENEFILE "$gene\t$code\n";
94 :     $counter++;
95 :     }
96 :     }
97 :     # Close the output file.
98 :     close GENEFILE;
99 :     Trace("$counter genomes written to $outFile.") if T(2);
100 :     };
101 :     if ($@) {
102 :     Trace("Script failed with error: $@") if T(0);
103 :     $rtype = "error";
104 :     } else {
105 :     Trace("Script complete.") if T(2);
106 :     $rtype = "no error";
107 :     }
108 :     if ($options->{phone}) {
109 :     my $msgID = Tracer::SendSMS($options->{phone}, "GenomeFile terminated with $rtype.");
110 :     if ($msgID) {
111 :     Trace("Phone message sent with ID $msgID.") if T(2);
112 :     } else {
113 :     Trace("Phone message not sent.") if T(2);
114 :     }
115 :     }
116 :    
117 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3