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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3