[Bio] / FigKernelPackages / FIGMODELmodel.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIGMODELmodel.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21, Sat Jul 10 22:43:52 2010 UTC revision 1.22, Mon Jul 26 04:51:24 2010 UTC
# Line 191  Line 191 
191  =cut  =cut
192  sub mgdata {  sub mgdata {
193          my ($self) = @_;          my ($self) = @_;
194          if (!defined($self->{_mgdata}) && $self->source() =~ /^MGRAST/) {          if (!defined($self->{_mgdata})) {
195                  require MGRAST;                  my $mgrastdbhandle = $self->figmodel()->database()->get_object_manager("mgjob");
196                  $self->{_mgdata} = $self->figmodel()->mgrast()->Job->get_objects( { 'genome_id' => $self->genome() } )                  my $objects = $mgrastdbhandle->get_objects( { 'genome_id' => $self->genome() } );
197                    $self->{_mgdata} = $objects->[0];
198          }          }
199          return $self->{_mgdata};          return $self->{_mgdata};
200  }  }
# Line 456  Line 457 
457                                  $filename = $self->directory().$tbldef->{filename_prefix}->[0]."-".$self->id().$self->selected_version().$suffix;                                  $filename = $self->directory().$tbldef->{filename_prefix}->[0]."-".$self->id().$self->selected_version().$suffix;
458                          }                          }
459                  }                  }
460                    print STDERR "KeyTable:".$filename.".\n";
461                  if (-e $filename) {                  if (-e $filename) {
462                          $self->{"_".$name} = $self->figmodel()->database()->load_table($filename,$columnDelim,$itemDelim,$tbldef->{headingline}->[0],$tbldef->{hashcolumns});                          $self->{"_".$name} = $self->figmodel()->database()->load_table($filename,$columnDelim,$itemDelim,$tbldef->{headingline}->[0],$tbldef->{hashcolumns});
463                  } else {                  } else {
# Line 548  Line 550 
550  =cut  =cut
551  sub reaction_table {  sub reaction_table {
552          my ($self,$clear) = @_;          my ($self,$clear) = @_;
553          if (defined($self->{_reaction_table})) {          if (defined($clear) && $clear == 1) {
554                  return $self->{_reaction_table};                  delete $self->{_reaction_table};
555          }          }
556            if (!defined($self->{_reaction_table})) {
557          $self->{_reaction_table} = $self->load_model_table("ModelReactions",$clear);          $self->{_reaction_table} = $self->load_model_table("ModelReactions",$clear);
558          my $classTbl = $self->reaction_class_table();          my $classTbl = $self->reaction_class_table();
559          if (defined($classTbl)) {          if (defined($classTbl)) {
# Line 582  Line 585 
585                          }                          }
586                  }                  }
587          }          }
588            }
589          return $self->{_reaction_table};          return $self->{_reaction_table};
590  }  }
591    
# Line 1031  Line 1035 
1035  }  }
1036    
1037  sub autocompleteMedia {  sub autocompleteMedia {
1038          my ($self) = @_;          my ($self,$newMedia) = @_;
1039          return $self->{_data}->autoCompleteMedia();          return $self->{_data}->autoCompleteMedia($newMedia);
1040    }
1041    
1042    sub biomassReaction {
1043            my ($self,$newBiomass) = @_;
1044            if (!defined($newBiomass)) {
1045                    return $self->{_data}->biomassReaction();
1046            } else {
1047                    #Figuring out what the old biomass is
1048                    my $oldBiomass = $self->{_data}->biomassReaction();
1049                    if ($newBiomass ne $oldBiomass) {
1050                            #Figuring out if the new biomass exists
1051                            my $handle = $self->database()->get_object_manager("bof");
1052                            my $objects = $handle->get_objects({"DATABASE" => [$newBiomass]});
1053                            if (!defined($objects) || !defined($objects->[0])) {
1054                                    print STDERR "Could not find new biomass reaction ".$newBiomass."\n";
1055                                    return $oldBiomass;
1056                            }
1057                            #Changing the biomass reaction in the model file
1058                            my $rxnTbl = $self->reaction_table();
1059                            for (my $i=0; $i < $rxnTbl->size(); $i++) {
1060                                    my $row = $rxnTbl->get_row($i);
1061                                    if ($row->{LOAD}->[0] =~ m/^bio/) {
1062                                            $row->{LOAD}->[0] = $newBiomass;
1063                                    }
1064                            }
1065                            $rxnTbl->save();
1066                            #Changing the biomass reaction in the database
1067                            return  $self->{_data}->biomassReaction($newBiomass);
1068                    }
1069            }
1070  }  }
1071    
1072  =head3 taxonomy  =head3 taxonomy
# Line 1157  Line 1191 
1191          $self->{_data}->modificationDate(time());          $self->{_data}->modificationDate(time());
1192          my $version = $self->{_data}->autocompleteVersion();          my $version = $self->{_data}->autocompleteVersion();
1193          $self->{_data}->autocompleteVersion($version+1);          $self->{_data}->autocompleteVersion($version+1);
1194            $self->update_model_stats();
1195  }  }
1196    
1197  =head3 update_stats_for_build  =head3 update_stats_for_build
# Line 1306  Line 1341 
1341          }          }
1342    
1343          #Calling the MFAToolkit to run the gap filling optimization          #Calling the MFAToolkit to run the gap filling optimization
1344          my $MinimalMediaTable = $self->figmodel()->database()->GetDBTable("MINIMAL MEDIA TABLE");          my $Media = $self->autocompleteMedia();
1345          my $Media = "Complete";          if ($Media eq "Complete") {
1346          if (defined($MinimalMediaTable->get_row_by_key($self->genome(),"Organism"))) {                  system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),undef,["GapFilling"],{"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef));
1347                  $Media = $MinimalMediaTable->get_row_by_key($self->genome(),"Organism")->{"Minimal media"}->[0];          } else {
1348                  #Loading media, changing bounds, saving media as a test media                  #Loading media, changing bounds, saving media as a test media
1349                  my $MediaTable = FIGMODELTable::load_table($self->config("Media directory")->[0].$Media.".txt",";","",0,["VarName"]);                  my $MediaTable = FIGMODELTable::load_table($self->config("Media directory")->[0].$Media.".txt",";","",0,["VarName"]);
1350                  for (my $i=0; $i < $MediaTable->size(); $i++) {                  for (my $i=0; $i < $MediaTable->size(); $i++) {
# Line 1324  Line 1359 
1359                  #print $self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$UniqueFilename."TestMedia",["GapFilling"],{"Default max drain flux" => 0,"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef)."\n";                  #print $self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$UniqueFilename."TestMedia",["GapFilling"],{"Default max drain flux" => 0,"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef)."\n";
1360                  system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$UniqueFilename."TestMedia",["GapFilling"],{"Default max drain flux" => 0,"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef));                  system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),$UniqueFilename."TestMedia",["GapFilling"],{"Default max drain flux" => 0,"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef));
1361                  unlink($self->config("Media directory")->[0].$UniqueFilename."TestMedia.txt");                  unlink($self->config("Media directory")->[0].$UniqueFilename."TestMedia.txt");
         } else {  
                 #print $self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),undef,["GapFilling"],{"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef)."\n";  
                 system($self->figmodel()->GenerateMFAToolkitCommandLineCall($UniqueFilename,$self->id(),undef,["GapFilling"],{"Reactions to knockout" => $self->config("permanently knocked out reactions")->[0]},"GapFill".$self->id().".log",undef));  
1362          }          }
1363    
1364          #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
# Line 1339  Line 1371 
1371                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");
1372                  return $self->fail();                  return $self->fail();
1373          }          }
         $SolutionData->save("/home/chenry/Solution.txt");  
1374    
1375          #Looking for the last printed recursive MILP solution          #Looking for the last printed recursive MILP solution
1376          for (my $i=($SolutionData->size()-1); $i >=0; $i--) {          for (my $i=($SolutionData->size()-1); $i >=0; $i--) {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3