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

Annotation of /FigKernelScripts/svr_contigs_in_genome.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3