#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";
		}
	}
}