[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.5 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     use SSserver;
4 :     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 :     =back
41 : parrello 1.1
42 : parrello 1.4 =cut
43 : parrello 1.1
44 :     my $noroles = 0;
45 :     my $group = 0;
46 :     my $show_owner = 0;
47 :     my $oldid = "";
48 :    
49 :     $0 =~ m/([^\/]+)$/;
50 :     my $self = $1;
51 : parrello 1.3 my $usage = "$self [--noroles --group] GenomeF < SubsystemIDs";
52 : parrello 1.1
53 :     my $rc = GetOptions("noroles" => \$noroles, "group" => \$group);
54 :    
55 :     if (!$rc) {
56 :     die "\n usage: $usage\n\n";
57 :     }
58 :    
59 :     my $roles = $noroles ? 0 : 1;
60 :     my $ss = SSserver->new();
61 :    
62 :     open GENOMES, "<" . $ARGV[$#ARGV] || die "Genome file error: $!";
63 :    
64 :     my @genomes;
65 :     my @subs;
66 :     while (<GENOMES>) {
67 : parrello 1.4 chomp;
68 :     push (@genomes, $_);
69 : parrello 1.1 }
70 :     while (<STDIN>) {
71 : parrello 1.4 chomp;
72 :     push (@subs, $_);
73 : parrello 1.1 }
74 :    
75 : parrello 1.4 my $pegs_inss = $ss->pegs_in_subsystems(\@genomes, \@subs);
76 : parrello 1.1 if ($roles) {
77 : parrello 1.4 foreach my $ss_role (@{$pegs_inss}) { #foreach subsystem/role
78 :     #(ss, role, (peg))
79 :     if ($group) {
80 :     print $ss_role->[0], "\t", $ss_role->[1]->[0], "\t", join (",", @{$ss_role->[1]->[1]}), "\n";
81 :     } else {
82 :     foreach my $peg (@{$ss_role->[1]->[1]}) { #foreach peg in this peg list
83 :     print join("\t", ($ss_role->[0], $ss_role->[1]->[0], $peg)), "\n";
84 :     }
85 : disz 1.2 }
86 : parrello 1.4 }
87 : parrello 1.1
88 : disz 1.2 } else { # no roles
89 : parrello 1.4 my %ss_pegs;
90 :     foreach my $ss_role (@{$pegs_inss}) {
91 :     foreach my $peg (@{$ss_role->[1]->[1]}) {
92 :     $ss_pegs{$ss_role->[0]}{$peg} = 1;
93 : disz 1.2 }
94 : parrello 1.4 }
95 :     for my $ss (keys %ss_pegs) {
96 :     if ($group) {
97 :     print $ss, "\t", join(",", keys %{$ss_pegs{$ss}}), "\n";
98 :     } else {
99 :     foreach my $peg (keys %{$ss_pegs{$ss}}) {
100 :     print join("\t", $ss, $peg), "\n";
101 :     }
102 : disz 1.2 }
103 : parrello 1.4 }
104 : disz 1.2 }
105 : parrello 1.1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3