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

Annotation of /Sprout/CorePegs.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 Core Peg List
21 :    
22 :     This is a simple script that creates a tab-delimited list of all the
23 :     features for the original core NMPDR organisms. The single positional
24 :     parameter is the name of the output file. If no output file is
25 :     specified, output will be to the standard output.
26 :    
27 :     The currently-supported command-line options are as follows.
28 :    
29 :     =over 4
30 :    
31 :     =item user
32 :    
33 :     Name suffix to be used for log files. If omitted, the PID is used.
34 :    
35 :     =item trace
36 :    
37 :     Numeric trace level. A higher trace level causes more messages to appear. The
38 :     default trace level is 2. Tracing will be directly to the standard output
39 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
40 :     where I<User> is the value of the B<user> option above.
41 :    
42 :     =item sql
43 :    
44 :     If specified, turns on tracing of SQL activity.
45 :    
46 :     =item background
47 :    
48 :     Save the standard and error output to files. The files will be created
49 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
50 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
51 :     B<user> option above.
52 :    
53 :     =item h
54 :    
55 :     Display this command's parameters and options.
56 :    
57 :     =item phone
58 :    
59 :     Phone number to message when the script is complete.
60 :    
61 :     =item filter
62 :    
63 :     Type of filtering to apply. If C<pegs>, only true PEGs will be included. If C<essential>,
64 :     only essential genes will be included. Otherwise, all genes will be included.
65 :     be displayed.
66 :    
67 :     =item
68 :    
69 :     =back
70 :    
71 :     =cut
72 :    
73 :     use strict;
74 :     use Tracer;
75 :     use DocUtils;
76 :     use TestUtils;
77 :     use Sprout;
78 :     use SFXlate;
79 :    
80 :     # Get the command-line options and parameters.
81 :     my ($options, @parameters) = StandardSetup([qw(Sprout) ],
82 :     {
83 :     filter => ["", "filtering type: pegs or essential"],
84 :     phone => ["", "phone number (international format) to call when load finishes"],
85 :     },
86 :     "<fileName>",
87 :     @ARGV);
88 :     # Set a variable to contain return type information.
89 :     my $rtype;
90 :     # Insure we catch errors.
91 :     eval {
92 :     # Get the Sprout object.
93 :     my $sprout = SFXlate->new_sprout_only();
94 :     # Check for a file name.
95 :     if ($parameters[0]) {
96 :     # A file was specified, so we open it.
97 :     Open(\*STDOUT, ">$parameters[0]");
98 :     Trace("Output will be to $parameters[0].") if T(2);
99 :     } else {
100 :     Trace("Standard output will be used.") if T(2);
101 :     }
102 :     # Now we just output the list to the standard output.
103 :     # Get the list of core organism genomes.
104 :     my @genomes = $sprout->RealCoreGenomes();
105 :     # We need to compute the filter clause, the parameters, and the
106 :     # result columns. The base filter is by genome ID (which is the
107 :     # first parameter). The base result column list is the
108 :     # feature ID and assignment. Additional filtering and stuff could be
109 :     # required by the filter option.
110 :     my $filter = "HasFeature(from-link) = ?";
111 :     my @parms = ('genomeID');
112 :     my @cols = ('Feature(id)', 'Feature(assignment)');
113 :     if ($options->{filter} eq 'pegs') {
114 :     $filter .= ' AND Feature(type) eq ?';
115 :     push @parms, 'peg';
116 :     } elsif ($options->{filter} eq 'essential') {
117 :     $filter .= ' AND Feature(essential) IS NOT NULL';
118 :     push @cols, 'Feature(essential)';
119 :     }
120 :     # Set up a counter.
121 :     my $totalCount = 0;
122 :     # Loop through the organisms.
123 :     for my $genome (sort @genomes) {
124 :     Trace("Processing $genome.") if T(3);
125 :     # Store the genome ID in the parms.
126 :     $parms[0] = $genome;
127 :     # Get this organism's features according to the filter.
128 :     my $query = $sprout->Get(['HasFeature', 'Feature'], $filter, \@parms);
129 :     # Set up a counter.
130 :     my $genomeCount = 0;
131 :     # Write them to the output file.
132 :     while (my $result = $query->Fetch()) {
133 :     my @fields = $result->Values(\@cols);
134 :     Tracer::PutLine(\*STDOUT, \@fields);
135 :     $genomeCount++;
136 :     }
137 :     # Update the counts.
138 :     Trace("$genomeCount features found for $genome.") if T(3);
139 :     $totalCount += $genomeCount;
140 :     }
141 :     Trace("$totalCount features output.") if T(2);
142 :     # Close the output file.
143 :     close STDOUT;
144 :     };
145 :     if ($@) {
146 :     Trace("Script failed with error: $@") if T(0);
147 :     $rtype = "error";
148 :     } else {
149 :     Trace("Script complete.") if T(2);
150 :     $rtype = "no error";
151 :     }
152 :     if ($options->{phone}) {
153 :     my $msgID = Tracer::SendSMS($options->{phone}, "Core Peg List terminated with $rtype.");
154 :     if ($msgID) {
155 :     Trace("Phone message sent with ID $msgID.") if T(2);
156 :     } else {
157 :     Trace("Phone message not sent.") if T(2);
158 :     }
159 :     }
160 :    
161 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3