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

Annotation of /FigKernelScripts/svr_is_hypo.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1 use strict;
2 :     use Data::Dumper;
3 :     use Carp;
4 :    
5 :     #
6 :     # This is a SAS Component
7 :     #
8 :    
9 :    
10 :     =head1 svr_is_hypo [-c N] [-v]
11 :    
12 :     Keep just hypotheticals
13 :    
14 :     ------
15 :    
16 :     Example:
17 :    
18 :     svr_all_features 3702.1 peg | svr_is_hypo
19 :    
20 :     would produce a 1-column table containing the hypotheticals in 3702.1
21 :    
22 : overbeek 1.3 Normally, a stream of feature IDs (PEGs) is used as input. If the things you send
23 :     through do not look like PEGs, then they are treated as functional roles.
24 :    
25 : overbeek 1.1 ------
26 :    
27 :     The standard input should be a tab-separated table (i.e., each line
28 :     is a tab-separated set of fields). Normally, the last field in each
29 :     line would contain the PEG . If some other column contains the PEGs, use
30 :    
31 :     -c N
32 :    
33 :     where N is the column (from 1) that contains the PEG in each case.
34 :    
35 :     This is a pipe command. The input is taken from the standard input, and the
36 :     output is to the standard output.
37 :    
38 :     =head2 Command-Line Options
39 :    
40 :     =over 4
41 :    
42 :     =item -c Column
43 :    
44 :     This is used only if the column containing PEGs is not the last.
45 :    
46 : parrello 1.2 =item -v [keep only non-hypotheticals]
47 : overbeek 1.1
48 :     =back
49 :    
50 :     =head2 Output Format
51 :    
52 :     This is a filter producing a subset of the input lines.
53 :    
54 :     =cut
55 :    
56 :     use SeedUtils;
57 :     use SAPserver;
58 :     my $sapObject = SAPserver->new();
59 :     use Getopt::Long;
60 :    
61 :     my $usage = "usage: svr_is_hypo [-c column] [-v]";
62 :    
63 :     my $column;
64 :     my $v;
65 :     my $rc = GetOptions('c=i' => \$column,
66 :     'v' => \$v);
67 :     if (! $rc) { print STDERR $usage; exit }
68 :    
69 :     my @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;
70 :     (@lines > 0) || exit;
71 :     if (! $column) { $column = @{$lines[0]} }
72 : overbeek 1.3 my @fids = grep { $_ =~ /^fig\|/ } map { $_->[$column-1] } @lines;
73 : overbeek 1.1
74 :     my $functions = $sapObject->ids_to_functions(-ids => \@fids);
75 :     foreach $_ (@lines)
76 :     {
77 : overbeek 1.3 my $thing = $_->[$column-1];
78 :     my $func;
79 :     if ($thing =~ /^fig\|/)
80 :     {
81 :     $func = $functions->{$thing};
82 :     }
83 :     else
84 :     {
85 :     $func = $thing;
86 :     }
87 : overbeek 1.1 my $hypo = &SeedUtils::hypo($func);
88 :     if (((! $v) && $hypo) || ($v && (! $hypo)))
89 :     {
90 :     print join("\t",@$_),"\n";
91 :     }
92 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3