[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.24, Mon Jul 26 06:21:14 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 548  Line 549 
549  =cut  =cut
550  sub reaction_table {  sub reaction_table {
551          my ($self,$clear) = @_;          my ($self,$clear) = @_;
552          if (defined($self->{_reaction_table})) {          if (defined($clear) && $clear == 1) {
553                  return $self->{_reaction_table};                  delete $self->{_reaction_table};
554          }          }
555            if (!defined($self->{_reaction_table})) {
556          $self->{_reaction_table} = $self->load_model_table("ModelReactions",$clear);          $self->{_reaction_table} = $self->load_model_table("ModelReactions",$clear);
557          my $classTbl = $self->reaction_class_table();          my $classTbl = $self->reaction_class_table();
558          if (defined($classTbl)) {          if (defined($classTbl)) {
# Line 582  Line 584 
584                          }                          }
585                  }                  }
586          }          }
587            }
588          return $self->{_reaction_table};          return $self->{_reaction_table};
589  }  }
590    
# Line 1031  Line 1034 
1034  }  }
1035    
1036  sub autocompleteMedia {  sub autocompleteMedia {
1037          my ($self) = @_;          my ($self,$newMedia) = @_;
1038            if (defined($newMedia)) {
1039                    return $self->{_data}->autoCompleteMedia($newMedia);
1040            }
1041          return $self->{_data}->autoCompleteMedia();          return $self->{_data}->autoCompleteMedia();
1042  }  }
1043    
1044    sub biomassReaction {
1045            my ($self,$newBiomass) = @_;
1046            if (!defined($newBiomass)) {
1047                    return $self->{_data}->biomassReaction();
1048            } else {
1049                    #Figuring out what the old biomass is
1050                    my $oldBiomass = $self->{_data}->biomassReaction();
1051                    if ($newBiomass ne $oldBiomass) {
1052                            #Figuring out if the new biomass exists
1053                            my $handle = $self->database()->get_object_manager("bof");
1054                            my $objects = $handle->get_objects({"DATABASE" => [$newBiomass]});
1055                            if (!defined($objects) || !defined($objects->[0])) {
1056                                    print STDERR "Could not find new biomass reaction ".$newBiomass."\n";
1057                                    return $oldBiomass;
1058                            }
1059                            #Changing the biomass reaction in the model file
1060                            my $rxnTbl = $self->reaction_table();
1061                            for (my $i=0; $i < $rxnTbl->size(); $i++) {
1062                                    my $row = $rxnTbl->get_row($i);
1063                                    if ($row->{LOAD}->[0] =~ m/^bio/) {
1064                                            $row->{LOAD}->[0] = $newBiomass;
1065                                    }
1066                            }
1067                            $rxnTbl->save();
1068                            #Changing the biomass reaction in the database
1069                            return  $self->{_data}->biomassReaction($newBiomass);
1070                    }
1071            }
1072    }
1073    
1074  =head3 taxonomy  =head3 taxonomy
1075  Definition:  Definition:
1076          string = FIGMODELmodel->taxonomy();          string = FIGMODELmodel->taxonomy();
# Line 1157  Line 1193 
1193          $self->{_data}->modificationDate(time());          $self->{_data}->modificationDate(time());
1194          my $version = $self->{_data}->autocompleteVersion();          my $version = $self->{_data}->autocompleteVersion();
1195          $self->{_data}->autocompleteVersion($version+1);          $self->{_data}->autocompleteVersion($version+1);
1196            $self->update_model_stats();
1197  }  }
1198    
1199  =head3 update_stats_for_build  =head3 update_stats_for_build
# Line 1306  Line 1343 
1343          }          }
1344    
1345          #Calling the MFAToolkit to run the gap filling optimization          #Calling the MFAToolkit to run the gap filling optimization
1346          my $MinimalMediaTable = $self->figmodel()->database()->GetDBTable("MINIMAL MEDIA TABLE");          my $Media = $self->autocompleteMedia();
1347          my $Media = "Complete";          if ($Media eq "Complete") {
1348          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));
1349                  $Media = $MinimalMediaTable->get_row_by_key($self->genome(),"Organism")->{"Minimal media"}->[0];          } else {
1350                  #Loading media, changing bounds, saving media as a test media                  #Loading media, changing bounds, saving media as a test media
1351                  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"]);
1352                  for (my $i=0; $i < $MediaTable->size(); $i++) {                  for (my $i=0; $i < $MediaTable->size(); $i++) {
# Line 1324  Line 1361 
1361                  #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";
1362                  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));
1363                  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));  
1364          }          }
1365    
1366          #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 1373 
1373                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");
1374                  return $self->fail();                  return $self->fail();
1375          }          }
         $SolutionData->save("/home/chenry/Solution.txt");  
1376    
1377          #Looking for the last printed recursive MILP solution          #Looking for the last printed recursive MILP solution
1378          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.24

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3