Running Flux Balance Analysis on a metabolic model in KBase In this short example, I write code that runs flux balance analysis on a single metabolic model in KBase and prints the result. First, you need to object a copy of the fbaServices client module. If you have access to the KBase git repository, you can check out the fbaServices module. The client module is included in the fbaServices/clients/ folder as fbaServicesClient.pm. Alternatively, you can simply download the client module from: http://bioseed.mcs.anl.gov/~chenry/KbaseFiles/fbaServicesClient.pm #First, you must include the fbaServicesClient module, which can be run on any computer anywhere use fbaServicesClient; #Next, you create an fbaServicesClient object, which you will call all functions on my $fbaServ = fbaServicesClient->new("http://biologin-4.mcs.anl.gov:5000/"); #Let's create a ModelFBA object with a model and media my $modelFBA = { fbaModel_id => "Seed83333.1", media_id => "ArgonneLBMedia", }; #Now we will call the runFBA function to run this model my $resultFBA = $fbaServ->runfba($modelFBA); #Our FBA is now done, so we print the objective and fluxes if (defined($resultFBA)) { #Printing the objective value print "Objective is:".$resultFBA->{objectiveValue}."!\n"; #Printing metabolite uptake and excretion print "Metabolite uptake and excretion:\n"; print "Metabolite\tUptake\n"; for (my $i=0; $i < @{$resultFBA->{fbaSolutions}->[0]->{modelfbaCompounds}}; $i++) { my $metabolite = $resultFBA->{fbaSolutions}->[0]->{modelfbaCompounds}->[$i]->{modelCompound_id}; my $flux = $resultFBA->{fbaSolutions}->[0]->{modelfbaCompounds}->[$i]->{variables}->{drainflux}->{value}; if ($flux < -1e-7 || $flux > 1e-7) { print $metabolite."\t".$flux."\n"; } } #Printing reaction flux print "Reaction flux:\n"; print "Reaction\tFlux\n"; for (my $i=0; $i < @{$resultFBA->{fbaSolutions}->[0]->{modelfbaReactions}}; $i++) { my $reaction = $resultFBA->{fbaSolutions}->[0]->{modelfbaReactions}->[$i]->{modelReaction_id}; my $flux = $resultFBA->{fbaSolutions}->[0]->{modelfbaReactions}->[$i]->{variables}->{flux}->{value}; if ($flux < -1e-7 || $flux > 1e-7) { print $reaction."\t".$flux."\n"; } } }