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

View of /FigKernelScripts/find_missing_lib_inputs_v2.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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, HEAD
Changes since 1.1: +1 -1 lines
switch to scenario_directory

## _*_ Perl _*_
#

use FIGV;
use Scenario;
use strict;

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

my $debug = 0;

unless (scalar( @ARGV) >= 2)
{
    print STDERR "\nusage:  find_missing_lib_inputs <genome_id> [0/1]\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 @scenarios = @{Scenario->get_genome_scenarios($genome_id,0)};
my $filebase = "$FIG_Config::global/Models/";

my %compound_id_to_name;
open(IN,"$FIG_Config::global/Models/compound_id_to_name.txt") or die("Failed to open compound_id_to_name.txt");
while($_ = <IN>){
    chomp($_);
    my($id,$name) = split("\t",$_);
    $compound_id_to_name{$id} = $name;
}
close(IN);

my %inputs;
my %outputs;
foreach my $scenario (@scenarios)
{
    map {$inputs{$_} = 1} @{$scenario->get_substrates_all()};
    map {$outputs{$_} = 1} @{$scenario->get_products_all()};
    #Uncomment this line of code if you want to see what scenario a cpd is being referenced from
    # Make sure you comment the previous line out if you do this
    #map {$outputs{$_} = $scenario->get_id()} @{$scenario->get_products_all()};
}

# Filter out compounts that occur in both the inputs and outputs/biomass
#   these are likely intermediates that are both produced and consumed
if($type)
{
    foreach my $input (keys %inputs)
    {
	if(defined $outputs{$input})
	{
	    delete $inputs{$input};
	    delete $outputs{$input};
	}
    }
}

open(RES_LIB, $filebase."standard_medium_lib.txt");
while(<RES_LIB>)
{
    chomp;
    my @temp = split "\t" , $_;
    if(defined $inputs{$temp[0]} && $temp[0] ne "")
    {
	delete $inputs{$temp[0]};
    }
}
close(RES_LIB);
my $location = $fig->scenario_directory($genome_id)."/Analysis/";
#Make the Analysis directory if it doesn't exist
mkdir($location);
open(OUTPUT,">",$location."scenario_inputs_not_transported_or_produced.txt");
print OUTPUT map { $_."\t$compound_id_to_name{$_}\n" } sort keys %inputs;
close(OUTPUT);


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3