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

Diff of /FigKernelScripts/svr_function_of.pl

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

revision 1.3, Sat Nov 7 16:56:45 2009 UTC revision 1.10, Mon Apr 18 00:33:41 2011 UTC
# Line 2  Line 2 
2  use Data::Dumper;  use Data::Dumper;
3  use Carp;  use Carp;
4    
5    #
6    # This is a SAS Component
7    #
8    
9    
10  =head1 svr_function_of  =head1 svr_function_of
11    
12  Get functions of protein-encoding genes  Get functions of protein-encoding genes
13    
14  ------  ------
15  Example: svr_all_features 3702.1 peg | svr_function_of  
16    Example:
17    
18        svr_all_features 3702.1 peg | svr_function_of
19    
20  would produce a 2-column table.  The first column would contain  would produce a 2-column table.  The first column would contain
21  PEG IDs for genes occurring in genome 3702.1, and the second  PEG IDs for genes occurring in genome 3702.1, and the second
22  would contain the functions of those genes.  would contain the functions of those genes.
23    
24  ------  ------
25    
26  The standard input should be a tab-separated table (i.e., each line  The standard input should be a tab-separated table (i.e., each line
# Line 29  Line 37 
37    
38  =head2 Command-Line Options  =head2 Command-Line Options
39    
40    =over 4
41    
42  =item -c Column  =item -c Column
43    
44  This is used only if the column containing PEGs is not the last.  This is used only if the column containing PEGs is not the last.
45    
46    =back
47    
48  =head2 Output Format  =head2 Output Format
49    
50  The standard output is a tab-delimited file. It consists of the input  The standard output is a tab-delimited file. It consists of the input
# Line 43  Line 55 
55  use SeedUtils;  use SeedUtils;
56  use SAPserver;  use SAPserver;
57  my $sapObject = SAPserver->new();  my $sapObject = SAPserver->new();
58    use Getopt::Long;
59    
60  my $usage = "usage: svr_function_of [-c column]";  my $usage = "usage: svr_function_of [-c column]";
61    
62  my $column;  my $column;
63  while ($ARGV[0] && ($ARGV[0] =~ /^-/))  my $rc  = GetOptions('c=i' => \$column);
64  {  if (! $rc) { print STDERR $usage; exit }
     $_ = shift @ARGV;  
     if    ($_ =~ s/^-c//) { $column       = ($_ || shift @ARGV) }  
     else                  { die "Bad Flag: $_" }  
 }  
65    
66  my @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;  my @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;
67    (@lines > 0) || exit;
68  if (! $column)  { $column = @{$lines[0]} }  if (! $column)  { $column = @{$lines[0]} }
69  my @fids = map { $_->[$column-1] } @lines;  my @fids = map { $_->[$column-1] } @lines;
70    
71  my $functions = $sapObject->ids_to_functions(-ids => \@fids);  my $functions = $sapObject->ids_to_functions(-ids => \@fids);
72  foreach $_ (@lines)  foreach $_ (@lines)
73  {  {
74      print join("\t",@$_,$functions->{$_->[$column-1]}),"\n";      my $func = $functions->{$_->[$column-1]};
75        if (! $func) { $func = '' }
76        print join("\t",(@$_,$func)),"\n";
77  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3