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

Annotation of /FigKernelScripts/svr_close_genomes.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 use strict;
2 :    
3 :     use Getopt::Long;
4 :     use SeedEnv;
5 :    
6 :     #
7 :     # This is a SAS Component
8 :     #
9 :    
10 :    
11 :     =head1 svr_close_genomes
12 :    
13 :     List the IDs of the genomes that are functionally close to the input genomes.
14 :    
15 :     svr_close_genomes < genomes.tbl > close_genomes.tbl
16 :    
17 :     This script takes as input a tab-delimited file with genome IDs at the end of each
18 :     line. For each genome ID, multiple output lines are produced containing the ID and
19 :     score of each functionally close genome found.
20 :    
21 :     This is a pipe command: the input is taken from the standard input and the output
22 :     is to the standard output.
23 :    
24 :     =head2 Command-Line Options
25 :    
26 :     =over 4
27 :    
28 :     =item url
29 :    
30 :     The URL for the Sapling server, if it is to be different from the default.
31 :    
32 :     =item c
33 :    
34 :     Column index. If specified, indicates that the input IDs should be taken from the
35 :     indicated column instead of the last column. The first column is column 1.
36 :    
37 :     =back
38 :    
39 :     =cut
40 :    
41 :     # Parse the command-line options.
42 :     my $url = '';
43 :     my $column = '';
44 :     my $opted = GetOptions('url=s' => \$url, 'c=i' => \$column);
45 :     if (! $opted) {
46 :     print "usage: svr_close_genomes [--url=http://...] [--c=N] <input >output\n";
47 :     } else {
48 :     # Get the server object.
49 :     my $sapServer = SAPserver->new(url => $url);
50 :     # The main loop processes chunks of input.
51 :     while (my @tuples = ScriptThing::GetBatch(\*STDIN, 2, $column)) {
52 :     # Ask the server for results.
53 :     my $document = $sapServer->close_genomes(-ids => [map { $_->[0] } @tuples]);
54 :     # Loop through the IDs, producing output.
55 :     for my $tuple (@tuples) {
56 :     my ($id, $line) = @$tuple;
57 :     # Get this genome's data.
58 :     my $genomeData = $document->{$id};
59 :     # Did we get something?
60 :     if (! $genomeData) {
61 :     # No. Write an error notification.
62 :     print STDERR "None found: $id\n";
63 :     } else {
64 :     # Yes. Loop through the genomes found.
65 :     for my $pair (@$genomeData) {
66 :     # Get the genome ID and score.
67 :     my ($genomeID, $score) = @$pair;
68 :     print join("\t", $line, $genomeID, $score) . "\n";
69 :     }
70 :     }
71 :     }
72 :     }
73 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3