387 |
=cut |
=cut |
388 |
sub load_model_table { |
sub load_model_table { |
389 |
my ($self,$name,$refresh) = @_; |
my ($self,$name,$refresh) = @_; |
390 |
if (!defined($refresh)) { |
if (defined($refresh) && $refresh == 1) { |
|
$refresh = 1; |
|
|
} |
|
|
if ($refresh == 1) { |
|
391 |
delete $self->{"_".$name}; |
delete $self->{"_".$name}; |
392 |
} |
} |
393 |
if (!defined($self->{"_".$name})) { |
if (!defined($self->{"_".$name})) { |
394 |
my $tbldef = $self->figmodel()->config("$name"); |
my $tbldef = $self->figmodel()->config($name); |
395 |
if (!defined($tbldef)) { |
if (!defined($tbldef)) { |
396 |
return undef; |
return undef; |
397 |
} |
} |
398 |
my $filename = $self->directory().$name."-".$self->id().$self->selected_version().".tbl"; |
my $itemDelim = "|"; |
399 |
$self->{"_".$name} = $self->figmodel()->database()->load_table($filename,"\t","|",$tbldef->{headingline}->[0],$tbldef->{hashcolumns}); |
if (defined($tbldef->{itemdelimiter}->[0])) { |
400 |
if (!defined($self->{"_".$name})) { |
$itemDelim = $tbldef->{itemdelimiter}->[0]; |
401 |
|
if ($itemDelim eq "SC") { |
402 |
|
$itemDelim = ";"; |
403 |
|
} |
404 |
|
} |
405 |
|
my $columnDelim = "\t"; |
406 |
|
if (defined($tbldef->{columndelimiter}->[0])) { |
407 |
|
$columnDelim = $tbldef->{columndelimiter}->[0]; |
408 |
|
if ($columnDelim eq "SC") { |
409 |
|
$columnDelim = ";"; |
410 |
|
} |
411 |
|
} |
412 |
|
my $suffix = ".tbl"; |
413 |
|
if (defined($tbldef->{filename_suffix}->[0])) { |
414 |
|
$suffix = $tbldef->{filename_suffix}->[0]; |
415 |
|
} |
416 |
|
my $filename = $self->directory().$name."-".$self->id().$self->selected_version().$suffix; |
417 |
|
if (defined($tbldef->{filename_prefix}->[0])) { |
418 |
|
if ($tbldef->{filename_prefix}->[0] eq "NONE") { |
419 |
|
$filename = $self->directory().$self->id().$self->selected_version().$suffix; |
420 |
|
} else { |
421 |
|
$filename = $self->directory().$tbldef->{filename_prefix}->[0]."-".$self->id().$self->selected_version().$suffix; |
422 |
|
} |
423 |
|
} |
424 |
|
if (-e $filename) { |
425 |
|
$self->{"_".$name} = $self->figmodel()->database()->load_table($filename,$columnDelim,$itemDelim,$tbldef->{headingline}->[0],$tbldef->{hashcolumns}); |
426 |
|
} else { |
427 |
if (defined($tbldef->{prefix})) { |
if (defined($tbldef->{prefix})) { |
428 |
$self->{"_".$name} = FIGMODELTable->new($tbldef->{columns},$filename,$tbldef->{hashcolumns},"\t","|",join(@{$tbldef->{prefix}},"\n")); |
$self->{"_".$name} = FIGMODELTable->new($tbldef->{columns},$filename,$tbldef->{hashcolumns},$columnDelim,$itemDelim,join(@{$tbldef->{prefix}},"\n")); |
429 |
} else { |
} else { |
430 |
$self->{"_".$name} = FIGMODELTable->new($tbldef->{columns},$filename,$tbldef->{hashcolumns},"\t","|"); |
$self->{"_".$name} = FIGMODELTable->new($tbldef->{columns},$filename,$tbldef->{hashcolumns},$columnDelim,$itemDelim); |
431 |
} |
} |
432 |
} |
} |
433 |
} |
} |
490 |
Returns FIGMODELTable with the reaction list for the model |
Returns FIGMODELTable with the reaction list for the model |
491 |
=cut |
=cut |
492 |
sub reaction_table { |
sub reaction_table { |
493 |
my ($self) = @_; |
my ($self,$clear) = @_; |
494 |
|
my $tbl = $self->load_model_table("ModelReactions",$clear); |
|
if (!defined($self->{_reaction_data})) { |
|
|
$self->{_reaction_data} = $self->figmodel()->database()->GetDBModel($self->id()); |
|
495 |
my $classTbl = $self->reaction_class_table(); |
my $classTbl = $self->reaction_class_table(); |
496 |
|
if (defined($classTbl)) { |
497 |
for (my $i=0; $i < $classTbl->size(); $i++) { |
for (my $i=0; $i < $classTbl->size(); $i++) { |
498 |
my $row = $classTbl->get_row($i); |
my $row = $classTbl->get_row($i); |
499 |
my $rxnRow = $self->{_reaction_data}->get_row_by_key($row->{"REACTION"}->[0],"LOAD"); |
if (defined($row->{REACTION})) { |
500 |
|
my $rxnRow = $tbl->get_row_by_key($row->{"REACTION"}->[0],"LOAD"); |
501 |
|
if (defined($row->{MEDIA})) { |
502 |
for (my $j=0; $j < @{$row->{MEDIA}};$j++) { |
for (my $j=0; $j < @{$row->{MEDIA}};$j++) { |
503 |
my $class = "Active <=>"; |
my $class = "Active <=>"; |
504 |
if ($row->{CLASS}->[$j] eq "Positive") { |
if ($row->{CLASS}->[$j] eq "Positive") { |
520 |
} |
} |
521 |
} |
} |
522 |
} |
} |
523 |
|
} |
524 |
|
} |
525 |
|
return $tbl; |
526 |
|
} |
527 |
|
|
528 |
return $self->{_reaction_data}; |
=head3 model_history |
529 |
|
Definition: |
530 |
|
FIGMODELTable = FIGMODELmodel->model_history(); |
531 |
|
Description: |
532 |
|
Returns FIGMODELTable with the history of model changes |
533 |
|
=cut |
534 |
|
sub model_history { |
535 |
|
my ($self,$clear) = @_; |
536 |
|
return $self->load_model_table("ModelHistory",$clear); |
537 |
} |
} |
538 |
|
|
539 |
=head3 feature_table |
=head3 feature_table |
620 |
Returns FIGMODELTable with the reaction class data, and creates the table file if it does not exist |
Returns FIGMODELTable with the reaction class data, and creates the table file if it does not exist |
621 |
=cut |
=cut |
622 |
sub reaction_class_table { |
sub reaction_class_table { |
623 |
my ($self) = @_; |
my ($self,$clear) = @_; |
624 |
|
return $self->load_model_table("ModelReactionClasses",$clear); |
|
if (!defined($self->{_reaction_class_table})) { |
|
|
if (-e $self->directory()."ReactionClassification-".$self->id().$self->selected_version().".tbl") { |
|
|
$self->{_reaction_class_table} = $self->figmodel()->database()->load_table($self->directory()."ReactionClassification-".$self->id().$self->selected_version().".tbl",";","|",0,["REACTION","CLASS","MEDIA"]); |
|
|
} else { |
|
|
$self->{_reaction_class_table} = FIGMODELTable->new(["REACTION","MEDIA","CLASS","MIN","MAX"],$self->directory()."ReactionClassification-".$self->id().$self->selected_version().".tbl",["REACTION","CLASS","MEDIA"],";","|",undef); |
|
|
} |
|
|
} |
|
|
|
|
|
return $self->{_reaction_class_table}; |
|
625 |
} |
} |
626 |
|
|
627 |
=head3 compound_class_table |
=head3 compound_class_table |
631 |
Returns FIGMODELTable with the compound class data, and creates the table file if it does not exist |
Returns FIGMODELTable with the compound class data, and creates the table file if it does not exist |
632 |
=cut |
=cut |
633 |
sub compound_class_table { |
sub compound_class_table { |
634 |
my ($self) = @_; |
my ($self,$clear) = @_; |
635 |
|
return $self->load_model_table("ModelCompoundClasses",$clear); |
|
if (!defined($self->{_compound_class_table})) { |
|
|
if (-e $self->directory()."CompoundClassification-".$self->id().$self->selected_version().".tbl") { |
|
|
$self->{_compound_class_table} = $self->figmodel()->database()->load_table($self->directory()."CompoundClassification-".$self->id().$self->selected_version().".tbl",";","|",0,["COMPOUND","CLASS","MEDIA"]); |
|
|
} else { |
|
|
$self->{_compound_class_table} = FIGMODELTable->new(["COMPOUND","MEDIA","CLASS","MIN","MAX"],$self->directory()."CompoundClassification-".$self->id().$self->selected_version().".tbl",["COMPOUND","CLASS","MEDIA"],";","|",undef); |
|
|
} |
|
|
} |
|
|
|
|
|
return $self->{_compound_class_table}; |
|
636 |
} |
} |
637 |
|
|
638 |
=head3 get_essential_genes |
=head3 get_essential_genes |
927 |
return $self->{_data}->cellwalltype(); |
return $self->{_data}->cellwalltype(); |
928 |
} |
} |
929 |
|
|
930 |
|
sub autocompleteMedia { |
931 |
|
my ($self) = @_; |
932 |
|
return $self->{_data}->autoCompleteMedia(); |
933 |
|
} |
934 |
|
|
935 |
=head3 taxonomy |
=head3 taxonomy |
936 |
Definition: |
Definition: |
937 |
string = FIGMODELmodel->taxonomy(); |
string = FIGMODELmodel->taxonomy(); |
1182 |
my $UniqueFilename = $self->figmodel()->filename(); |
my $UniqueFilename = $self->figmodel()->filename(); |
1183 |
my $StartTime = time(); |
my $StartTime = time(); |
1184 |
|
|
1185 |
#Archiving the existing model |
#Reading original reaction table |
1186 |
$self->ArchiveModel(); |
my $OriginalRxn = $self->reaction_table(); |
1187 |
|
#Clearing the table |
1188 |
|
$self->reaction_table(1); |
1189 |
|
|
1190 |
#Removing any gapfilling reactions that may be currently present in the model |
#Removing any gapfilling reactions that may be currently present in the model |
1191 |
if (!defined($donotclear) || $donotclear != 1) { |
if (!defined($donotclear) || $donotclear != 1) { |
1192 |
my $ModelTable = $self->reaction_table(); |
my $ModelTable = $self->reaction_table(); |
1193 |
for (my $i=0; $i < $ModelTable->size(); $i++) { |
for (my $i=0; $i < $ModelTable->size(); $i++) { |
1194 |
if (!defined($ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0]) || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] eq "GAP FILLING" || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] =~ m/BIOLOG/ || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] =~ m/GROWMATCH/) { |
if (!defined($ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0]) || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] eq "AUTOCOMPLETION" || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] eq "GAP FILLING" || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] =~ m/BIOLOG/ || $ModelTable->get_row($i)->{"ASSOCIATED PEG"}->[0] =~ m/GROWMATCH/) { |
1195 |
$ModelTable->delete_row($i); |
$ModelTable->delete_row($i); |
1196 |
$i--; |
$i--; |
1197 |
} |
} |
1223 |
|
|
1224 |
#Parse the solutions file for the model and get the reaction list from it |
#Parse the solutions file for the model and get the reaction list from it |
1225 |
my $SolutionData = $self->figmodel()->LoadProblemReport($UniqueFilename); |
my $SolutionData = $self->figmodel()->LoadProblemReport($UniqueFilename); |
1226 |
|
|
1227 |
#Clearing the mfatoolkit output and log file |
#Clearing the mfatoolkit output and log file |
1228 |
$self->figmodel()->clearing_output($UniqueFilename,"GapFill".$self->id().".log"); |
$self->figmodel()->clearing_output($UniqueFilename,"GapFill".$self->id().".log"); |
1229 |
if (!defined($SolutionData) || $SolutionData->size() == 0) { |
if (!defined($SolutionData) || $SolutionData->size() == 0) { |
1259 |
push(@{$ReactionList},$ID); |
push(@{$ReactionList},$ID); |
1260 |
} |
} |
1261 |
} |
} |
1262 |
$self->figmodel()->IntegrateGrowMatchSolution($self->id(),undef,$ReactionList,$DirectionList,"GAP FILLING",0,1); |
$self->figmodel()->IntegrateGrowMatchSolution($self->id(),undef,$ReactionList,$DirectionList,"AUTOCOMPLETION",0,1); |
1263 |
} |
} |
1264 |
last; |
last; |
1265 |
} |
} |
1266 |
} |
} |
1267 |
|
|
1268 |
#Updating model stats with gap filling results |
#Updating model stats with gap filling results |
1269 |
my $ElapsedTime = time() - $StartTime; |
my $ElapsedTime = time() - $StartTime; |
1270 |
$self->figmodel()->database()->ClearDBModel($self->id(),1); |
$self->reaction_table(1); |
1271 |
|
$self->calculate_model_changes($OriginalRxn,"AUTOCOMPLETION"); |
1272 |
|
|
1273 |
#Determining why each gap filling reaction was added |
#Determining why each gap filling reaction was added |
1274 |
$self->figmodel()->IdentifyDependancyOfGapFillingReactions($self->id(),$Media); |
$self->figmodel()->IdentifyDependancyOfGapFillingReactions($self->id(),$Media); |
1275 |
if (!defined($donotclear) || $donotclear != 1) { |
if (!defined($donotclear) || $donotclear != 1) { |
1289 |
return $self->success(); |
return $self->success(); |
1290 |
} |
} |
1291 |
|
|
1292 |
|
=head3 calculate_model_changes |
1293 |
|
Definition: |
1294 |
|
FIGMODELmodel->calculate_model_changes(FIGMODELTable:original reaction table,string:modification cause); |
1295 |
|
Description: |
1296 |
|
|
1297 |
|
=cut |
1298 |
|
|
1299 |
|
sub calculate_model_changes { |
1300 |
|
my ($self,$originalReactions,$cause) = @_; |
1301 |
|
my $modTime = time(); |
1302 |
|
my $version = $self->selected_version(); |
1303 |
|
my $user = $self->figmodel()->user(); |
1304 |
|
#Getting the history table |
1305 |
|
my $histTbl = $self->model_history(); |
1306 |
|
#Checking for differences |
1307 |
|
my $tbl = $self->reaction_table(); |
1308 |
|
for (my $i=0; $i < $tbl->size(); $i++) { |
1309 |
|
my $row = $tbl->get_row($i); |
1310 |
|
my $orgRow = $originalReactions->get_row_by_key($row->{LOAD}->[0],"LOAD"); |
1311 |
|
if (!defined($orgRow)) { |
1312 |
|
$histTbl->add_row({Reaction => [$row->{LOAD}->[0]], DirectionChange => $row->{DIRECTIONALITY}, GeneChange => $row->{"ASSOCIATED PEG"}, Action => ["ADDED"], ModificationTime => [$modTime], ModifcationCause => [$cause], User => [$user], Version => [$version]}); |
1313 |
|
} else { |
1314 |
|
my $geneChanges; |
1315 |
|
my $directionChange; |
1316 |
|
if ($orgRow->{"DIRECTIONALITY"}->[0] ne $row->{"DIRECTIONALITY"}->[0]) { |
1317 |
|
$directionChange = $orgRow->{"DIRECTIONALITY"}->[0]." to ".$row->{"DIRECTIONALITY"}->[0]; |
1318 |
|
} |
1319 |
|
for (my $j=0; $j < @{$row->{"ASSOCIATED PEG"}}; $j++) { |
1320 |
|
my $match = 0; |
1321 |
|
for (my $k=0; $k < @{$orgRow->{"ASSOCIATED PEG"}}; $k++) { |
1322 |
|
if ($row->{"ASSOCIATED PEG"}->[$j] eq $orgRow->{"ASSOCIATED PEG"}->[$k]) { |
1323 |
|
$match = 1; |
1324 |
|
} |
1325 |
|
} |
1326 |
|
if ($match == 0) { |
1327 |
|
push(@{$geneChanges},"Added ".$row->{"ASSOCIATED PEG"}->[$j]); |
1328 |
|
} |
1329 |
|
} |
1330 |
|
for (my $k=0; $k < @{$orgRow->{"ASSOCIATED PEG"}}; $k++) { |
1331 |
|
my $match = 0; |
1332 |
|
for (my $j=0; $j < @{$row->{"ASSOCIATED PEG"}}; $j++) { |
1333 |
|
if ($row->{"ASSOCIATED PEG"}->[$j] eq $orgRow->{"ASSOCIATED PEG"}->[$k]) { |
1334 |
|
$match = 1; |
1335 |
|
} |
1336 |
|
} |
1337 |
|
if ($match == 0) { |
1338 |
|
push(@{$geneChanges},"Removed ".$orgRow->{"ASSOCIATED PEG"}->[$k]); |
1339 |
|
} |
1340 |
|
} |
1341 |
|
if ((defined($directionChange) && length($directionChange) > 0) || defined($geneChanges) && @{$geneChanges} > 0) { |
1342 |
|
$histTbl->add_row({Reaction => [$row->{LOAD}->[0]], DirectionChange => [$directionChange], GeneChange => $geneChanges, Action => ["CHANGE"], ModificationTime => [$modTime], ModifcationCause => [$cause], User => [$user], Version => [$version]}); |
1343 |
|
} |
1344 |
|
} |
1345 |
|
} |
1346 |
|
#Looking for removed reactions |
1347 |
|
for (my $i=0; $i < $originalReactions->size(); $i++) { |
1348 |
|
my $row = $originalReactions->get_row($i); |
1349 |
|
my $orgRow = $tbl->get_row_by_key($row->{LOAD}->[0],"LOAD"); |
1350 |
|
if (!defined($orgRow)) { |
1351 |
|
$histTbl->add_row({Reaction => [$row->{LOAD}->[0]], DirectionChange => $row->{DIRECTIONALITY}, GeneChange => $row->{"ASSOCIATED PEG"}, Action => ["REMOVED"], ModificationTime => [$modTime], ModifcationCause => [$cause], User => [$user], Version => [$version]}); |
1352 |
|
} |
1353 |
|
} |
1354 |
|
$histTbl->save(); |
1355 |
|
} |
1356 |
|
|
1357 |
=head3 GapGenModel |
=head3 GapGenModel |
1358 |
Definition: |
Definition: |
1359 |
FIGMODELmodel->GapGenModel(); |
FIGMODELmodel->GapGenModel(); |
1591 |
=cut |
=cut |
1592 |
sub status { |
sub status { |
1593 |
my ($self) = @_; |
my ($self) = @_; |
1594 |
return $self->{_data}->{status}->[0]; |
return $self->{_data}->status(); |
1595 |
} |
} |
1596 |
|
|
1597 |
=head3 message |
=head3 message |
1602 |
=cut |
=cut |
1603 |
sub message { |
sub message { |
1604 |
my ($self) = @_; |
my ($self) = @_; |
1605 |
return $self->{_data}->{message}->[0]; |
return $self->{_data}->message(); |
1606 |
} |
} |
1607 |
|
|
1608 |
=head3 set_status |
=head3 set_status |
1617 |
=cut |
=cut |
1618 |
sub set_status { |
sub set_status { |
1619 |
my ($self,$NewStatus,$Message) = @_; |
my ($self,$NewStatus,$Message) = @_; |
1620 |
|
$self->{_data}->status($NewStatus); |
1621 |
#Getting the model row from the MODELS table |
$self->{_data}->message($Message); |
|
$self->{_data}->{status}->[0] = $NewStatus; |
|
|
$self->{_data}->{message}->[0] = $Message; |
|
|
$self->figmodel()->database()->update_row("MODELS",$self->{_data},"id"); |
|
1622 |
return $self->config("SUCCESS")->[0]; |
return $self->config("SUCCESS")->[0]; |
1623 |
} |
} |
1624 |
|
|
1657 |
} |
} |
1658 |
#Setting up needed variables |
#Setting up needed variables |
1659 |
my $OriginalModelTable = undef; |
my $OriginalModelTable = undef; |
1660 |
#Locking model status table |
if ($self->status() == 0) { |
|
my $ModelTable = $self->figmodel()->database()->LockDBTable("MODELS"); |
|
|
my $Row = $ModelTable->get_row_by_key($self->id(),"id"); |
|
|
if (!defined($Row) || !defined($Row->{status}->[0])) { |
|
|
$self->figmodel()->database()->UnlockDBTable("MODELS"); |
|
|
$self->figmodel()->error_message("FIGMODEL:CreateSingleGenomeReactionList: ".$self->id()." has no row in models table!"); |
|
|
return $self->fail(); |
|
|
} elsif ($Row->{status}->[0] == 0) { |
|
1661 |
$self->figmodel()->error_message("FIGMODEL:CreateSingleGenomeReactionList:Model is already being built. Canceling current build."); |
$self->figmodel()->error_message("FIGMODEL:CreateSingleGenomeReactionList:Model is already being built. Canceling current build."); |
|
$self->figmodel()->database()->UnlockDBTable("MODELS"); |
|
1662 |
return $self->fail(); |
return $self->fail(); |
1663 |
}elsif ($Row->{status}->[0] == 1) { |
}elsif ($self->status() == 1) { |
1664 |
$OriginalModelTable = $self->reaction_table(); |
$OriginalModelTable = $self->reaction_table(); |
1665 |
$self->ArchiveModel(); |
$self->set_status(0,"Rebuilding preliminary reconstruction"); |
|
$Row->{status}->[0] = 0; |
|
|
$Row->{message}->[0] = "Rebuilding preliminary reconstruction"; |
|
1666 |
} else { |
} else { |
1667 |
$Row->{status}->[0] = 0; |
$self->set_status(0,"Preliminary reconstruction"); |
|
$Row->{message}->[0] = "Preliminary reconstruction"; |
|
1668 |
} |
} |
|
#Updating the status table |
|
|
$self->figmodel()->database()->save_table($ModelTable); |
|
|
$self->figmodel()->database()->UnlockDBTable("MODELS"); |
|
1669 |
#Sorting GenomeData by gene location on the chromosome |
#Sorting GenomeData by gene location on the chromosome |
1670 |
$FeatureTable->sort_rows("MIN LOCATION"); |
$FeatureTable->sort_rows("MIN LOCATION"); |
1671 |
my ($ComplexHash,$SuggestedMappings,$UnrecognizedReactions,$ReactionHash); |
my ($ComplexHash,$SuggestedMappings,$UnrecognizedReactions,$ReactionHash); |
1959 |
#Saving the new model to file |
#Saving the new model to file |
1960 |
$self->set_status(1,"Preliminary reconstruction complete"); |
$self->set_status(1,"Preliminary reconstruction complete"); |
1961 |
$self->figmodel()->database()->save_table($NewModelTable); |
$self->figmodel()->database()->save_table($NewModelTable); |
1962 |
$self->{_reaction_data} = $NewModelTable; |
$self->reaction_table(1); |
|
#Clearing the previous model from the cache |
|
|
$self->figmodel()->database()->ClearDBModel($self->id(),1); |
|
1963 |
#Updating the model stats table |
#Updating the model stats table |
1964 |
$self->update_stats_for_build(); |
$self->update_stats_for_build(); |
1965 |
$self->PrintSBMLFile(); |
$self->PrintSBMLFile(); |
1966 |
|
if (defined($OriginalModelTable)) { |
1967 |
|
$self->calculate_model_changes($OriginalModelTable,"REBUILD"); |
1968 |
|
} |
1969 |
|
|
1970 |
#Adding model to gapfilling queue |
#Adding model to gapfilling queue |
1971 |
if (defined($RunGapFilling) && $RunGapFilling == 1) { |
if (defined($RunGapFilling) && $RunGapFilling == 1) { |
2465 |
Calculating growth in the input media |
Calculating growth in the input media |
2466 |
=cut |
=cut |
2467 |
sub calculate_growth { |
sub calculate_growth { |
2468 |
my ($self,$Media) = @_; |
my ($self,$Media,$outputDirectory,$InParameters,$saveLPFile) = @_; |
2469 |
|
#Setting the Media |
2470 |
|
if (!defined($Media) || length($Media) == 0) { |
2471 |
|
$Media = $self->autocompleteMedia(); |
2472 |
|
} |
2473 |
|
#Setting parameters for the run |
2474 |
|
my $DefaultParameters = $self->figmodel()->defaultParameters(); |
2475 |
|
if (defined($InParameters)) { |
2476 |
|
my @parameters = keys(%{$InParameters}); |
2477 |
|
for (my $i=0; $i < @parameters; $i++) { |
2478 |
|
$DefaultParameters->{$parameters[$i]} = $InParameters->{$parameters[$i]}; |
2479 |
|
} |
2480 |
|
} |
2481 |
|
$DefaultParameters->{"optimize metabolite production if objective is zero"} = 1; |
2482 |
|
#Setting filenames |
2483 |
my $UniqueFilename = $self->figmodel()->filename(); |
my $UniqueFilename = $self->figmodel()->filename(); |
2484 |
system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$Media,["ProductionMFA"],{"optimize metabolite production if objective is zero" => 1},$self->id()."-".$Media."-GrowthTest.txt",undef,$self->selected_version())); |
if (!defined($outputDirectory)) { |
2485 |
|
$outputDirectory = $self->config("database message file directory")->[0]; |
2486 |
|
} |
2487 |
|
my $fluxFilename = $outputDirectory."Fluxes-".$self->id()."-".$Media.".txt"; |
2488 |
|
my $cpdFluxFilename = $outputDirectory."CompoundFluxes-".$self->id()."-".$Media.".txt"; |
2489 |
|
#Running FBA |
2490 |
|
system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$Media,["ProductionMFA"],$DefaultParameters,$self->id()."-".$Media."-GrowthTest.txt",undef,$self->selected_version())); |
2491 |
|
#Saving LP file if requested |
2492 |
|
if (defined($saveLPFile) && $saveLPFile == 1 && -e $self->figmodel()->{"MFAToolkit output directory"}->[0].$UniqueFilename."/CurrentProblem.lp") { |
2493 |
|
system("cp ".$self->figmodel()->config("MFAToolkit output directory")->[0].$UniqueFilename."/CurrentProblem.lp ".$self->figmodel()->config("SBML files")->[0].$self->id().".lp"); |
2494 |
|
} |
2495 |
my $ProblemReport = $self->figmodel()->LoadProblemReport($UniqueFilename); |
my $ProblemReport = $self->figmodel()->LoadProblemReport($UniqueFilename); |
2496 |
my $Result; |
my $Result; |
2497 |
if (defined($ProblemReport)) { |
if (defined($ProblemReport)) { |
2498 |
my $Row = $ProblemReport->get_row(0); |
my $Row = $ProblemReport->get_row(0); |
2499 |
if (defined($Row) && defined($Row->{"Objective"}->[0])) { |
if (defined($Row) && defined($Row->{"Objective"}->[0])) { |
2500 |
if ($Row->{"Objective"}->[0] < 0.00000001) { |
if ($Row->{"Objective"}->[0] < 0.00000001 || $Row->{"Objective"}->[0] == 1e7) { |
2501 |
$Result = "NOGROWTH:".$Row->{"Individual metabolites with zero production"}->[0]; |
$Result = "NOGROWTH"; |
2502 |
|
if (defined($Row->{"Individual metabolites with zero production"}->[0]) && $Row->{"Individual metabolites with zero production"}->[0] =~ m/cpd\d\d\d\d\d/) { |
2503 |
|
$Result .= ":".$Row->{"Individual metabolites with zero production"}->[0]; |
2504 |
|
} |
2505 |
} else { |
} else { |
2506 |
|
if (-e $self->figmodel()->config("MFAToolkit output directory")->[0].$UniqueFilename."/MFAOutput/SolutionReactionData0.txt") { |
2507 |
|
system("cp ".$self->figmodel()->config("MFAToolkit output directory")->[0].$UniqueFilename."/MFAOutput/SolutionReactionData0.txt ".$fluxFilename); |
2508 |
|
system("cp ".$self->figmodel()->config("MFAToolkit output directory")->[0].$UniqueFilename."/MFAOutput/SolutionCompoundData0.txt ".$cpdFluxFilename); |
2509 |
|
} |
2510 |
$Result = $Row->{"Objective"}->[0]; |
$Result = $Row->{"Objective"}->[0]; |
2511 |
} |
} |
2512 |
} |
} |
2513 |
} |
} |
2514 |
|
#Deleting files if necessary |
2515 |
|
if ($self->figmodel()->config("preserve all log files")->[0] ne "yes") { |
2516 |
|
$self->figmodel()->cleardirectory($UniqueFilename); |
2517 |
|
unlink($self->figmodel()->config("database message file directory")->[0].$self->id()."-".$Media."-GrowthTest.txt"); |
2518 |
|
} |
2519 |
|
#Returning result |
2520 |
return $Result; |
return $Result; |
2521 |
} |
} |
2522 |
|
|