[Bio] / FigKernelScripts / svr_expressed_genes_in_range.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/svr_expressed_genes_in_range.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 :     use strict;
3 :    
4 :     use Getopt::Long;
5 :     use SAPserver;
6 :     use ScriptThing;
7 :    
8 :     #
9 :     # This is a SAS Component.
10 :     #
11 :    
12 :     =head1 svr_expressed_genes_in_range
13 :    
14 :     svr_expressed_genes_in_range --min=minLevel --max=maxLevel <genome_ids.tbl >genome_data.tbl
15 :    
16 :     Compute the genes in the specified genomes that are expressed a particular fraction of the
17 :     time, where the fraction is a number between 0 and 1. The fraction is specified as a
18 :     range from a minimum to a maximum value. If the minimum is 1, then only genes expressed
19 :     all the time are returned. If the maximum is 0, then only genes that are never expressed
20 :     are returned.
21 :    
22 :     The expression level is computed by taking all the experiment results called I<on> and
23 :     dividing them by the total number of results called either I<on> or I<off>. In other
24 :     words, results that are called as indeterminate are ignored in the computation.
25 :    
26 :     This script takes as input a tab-delimited file with genome IDs at the end of each
27 :     line. For each genome ID, multiple output lines will be generated-- one per qualified gene--
28 :     and each generated line will have a level fraction and a FIG gene ID appended to it.
29 :    
30 :     This is a pipe command: the input is taken from the standard input and the output
31 :     is to the standard output.
32 :    
33 :     The following command-line options are supported.
34 :    
35 :     =over 4
36 :    
37 :     =item url
38 :    
39 :     The URL to use for the server. This is primarily a debugging option, and is used to
40 :     specify an alternate server script.
41 :    
42 :     =item c
43 :    
44 :     The index (1-based) of the column containing the genome ID. If this option is omitted,
45 :     the last column is used.
46 :    
47 :     =item min
48 :    
49 :     The minimum acceptable expression level. The default is 0, meaning all genes with an expression level
50 :     less than or equal to the maximum will be returned.
51 :    
52 :     =item max
53 :    
54 :     The maximum acceptable expression level. The default is 1, meaning all genes with an expression level
55 :     greater than or equal to the minimum level will be returned.
56 :    
57 :     =cut
58 :    
59 :     # Parse the command-line options.
60 :     my $url = '';
61 :     my $column = '';
62 :     my $max = 1;
63 :     my $min = 0;
64 :     my $opted = GetOptions('url=s' => \$url, 'c=i' => \$column, 'min=f' => \$min, 'max=f' => \$max);
65 :     if (! $opted) {
66 :     print "usage: svr_expressed_genes_in_range [--url=http://...] [--c=N] [--min=0.00] [--max=1.00] <input >output\n";
67 :     } else {
68 :     # Get the server object.
69 :     my $sapServer = SAPserver->new(url => $url);
70 :     # The main loop processes chunks of input.
71 :     while (my @tuples = ScriptThing::GetBatch(\*STDIN, 10, $column)) {
72 :     # Ask the server for results.
73 :     my $document = $sapServer->fids_expressed_in_range(-ids => [map { $_->[0] } @tuples],
74 :     -minLevel => $min, -maxLevel => $max);
75 :     # Loop through the IDs, producing output.
76 :     for my $tuple (@tuples) {
77 :     my ($id, $line) = @$tuple;
78 :     # Get this genome's data.
79 :     my $genomeData = $document->{$id};
80 :     # Did we get something?
81 :     if (! $genomeData) {
82 :     # No. Write an error notification.
83 :     print STDERR "Not found: $id\n";
84 :     } else {
85 :     # Yes. Loop through the features found for this genome, producing output lines.
86 :     for my $fid (sort keys %$genomeData) {
87 :     print join("\t", $line, $genomeData->{$fid}, $fid) . "\n";
88 :     }
89 :     }
90 :     }
91 :     }
92 :     }
93 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3