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

Diff of /FigKernelScripts/svr_subsystem_roles.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed Aug 11 20:36:18 2010 UTC revision 1.2, Thu Apr 7 21:49:14 2011 UTC
# Line 13  Line 13 
13    
14      svr_subsystem_roles "subsystem ID" >sub_data.tbl      svr_subsystem_roles "subsystem ID" >sub_data.tbl
15    
16    
17  Output the roles of a subsystem.  Output the roles of a subsystem.
18    
19  This script takes as input a subsystem name on the command line and produces a  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  tab-delimited file of all the roles in the subsystem (in order) and their
21  abbreviations. Each line of the file will contain the abbreviation first and then  abbreviations. Each line of the file will contain the subsystem name, abbreviation and
22  the full role name. The output will be produced on the standard output.  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  Note that because the subsystem name likely contains spaces, it will need to be
25  enclosed in quotes on the command-line.  enclosed in quotes on the command-line.
26    
27    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  =head2 Command-Line Options  =head2 Command-Line Options
31    
32  =over 4  =over 4
# Line 43  Line 47 
47  # Parse the command-line options.  # Parse the command-line options.
48  my $url = '';  my $url = '';
49  my $aux;  my $aux;
50  my $opted =  GetOptions('url=s' => \$url, aux => \$aux);  my $column;
51    my $opted =  GetOptions('url=s' => \$url,
52                            'c=i' => \$column,
53                            aux => \$aux);
54  my $subID = $ARGV[0];  my $subID = $ARGV[0];
55  if (! $opted || ! $subID) {  if (! $opted)
56    {
57      print "usage: svr_subsystem_roles [--url=http://...] [--aux] \"subsystem name\" >output\n";      print "usage: svr_subsystem_roles [--url=http://...] [--aux] \"subsystem name\" >output\n";
58  } else {  } else {
59      # Get the server object.      # Get the server object.
60      my $sapServer = SAPserver->new(url => $url);      my $sapServer = SAPserver->new(url => $url);
61      # Get the roles.      my @lines;
62      my $subHash = $sapServer->subsystem_roles(-ids => $subID, -aux => $aux, -abbr => 1);      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.      # Loop through them, producing output.
77      my $roles = $subHash->{$subID};      my $roles = $subHash->{$subID};
78      if (! $roles) {      if (! $roles) {
# Line 59  Line 80 
80      } else {      } else {
81          for my $role (@$roles) {          for my $role (@$roles) {
82              my ($roleID, $abbr) = @$role;              my ($roleID, $abbr) = @$role;
83              print "$abbr\t$roleID\n";                  print "$subID\t$abbr\t$roleID\n";
84                }
85          }          }
86      }      }
87  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3