[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.23, Mon Jul 26 05:53:06 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          return $self->{_data}->autoCompleteMedia();          return $self->{_data}->autoCompleteMedia($newMedia);
1039    }
1040    
1041    sub biomassReaction {
1042            my ($self,$newBiomass) = @_;
1043            if (!defined($newBiomass)) {
1044                    return $self->{_data}->biomassReaction();
1045            } else {
1046                    #Figuring out what the old biomass is
1047                    my $oldBiomass = $self->{_data}->biomassReaction();
1048                    if ($newBiomass ne $oldBiomass) {
1049                            #Figuring out if the new biomass exists
1050                            my $handle = $self->database()->get_object_manager("bof");
1051                            my $objects = $handle->get_objects({"DATABASE" => [$newBiomass]});
1052                            if (!defined($objects) || !defined($objects->[0])) {
1053                                    print STDERR "Could not find new biomass reaction ".$newBiomass."\n";
1054                                    return $oldBiomass;
1055                            }
1056                            #Changing the biomass reaction in the model file
1057                            my $rxnTbl = $self->reaction_table();
1058                            for (my $i=0; $i < $rxnTbl->size(); $i++) {
1059                                    my $row = $rxnTbl->get_row($i);
1060                                    if ($row->{LOAD}->[0] =~ m/^bio/) {
1061                                            $row->{LOAD}->[0] = $newBiomass;
1062                                    }
1063                            }
1064                            $rxnTbl->save();
1065                            #Changing the biomass reaction in the database
1066                            return  $self->{_data}->biomassReaction($newBiomass);
1067                    }
1068            }
1069  }  }
1070    
1071  =head3 taxonomy  =head3 taxonomy
# Line 1157  Line 1190 
1190          $self->{_data}->modificationDate(time());          $self->{_data}->modificationDate(time());
1191          my $version = $self->{_data}->autocompleteVersion();          my $version = $self->{_data}->autocompleteVersion();
1192          $self->{_data}->autocompleteVersion($version+1);          $self->{_data}->autocompleteVersion($version+1);
1193            $self->update_model_stats();
1194  }  }
1195    
1196  =head3 update_stats_for_build  =head3 update_stats_for_build
# Line 1306  Line 1340 
1340          }          }
1341    
1342          #Calling the MFAToolkit to run the gap filling optimization          #Calling the MFAToolkit to run the gap filling optimization
1343          my $MinimalMediaTable = $self->figmodel()->database()->GetDBTable("MINIMAL MEDIA TABLE");          my $Media = $self->autocompleteMedia();
1344          my $Media = "Complete";          if ($Media eq "Complete") {
1345          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));
1346                  $Media = $MinimalMediaTable->get_row_by_key($self->genome(),"Organism")->{"Minimal media"}->[0];          } else {
1347                  #Loading media, changing bounds, saving media as a test media                  #Loading media, changing bounds, saving media as a test media
1348                  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"]);
1349                  for (my $i=0; $i < $MediaTable->size(); $i++) {                  for (my $i=0; $i < $MediaTable->size(); $i++) {
# Line 1324  Line 1358 
1358                  #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";
1359                  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));
1360                  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));  
1361          }          }
1362    
1363          #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 1370 
1370                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");                  $self->figmodel()->error_message("FIGMODEL:GapFillModel: Gap filling report not found!");
1371                  return $self->fail();                  return $self->fail();
1372          }          }
         $SolutionData->save("/home/chenry/Solution.txt");  
1373    
1374          #Looking for the last printed recursive MILP solution          #Looking for the last printed recursive MILP solution
1375          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.23

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3