[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.11 - (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.11 use ScriptThing;
60 : parrello 1.1
61 : overbeek 1.3 my $usage = "usage: svr_function_of [-c column]";
62 : parrello 1.1
63 : overbeek 1.3 my $column;
64 : parrello 1.11 my $i = "-";
65 :     my $rc = GetOptions('c=i' => \$column, 'i=s' => \$i);
66 : overbeek 1.7 if (! $rc) { print STDERR $usage; exit }
67 : parrello 1.11 open my $ih, "<$i";
68 :     while (my @tuples = ScriptThing::GetBatch($ih, undef, $column)) {
69 :     my @ids = map { $_->[0] } @tuples;
70 :     my $functions = $sapObject->ids_to_functions(-ids => \@ids);
71 :     for my $tuple (@tuples) {
72 :     my ($id, $line) = @$tuple;
73 :     my $function = $functions->{$id};
74 :     if (! defined $function) {
75 :     print STDERR "$id not found.\n";
76 :     } else {
77 :     print "$line\t$function\n";
78 :     }
79 :     }
80 : overbeek 1.3 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3