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

Annotation of /FigKernelScripts/svr_fids_to_locations.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1 ########################################################################
2 :     use strict;
3 :     use Data::Dumper;
4 :     use Carp;
5 :    
6 :     #
7 :     # This is a SAS Component
8 :     #
9 :    
10 :    
11 :     =head1 svr_fids_to_locations < FIDs > with.locs
12 :    
13 :     Clusters from protein-encoding genes
14 :    
15 :     ------
16 :    
17 :     Example:
18 :    
19 :     svr_all_features 3702.1 fid | svr_fids_to_locations
20 :     svr_all_features 3702.1 fid | svr_fids_to_locations -b
21 :    
22 :     would produce a 3-column table. The first column would contain
23 :     FID IDs and the second the FID locations.
24 :     The file would be sorted on the locations.
25 :     The second version would coallapse multi-region locations into
26 :     lust the boundaries.
27 :     ------
28 :    
29 :     The standard input should be a tab-separated table (i.e., each line
30 :     is a tab-separated set of fields). Normally, the last field in each
31 :     line would contain the FID for which clusters are being requested.
32 :     If some other column contains the FIDs, use
33 :    
34 :     -c N
35 :    
36 :     where N is the column (from 1) that contains the FID in each case.
37 :    
38 :     This is a pipe command. The input is taken from the standard input, and the
39 :     output is to the standard output.
40 :    
41 :     =head2 Command-Line Options
42 :    
43 :     =over 4
44 :    
45 :     =item -c Column
46 :    
47 :     This is used only if the column containing FIDs is not the last.
48 :    
49 :     =item -b [return just boundaries]
50 :    
51 :     =back
52 :    
53 :     =head2 Output Format
54 :    
55 :     The standard output is a tab-delimited file. It consists of the input
56 :     file with an extra column added (the locations of fids)
57 :    
58 :     =cut
59 :    
60 :     use SeedUtils;
61 :     use SAPserver;
62 :     use Getopt::Long;
63 :     use ScriptThing;
64 :    
65 :     my $usage = "usage: fids_to_locations [-c column] [-b]\n";
66 :    
67 :     my $column;
68 :     my $boundaries = 0;
69 :     my $i = "-";
70 :     my $url = '';
71 :    
72 :     my $rc = GetOptions('c=i' => \$column,
73 :     'b' => \$boundaries,
74 :     'url=s' => \$url,
75 :     'i=s' => \$i);
76 :     if (! $rc) { print STDERR $usage; exit }
77 :     my $sapObject = SAPserver->new(url => $url);
78 :     open my $ih, "<$i";
79 :     while (my @tuples = ScriptThing::GetBatch($ih, undef, $column))
80 :     {
81 :     my @ids = map { $_->[0] } @tuples;
82 :     my $b = $boundaries ? "1" : "0";
83 :     my $locations = $sapObject->fid_locations(-ids => \@ids, -boundaries => $boundaries);
84 :     for my $tuple (@tuples)
85 :     {
86 :     my ($id, $line) = @$tuple;
87 :     my $location = $locations->{$id};
88 :     if (! defined $location) {
89 :     # print STDERR "$id not found.\n";
90 :     }
91 :     else
92 :     {
93 :     if (! $b)
94 :     {
95 :     $location = join(",",@$location);
96 :     }
97 :     print "$line\t$location\n";
98 :     }
99 :     }
100 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3