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

Annotation of /FigKernelScripts/svr_fc_figfams.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1 #!/usr/bin/perl -w
2 :     use strict;
3 :     use Data::Dumper;
4 :    
5 :     use Getopt::Long;
6 :     use SAPserver;
7 :     use ScriptThing;
8 :     use SeedUtils;
9 :    
10 :     #
11 :     # This is a SAS Component.
12 :     #
13 :    
14 :     =head1 svr_fc_figfams
15 :    
16 : overbeek 1.2 svr_fc_figfams [-MinSc=n] < table_with_ff_column.tbl > extended_with_scores_and_ffs.tbl
17 : overbeek 1.1
18 : overbeek 1.2 Output the functionally coupled FIGfams By specifying a MinSc, you restrict the
19 :     output to functionally-coupled FIGfams that co-occur in at least n OTUs.
20 : overbeek 1.1
21 :     This script takes as input a tab-delimited file with FIGfam IDs at the end of
22 :     each line. For each FIGfam ID, the coupling score and FIGfam ID of
23 :     a functionally coupled FIGfam will be appended to the list.
24 :    
25 :     This is a pipe command: the input is taken from the standard input and the
26 :     output is to the standard output. Alternatively, a list of FIGfam IDs can be
27 :     specified as command-line parameters.
28 :    
29 :     =head2 Command-Line Options
30 :    
31 :     =over 4
32 :    
33 :     =item url
34 :    
35 :     The URL for the Sapling server, if it is to be different from the default.
36 :    
37 :     =item c
38 :    
39 :     Column index. If specified, indicates that the input IDs should be taken from the
40 :     indicated column instead of the last column. The first column is column 1.
41 :    
42 :     =back
43 :    
44 :     =cut
45 :    
46 :     # Parse the command-line options.
47 :     my $url = '';
48 :     my $column = 0;
49 :     my $all = 0;
50 : overbeek 1.2 my $MinSc = 0;
51 :     my $opted = GetOptions('url=s' => \$url, 'c=i' => \$column, 'MinSc=i' => \$MinSc );
52 : overbeek 1.1 if (! $opted) {
53 : overbeek 1.2 print "usage: svr_fc_figfams [--url=http://...] [--c=N] [MinSc=n] <input >output\n";
54 : overbeek 1.1 } else {
55 :     # Get the server object.
56 :     my $sapServer = SAPserver->new(url => $url);
57 :     # Here the user wants selected FIGfams. Find out if we're getting input
58 :     # from STDIN or the command line.
59 :     my $input = (@ARGV ? [@ARGV] : \*STDIN);
60 :     # The main loop processes chunks of input.
61 :     while (my @tuples = ScriptThing::GetBatch($input, undef, $column)) {
62 :     # Ask the server for results.
63 :     my $coupledH = $sapServer->related_figfams(-ids => [map { $_->[0] } @tuples]);
64 :     # Loop through the IDs, producing output.
65 :     for my $tuple (@tuples) {
66 :     my ($id, $line) = @$tuple;
67 :     # Get related FIGfams
68 :     if (my $relatedL = $coupledH->{$id})
69 :     {
70 : overbeek 1.3 foreach my $pair (sort { $b->[1]->[0] <=> $a->[1]->[0] } @$relatedL)
71 : overbeek 1.1 {
72 :     my $figfam2 = $pair->[0];
73 :     my $score = $pair->[1]->[0];
74 : overbeek 1.2 if ($score >= $MinSc)
75 :     {
76 :     print "$line\t$score\t$figfam2\n";
77 :     }
78 : overbeek 1.1 }
79 :     }
80 :     }
81 :     }
82 :     }
83 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3