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

View of /FigKernelScripts/server_paper_example7.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Tue Apr 27 04:05:03 2010 UTC (9 years, 10 months ago) by chenry
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, 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_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.3: +8 -4 lines
Corrected a few bugs in the example script.

#!/usr/bin/perl -w
use strict;
use FBAMODELserver;

# Reads the SEED genome-scale metabolic model of E. coli  
# Runs flux variability analysis, flux balance analysis, and single gene knockout simulations in E. coli
# Prints all results to file

#1.) Creating perl object which interfaces with the SEED server API
my $fbaObject = FBAMODELserver->new();

#2.) Obtain a list of the reaction IDs in the E. coli model
my $reactionList = $fbaObject->get_reaction_id_list({id => "Seed83333.1"});

#3.) Obtain a list of the compound IDs in the E. coli model
my $compoundList = $fbaObject->get_compound_id_list({id => "Seed83333.1"});

#4.) Obtaining detailed data on E. coli reactions
my $reactionData = $fbaObject->get_reaction_data({"id" => $reactionList->{"Seed83333.1"},"model" => ["Seed83333.1"]});

#5.) Obtaining detailed data on E. coli compounds
my $compoundData = $fbaObject->get_compound_data({"id" => $compoundList->{"Seed83333.1"},"model" => ["Seed83333.1"]});

#6.) Running flux variability analysis on E. coli model while simulating growth in LB media
my $fvaOutput = $fbaObject->classify_model_entities({"parameters" => [{id=>"Seed83333.1",media=>"ArgonneLBMedia"}]});
#Placing fva output into a hash to simplify access
my $fvaHash;
for (my $i=0; $i < @{$fvaOutput->[0]->{entities}};$i++) {
	$fvaHash->{substr($fvaOutput->[0]->{entities}->[$i],0,8)} = $fvaOutput->[0]->{classes}->[$i];
}

#7.) Simulating growth of E. coli model in LB media
my $fbaOutput = $fbaObject->simulate_model_growth({"parameters" => [{id=>"Seed83333.1",media=>"Carbon-D-Glucose"}]});
#Placing fba output into a hash to simplify access
my $fbaHash;
for (my $i=0; $i < @{$fbaOutput->[0]->{entities}};$i++) {
	$fbaHash->{$fbaOutput->[0]->{entities}->[$i]} = $fbaOutput->[0]->{fluxes}->[$i];
}

#8.) Simulating single gene knockout in E. coli model during growth in LB media
my $KOOutput = $fbaObject->simulate_all_single_gene_knockout({"parameters" => [{id=>"Seed83333.1",media=>"ArgonneLBMedia"}]});

#9.) Printing all compound data to output file CompoundTbl.txt
my $columns = ["DATABASE","NAME","FORMULA","CHARGE","FVA class","FBA uptake flux"];
open (OUTPUT, ">CompoundTbl.txt");
print OUTPUT join("\t",@{$columns})."\n";
for (my $i=0; $i < @{$compoundList->{"Seed83333.1"}}; $i++) {
	for (my $j=0; $j < @{$columns}; $j++) {
		if ($j > 0) {
			print OUTPUT "\t";
		}
		if ($columns->[$j] eq "FVA class") {
			if (defined($fvaHash->{$compoundList->{"Seed83333.1"}->[$i]})) {
				print OUTPUT $fvaHash->{$compoundList->{"Seed83333.1"}->[$i]};
			}
		} elsif ($columns->[$j] eq "FBA uptake flux") {
			if (defined($fbaHash->{$compoundList->{"Seed83333.1"}->[$i]})) {
				print OUTPUT $fbaHash->{$compoundList->{"Seed83333.1"}->[$i]};
			}
		} else {
			if (defined($compoundData->{$compoundList->{"Seed83333.1"}->[$i]}->{$columns->[$j]})) {
				print OUTPUT join(", ",@{$compoundData->{$compoundList->{"Seed83333.1"}->[$i]}->{$columns->[$j]}});
			}
		}
	}
	print OUTPUT "\n";
}
close (OUTPUT);

#10.) Printing all reaction data to output file ReactionTbl.txt
$columns = ["DATABASE","NAME","EQUATION","Seed83333.1 COMPARTMENT","Seed83333.1 ASSOCIATED PEG","Seed83333.1 DIRECTIONALITY","FVA class","FBA flux"];
open (OUTPUT, ">ReactionTbl.txt");
print OUTPUT join("\t",@{$columns})."\n";
for (my $i=0; $i < @{$reactionList->{"Seed83333.1"}}; $i++) {
	for (my $j=0; $j < @{$columns}; $j++) {
		if ($j > 0) {
			print OUTPUT "\t";
		}
		if ($columns->[$j] =~ m/^Seed83333\.1\s(.+)/) {
			my $columnName = $1;
			if (defined($reactionData->{$reactionList->{"Seed83333.1"}->[$i]}->{"Seed83333.1"}->{$columnName})) {
				print OUTPUT join(" or ",@{$reactionData->{$reactionList->{"Seed83333.1"}->[$i]}->{"Seed83333.1"}->{$columnName}});
			}
		} elsif ($columns->[$j] eq "FVA class") {
			if (defined($fvaHash->{$reactionList->{"Seed83333.1"}->[$i]})) {
				print OUTPUT $fvaHash->{$reactionList->{"Seed83333.1"}->[$i]};
			}
		} elsif ($columns->[$j] eq "FBA flux") {
			if (defined($fbaHash->{$reactionList->{"Seed83333.1"}->[$i]})) {
				print OUTPUT $fbaHash->{$reactionList->{"Seed83333.1"}->[$i]};
			}
		} else {
			print OUTPUT $reactionData->{$reactionList->{"Seed83333.1"}->[$i]}->{$columns->[$j]}->[0];
		}
	}
	print OUTPUT "\n";
}
close (OUTPUT);

#11.) Printing essential gene predictions to output file GeneTbl.txt
open (OUTPUT, ">GeneTbl.txt");
print OUTPUT "Predicted essential E. coli genes\n";
for (my $i=0; $i < @{$KOOutput->[0]->{"essential genes"}}; $i++) {
	print OUTPUT $KOOutput->[0]->{"essential genes"}->[$i]."\n";
}
close (OUTPUT);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3