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

View of /FigKernelScripts/find_model_cofactors.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (download) (as text) (annotate)
Wed Nov 12 18:29:31 2008 UTC (11 years ago) by dejongh
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2009_02_05, rast_rel_2011_0119, 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, rast_rel_2009_07_09, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, HEAD
Changes since 1.6: +1 -1 lines
switch to scenario_directory

## _*_ Perl _*_
#

use FIGV;
use Scenario;
use strict;

my ($genome_id,$orgdir) = @ARGV;

my $debug = 0;

unless (scalar (@ARGV) >= 1)
{
    print STDERR "\nusage:  find_model_cofactors <genome_id>\n"; 
    exit(-1);
}
chomp $genome_id;
my $fig;
if($orgdir)
{
    $fig = new FIGV($orgdir);
}
else
{
    $fig = new FIGV;
}

Scenario::set_fig($fig,$genome_id);
my $filebase = $fig->scenario_directory($genome_id)."/Analysis/";
my $source = $FIG_Config::global."/Models/cofactors_lib.txt";
my $to = $filebase."secondary_compounds.txt";
print STDERR "source: $source\n";
print STDERR "to: $to\n";

`cp $source $to`;
exit;

my @scenarios = @{Scenario->get_genome_scenarios($genome_id,0)};


my %input_cpds;
open(INPUTS,$filebase."inputs.txt")
    or die ("Failed to open ".$filebase."inputs.txt. Run find_scenario_information $genome_id inputs");
while(<INPUTS>)
{
    chomp;
    my @line = split "\t", $_;
    chomp @line;
    $input_cpds{$line[0]} = 1;
}
close(INPUTS);

my %biomass_cpds;
open(BIOMASS,$filebase."biomass.txt")
    or die("Failed to open ".$filebase."biomass.txt");
while(<BIOMASS>)
{
    chomp;
    my @line = split "\t", $_;
    chomp @line;
    $biomass_cpds{$line[0]} = 1;
}
close(BIOMASS);

my %cofactor_lib;
open(CO,"$FIG_Config::global/Models/cofactors_lib.txt")
    or die("Failed to open $FIG_Config::global/Models/cofactors_lib.txt ");
while(<CO>)
{
    chomp;
    $cofactor_lib{$_} = 1;
}
close(CO);

my %new_cofactors;
#We want to determine possible cofactors that we could need
#
# 1. Look at what scenarios we can run on our 'main' inputs
#    and add the required cofactors. 

foreach my $scenario (@scenarios)
{
    my $count = 0;
    foreach my $substrate (@{$scenario->get_substrates()})
    {
	if($input_cpds{$substrate})
	{
	    $count++;
	}
    }
    if($count != scalar(@{$scenario->get_substrates()}))
    {
	foreach (@{$scenario->get_substrate_cofactors()})
	{
# Commented out. this breaks ecoli. but I don't think we should uptake cpds
#  that are also in our biomass! These should be main cpds. NOT cofactors.
#	    if($biomass_cpds{$_})
#	    {
#		next;
#	    }
	    if(!$cofactor_lib{$_})
	    {
		next;
	    }	   
	    print STDERR "Adding cofactor $_\n" if($debug);
	    if(!defined $new_cofactors{$_})
	    {
		$new_cofactors{$_} = 1;
	    }
	    else
	    {
		$new_cofactors{$_}++;
	    }
	}
    }
}
open (OUT,">".$filebase."secondary_compounds.txt");
map {print OUT "$_\t$new_cofactors{$_}\n"} sort keys %new_cofactors; 
close(OUT);



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3