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

View of /FigKernelScripts/svr_pegs_in_subsystems.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri Jul 17 19:45:18 2009 UTC (10 years, 5 months ago) by disz
Branch: MAIN
CVS Tags: rast_rel_2009_0925
Changes since 1.1: +28 -22 lines
fixed up noroles with group, noroles w/o group

#!/usr/bin/perl -w 

use LWP;
use Data::Dumper;
use SSserver;
use Getopt::Long;


# This is a SAS Component


my $noroles = 0;
my $group = 0;
my $show_owner = 0;
my $oldid = "";

$0 =~ m/([^\/]+)$/;
my $self = $1;
my $usage = "$self [--noroles --group GenomeF < SubsystemIDs]";

my $rc = GetOptions("noroles" => \$noroles, "group" => \$group);

if (!$rc) {
    die "\n   usage: $usage\n\n";
}


my $roles = $noroles ? 0 : 1;
my $ss = SSserver->new();

open GENOMES, "<" . $ARGV[$#ARGV] || die "Genome file error: $!";

my @genomes;
my @subs;
while (<GENOMES>) {
	chomp;
	push (@genomes, $_);
}
while (<STDIN>) {
	chomp;
	push (@subs, $_);
}

my $pegs_inss = $ss->pegs_in_subsystems(\@genomes, \@subs);
if ($roles) {
        foreach my $ss_role (@{$pegs_inss}) { #foreach subsystem/role
                #(ss, role, (peg))
                if ($group) {
                        print $ss_role->[0], "\t", $ss_role->[1]->[0], "\t", join (",", @{$ss_role->[1]->[1]}), "\n";
                } else {
                        foreach my $peg (@{$ss_role->[1]->[1]}) { #foreach peg in this peg list
                                print join("\t", ($ss_role->[0], $ss_role->[1]->[0], $peg)), "\n";
                        }
                }
        }

} else { # no roles
        my %ss_pegs;
        foreach my $ss_role (@{$pegs_inss}) {
                foreach my $peg (@{$ss_role->[1]->[1]}) {
                        $ss_pegs{$ss_role->[0]}{$peg} = 1;
                }
        }
        for my $ss (keys %ss_pegs) {
                if ($group) {
                        print $ss, "\t", join(",", keys %{$ss_pegs{$ss}}), "\n";
                } else {
                        foreach my $peg (keys %{$ss_pegs{$ss}}) {
                                print join("\t", $ss, $peg), "\n";
                        }
                }
        }
}

exit;


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3