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

View of /FigKernelScripts/accumulate_pegs_to_scenario_paths.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Feb 10 22:09:04 2011 UTC (8 years, 9 months ago) by dejongh
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, mgrast_release_3_0, mgrast_dev_03252011, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
determine which pegs in an organism are involved in which scenario paths

use strict;
use FIG;

unless (scalar @ARGV == 1)
{
    print "usage:  accumulate_pegs_to_scenario_paths <genome_id>\n";
    exit(-1);
}

my ($genome_id) = @ARGV;

open(HS, "<$FIG_Config::global/Models/hope_supersets.txt") 
    or die("Couldn't open hope_supersets.txt");

my $fig = new FIG;
my $model_dir = $fig->scenario_directory("All");

while (<HS>)
{
    chomp;
    my ($superset, $ss_name) = split "\t";
    
    $superset =~ s/\s+$//g;
    $superset =~ s/\s+/_/g;
    $ss_name  =~ s/\s+$//g;
    my $inner_ss_name = $ss_name;
    $inner_ss_name  =~ s/\(/\\\(/g;
    $inner_ss_name  =~ s/\)/\\\)/g;

    my $ss = $fig->get_subsystem($ss_name);

    if (! defined $ss) {
	print STDERR "$ss_name does not exist, skipping\n";
	next;
    }
    else {
	print STDERR "Processing $ss_name\n";
    }

    my %roles = map { $_ => 1 } $ss->get_roles;

    my %reactions = $ss->get_hope_reactions;

    foreach my $role (keys %reactions)
    {
	if (! exists $roles{$role}) {
	    print STDERR "In $ss_name, missing role: $role\n";
	    next;
	}

	my @pegs = $fig->seqs_with_role($role, "", $genome_id);

	if (scalar @pegs > 0)
	{
	    my %scenarios;

	    foreach my $reaction (@{$reactions{$role}})
	    {
		my @stuff = `find -L $model_dir/PathInfo/$superset/$inner_ss_name -name path_info -exec grep -l $reaction {} \\\;`;

		foreach my $path (@stuff)
		{
		    my @path_guts = split "/", $path;
		    $scenarios{$path_guts[-3]}->{$path_guts[-2]}->{$reaction} = 1;
		}
	    }

	    foreach my $peg (@pegs)
	    {
		foreach my $scenario (keys %scenarios)
		{
		    foreach my $path (keys %{$scenarios{$scenario}})
		    {
			foreach my $reaction (keys %{$scenarios{$scenario}->{$path}})
			{
			    print $peg, "\t", $reaction, "\t", $role, "\t", $path, "\t", $scenario, "\t", $ss_name, "\t", $superset, "\n";
			}
		    }
		}
	    }

	}
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3