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

Annotation of /FigKernelScripts/svr_subsystem_roles.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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_subsystem_roles
13 :    
14 :     svr_subsystem_roles "subsystem ID" >sub_data.tbl
15 :    
16 : overbeek 1.2
17 : parrello 1.1 Output the roles of a subsystem.
18 :    
19 :     This script takes as input a subsystem name on the command line and produces a
20 :     tab-delimited file of all the roles in the subsystem (in order) and their
21 : overbeek 1.2 abbreviations. Each line of the file will contain the subsystem name, abbreviation and
22 : parrello 1.1 the full role name. The output will be produced on the standard output.
23 :    
24 :     Note that because the subsystem name likely contains spaces, it will need to be
25 :     enclosed in quotes on the command-line.
26 :    
27 : overbeek 1.2 If you want to see the data for a set of subsystems, you can read a file of genome IDs.
28 :     The script will then write out the roles for all subsystems in the file.
29 :    
30 : parrello 1.1 =head2 Command-Line Options
31 :    
32 :     =over 4
33 :    
34 :     =item url
35 :    
36 :     The URL for the Sapling server, if it is to be different from the default.
37 :    
38 :     =item aux
39 :    
40 :     If specified, auxiliary roles will be included in the output. Normally these are
41 :     excluded.
42 :    
43 :     =back
44 :    
45 :     =cut
46 :    
47 :     # Parse the command-line options.
48 :     my $url = '';
49 :     my $aux;
50 : overbeek 1.2 my $column;
51 :     my $opted = GetOptions('url=s' => \$url,
52 :     'c=i' => \$column,
53 :     aux => \$aux);
54 : parrello 1.1 my $subID = $ARGV[0];
55 : overbeek 1.2 if (! $opted)
56 :     {
57 : parrello 1.1 print "usage: svr_subsystem_roles [--url=http://...] [--aux] \"subsystem name\" >output\n";
58 :     } else {
59 :     # Get the server object.
60 :     my $sapServer = SAPserver->new(url => $url);
61 : overbeek 1.2 my @lines;
62 :     if ($ARGV[0])
63 :     {
64 :     @lines = ([$ARGV[0]]);
65 :     }
66 :     else
67 :     {
68 :     @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;
69 :     }
70 :     (@lines > 0) || exit;
71 :     if (! $column) { $column = @{$lines[0]} }
72 :     my @ss = map { $_->[$column-1] } @lines;
73 :     my $subHash = $sapServer->subsystem_roles(-ids => \@ss, -aux => $aux, -abbr => 1);
74 :     foreach my $subID (@ss)
75 :     {
76 :     # Loop through them, producing output.
77 :     my $roles = $subHash->{$subID};
78 :     if (! $roles) {
79 :     print STDERR "Could not find \"$subID\".\n";
80 :     } else {
81 :     for my $role (@$roles) {
82 :     my ($roleID, $abbr) = @$role;
83 :     print "$subID\t$abbr\t$roleID\n";
84 :     }
85 : parrello 1.1 }
86 :     }
87 :     }
88 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3