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

Annotation of /FigKernelScripts/svr_pegs_in_subsystems.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 : parrello 1.6 use SAPserver;
4 : parrello 1.1 use Getopt::Long;
5 :    
6 : parrello 1.4 # This is a SAS Component
7 :    
8 :     =head1 svr_pegs_in_subsystems
9 :    
10 : parrello 1.5 svr_pegs_in_subsystems genome_ids.tbl <subsystem_ids.tbl >peg_role_data.tbl
11 :    
12 : parrello 1.4 Return all genes in one or more subsystems found in one or more genomes.
13 :    
14 :     This script takes a list of genomes and a list of subsystems and returns a list
15 :     of the genes represented in each genome/subsystem pair. It takes one positional
16 :     parameter-- the name of the file containing the genome IDs, and reads the list
17 :     of subsystem IDs from the standard input.
18 :    
19 :     The standard output will be a tab-delimited file, each record containing a
20 :     subsystem ID, a functional role in that subsystem, and the ID of a gene with
21 :     that role from one of the supplied genomes.
22 :    
23 :     This is a pipe command. The input is from the standard input and the output is
24 :     to the standard output.
25 :    
26 :     The following command-line options are supported.
27 :    
28 :     =over 4
29 : parrello 1.1
30 : parrello 1.4 =item group
31 :    
32 :     If specified, then each output line will be for a single role, and the gene IDs will
33 :     be listed as a single comma-delimited string.
34 :    
35 :     =item noroles
36 :    
37 :     If specified, then the second column in each output line (functional role) will be
38 :     omitted from the output.
39 :    
40 : parrello 1.6 =item url
41 :    
42 :     The URL for the Sapling server, if it is to be different from the default.
43 :    
44 : parrello 1.4 =back
45 : parrello 1.1
46 : parrello 1.4 =cut
47 : parrello 1.1
48 :     my $noroles = 0;
49 :     my $group = 0;
50 :     my $show_owner = 0;
51 :     my $oldid = "";
52 : parrello 1.6 my $url = "";
53 : parrello 1.1
54 :     $0 =~ m/([^\/]+)$/;
55 :     my $self = $1;
56 : parrello 1.6 my $usage = "$self [--noroles --group --url=http://...] GenomeF < SubsystemIDs";
57 : parrello 1.1
58 : parrello 1.6 my $rc = GetOptions("noroles" => \$noroles, "group" => \$group, "url=s" => \$url);
59 : parrello 1.1
60 :     if (!$rc) {
61 :     die "\n usage: $usage\n\n";
62 :     }
63 :    
64 :     my $roles = $noroles ? 0 : 1;
65 : parrello 1.6 my $ss = SAPserver->new(url => $url);
66 : parrello 1.1
67 :     open GENOMES, "<" . $ARGV[$#ARGV] || die "Genome file error: $!";
68 :    
69 :     my @genomes;
70 :     my @subs;
71 :     while (<GENOMES>) {
72 : parrello 1.4 chomp;
73 :     push (@genomes, $_);
74 : parrello 1.1 }
75 :     while (<STDIN>) {
76 : parrello 1.4 chomp;
77 :     push (@subs, $_);
78 : parrello 1.1 }
79 :    
80 : parrello 1.4 my $pegs_inss = $ss->pegs_in_subsystems(\@genomes, \@subs);
81 : parrello 1.1 if ($roles) {
82 : parrello 1.4 foreach my $ss_role (@{$pegs_inss}) { #foreach subsystem/role
83 :     #(ss, role, (peg))
84 :     if ($group) {
85 :     print $ss_role->[0], "\t", $ss_role->[1]->[0], "\t", join (",", @{$ss_role->[1]->[1]}), "\n";
86 :     } else {
87 :     foreach my $peg (@{$ss_role->[1]->[1]}) { #foreach peg in this peg list
88 :     print join("\t", ($ss_role->[0], $ss_role->[1]->[0], $peg)), "\n";
89 :     }
90 : disz 1.2 }
91 : parrello 1.4 }
92 : parrello 1.1
93 : disz 1.2 } else { # no roles
94 : parrello 1.4 my %ss_pegs;
95 :     foreach my $ss_role (@{$pegs_inss}) {
96 :     foreach my $peg (@{$ss_role->[1]->[1]}) {
97 :     $ss_pegs{$ss_role->[0]}{$peg} = 1;
98 : disz 1.2 }
99 : parrello 1.4 }
100 :     for my $ss (keys %ss_pegs) {
101 :     if ($group) {
102 :     print $ss, "\t", join(",", keys %{$ss_pegs{$ss}}), "\n";
103 :     } else {
104 :     foreach my $peg (keys %{$ss_pegs{$ss}}) {
105 :     print join("\t", $ss, $peg), "\n";
106 :     }
107 : disz 1.2 }
108 : parrello 1.4 }
109 : disz 1.2 }
110 : parrello 1.1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3