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

Diff of /Sprout/CorePegs.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed Feb 6 23:20:20 2008 UTC revision 1.2, Thu Feb 14 19:04:15 2008 UTC
# Line 20  Line 20 
20  =head1 Core Peg List  =head1 Core Peg List
21    
22  This is a simple script that creates a tab-delimited list of all the  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  features for the selected NMPDR organisms. The single positional
24  parameter is the name of the output file. If no output file is  parameter is the name of the output file.
 specified, output will be to the standard output.  
25    
26  The currently-supported command-line options are as follows.  The currently-supported command-line options are as follows.
27    
28  =over 4  =over 4
29    
30    =item orgs
31    
32    Organisms whose features are desired. If C<all>, then all
33    organisms will be listed. If C<nmpdr>, then all organisms in
34    NMPDR groups will be listed. If C<core>, then only the organisms
35    in the core NMPDR groups will be listed. The default is C<core>.
36    
37  =item user  =item user
38    
39  Name suffix to be used for log files. If omitted, the PID is used.  Name suffix to be used for log files. If omitted, the PID is used.
# Line 62  Line 68 
68    
69  Type of filtering to apply. If C<pegs>, only true PEGs will be included. If C<essential>,  Type of filtering to apply. If C<pegs>, only true PEGs will be included. If C<essential>,
70  only essential genes will be included. Otherwise, all genes will be included.  only essential genes will be included. Otherwise, all genes will be included.
71  be displayed.  
72    
73  =item  =item
74    
# Line 80  Line 86 
86  # Get the command-line options and parameters.  # Get the command-line options and parameters.
87  my ($options, @parameters) = StandardSetup([qw(Sprout) ],  my ($options, @parameters) = StandardSetup([qw(Sprout) ],
88                                             {                                             {
89                                                  orgs => ["core", "type of organisms (core, nmpdr, all)"],
90                                                filter => ["", "filtering type: pegs or essential"],                                                filter => ["", "filtering type: pegs or essential"],
91                                                phone => ["", "phone number (international format) to call when load finishes"],                                                phone => ["", "phone number (international format) to call when load finishes"],
92                                             },                                             },
# Line 91  Line 98 
98  eval {  eval {
99      # Get the Sprout object.      # Get the Sprout object.
100      my $sprout = SFXlate->new_sprout_only();      my $sprout = SFXlate->new_sprout_only();
101        # Now we just output the list to the standard output.
102        # Next, we need to determine the genomes of interest. This
103        # is determined by the "orgs" option.
104        my @genomes = $sprout->CoreGenomes($options->{orgs});
105        # If no genomes are found, it's an error.
106        my $genomes = scalar @genomes;
107        if (! $genomes) {
108            Confess("No genomes found for orgs option \"$options->{org}\".");
109        } else {
110            Trace("$genomes genomes will be processed.") if T(2);
111      # Check for a file name.      # Check for a file name.
112      if ($parameters[0]) {          if (! $parameters[0]) {
113                Confess("No output file specified.");
114            } else {
115          # A file was specified, so we open it.          # A file was specified, so we open it.
116          Open(\*STDOUT, ">$parameters[0]");              my $oh = Open(undef, ">$parameters[0]");
117          Trace("Output will be to $parameters[0].") if T(2);          Trace("Output will be to $parameters[0].") if T(2);
     } else {  
         Trace("Standard output will be used.") if T(2);  
     }  
     # Now we just output the list to the standard output.  
     # Get the list of core organism genomes.  
     my @genomes = $sprout->RealCoreGenomes();  
118      # We need to compute the filter clause, the parameters, and the      # We need to compute the filter clause, the parameters, and the
119      # result columns. The base filter is by genome ID (which is the      # result columns. The base filter is by genome ID (which is the
120      # first parameter). The base result column list is the      # first parameter). The base result column list is the
# Line 111  Line 124 
124      my @parms = ('genomeID');      my @parms = ('genomeID');
125      my @cols = ('Feature(id)', 'Feature(assignment)');      my @cols = ('Feature(id)', 'Feature(assignment)');
126      if ($options->{filter} eq 'pegs') {      if ($options->{filter} eq 'pegs') {
127                    # Here we filter by feature type to get PEGs only.
128          $filter .= ' AND Feature(type) eq ?';          $filter .= ' AND Feature(type) eq ?';
129          push @parms, 'peg';          push @parms, 'peg';
130                    Trace("Filtering for PEGs.") if T(2);
131      } elsif ($options->{filter} eq 'essential') {      } elsif ($options->{filter} eq 'essential') {
132                    # Here we filter by the essentiality column.
133          $filter .= ' AND Feature(essential) IS NOT NULL';          $filter .= ' AND Feature(essential) IS NOT NULL';
134          push @cols, 'Feature(essential)';          push @cols, 'Feature(essential)';
135                    Trace("Filtering for essential genes.") if T(2);
136                } elsif ($options->{filter}) {
137                    # Here the filter type is invalid.
138                    Confess("Unknown filter type \"$options->{filter}\".");
139      }      }
140      # Set up a counter.      # Set up a counter.
141      my $totalCount = 0;      my $totalCount = 0;
# Line 131  Line 151 
151          # Write them to the output file.          # Write them to the output file.
152          while (my $result = $query->Fetch()) {          while (my $result = $query->Fetch()) {
153              my @fields = $result->Values(\@cols);              my @fields = $result->Values(\@cols);
154              Tracer::PutLine(\*STDOUT, \@fields);                      Tracer::PutLine($oh, \@fields);
155              $genomeCount++;              $genomeCount++;
156          }          }
157          # Update the counts.          # Update the counts.
# Line 140  Line 160 
160      }      }
161      Trace("$totalCount features output.") if T(2);      Trace("$totalCount features output.") if T(2);
162      # Close the output file.      # Close the output file.
163      close STDOUT;              close $oh;
164            }
165        }
166  };  };
167  if ($@) {  if ($@) {
168      Trace("Script failed with error: $@") if T(0);      Trace("Script failed with error: $@") if T(0);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3