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

Annotation of /FigKernelScripts/svr_function_of.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 use strict;
2 : overbeek 1.3 use Data::Dumper;
3 :     use Carp;
4 : parrello 1.1
5 : disz 1.4 #
6 :     # This is a SAS Component
7 :     #
8 :    
9 : parrello 1.1
10 : overbeek 1.3 =head1 svr_function_of
11 :    
12 :     Get functions of protein-encoding genes
13 :    
14 :     ------
15 : parrello 1.6
16 :     Example:
17 :    
18 :     svr_all_features 3702.1 peg | svr_function_of
19 : overbeek 1.3
20 :     would produce a 2-column table. The first column would contain
21 :     PEG IDs for genes occurring in genome 3702.1, and the second
22 :     would contain the functions of those genes.
23 : parrello 1.6
24 : overbeek 1.3 ------
25 : parrello 1.1
26 : overbeek 1.3 The standard input should be a tab-separated table (i.e., each line
27 :     is a tab-separated set of fields). Normally, the last field in each
28 :     line would contain the PEG for which functions are being requested.
29 :     If some other column contains the PEGs, use
30 : parrello 1.1
31 : overbeek 1.3 -c N
32 : parrello 1.1
33 : overbeek 1.3 where N is the column (from 1) that contains the PEG in each case.
34 : parrello 1.1
35 : overbeek 1.3 This is a pipe command. The input is taken from the standard input, and the
36 :     output is to the standard output.
37 : parrello 1.1
38 :     =head2 Command-Line Options
39 :    
40 : parrello 1.6 =over 4
41 :    
42 : overbeek 1.3 =item -c Column
43 : parrello 1.1
44 : overbeek 1.3 This is used only if the column containing PEGs is not the last.
45 : parrello 1.1
46 : parrello 1.6 =back
47 :    
48 : overbeek 1.3 =head2 Output Format
49 : parrello 1.1
50 : overbeek 1.3 The standard output is a tab-delimited file. It consists of the input
51 :     file with an extra column added (the function associated with the PEG).
52 : parrello 1.1
53 : overbeek 1.3 =cut
54 : parrello 1.1
55 : overbeek 1.3 use SeedUtils;
56 :     use SAPserver;
57 :     my $sapObject = SAPserver->new();
58 : overbeek 1.7 use Getopt::Long;
59 : parrello 1.1
60 : overbeek 1.3 my $usage = "usage: svr_function_of [-c column]";
61 : parrello 1.1
62 : overbeek 1.3 my $column;
63 : overbeek 1.7 my $rc = GetOptions('c=i' => \$column);
64 :     if (! $rc) { print STDERR $usage; exit }
65 : parrello 1.1
66 : overbeek 1.3 my @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;
67 :     if (! $column) { $column = @{$lines[0]} }
68 :     my @fids = map { $_->[$column-1] } @lines;
69 :    
70 :     my $functions = $sapObject->ids_to_functions(-ids => \@fids);
71 :     foreach $_ (@lines)
72 :     {
73 : overbeek 1.8 my $func = $functions->{$_->[$column-1]};
74 :     if (! $func) { $func = '' }
75 : overbeek 1.3 print join("\t",@$_,$functions->{$_->[$column-1]}),"\n";
76 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3