[Bio] / Sprout / ModelSaplingLoader.pm Repository:
ViewVC logotype

Diff of /Sprout/ModelSaplingLoader.pm

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

revision 1.1, Wed Mar 4 00:08:30 2009 UTC revision 1.8, Mon Feb 1 20:14:28 2010 UTC
# Line 41  Line 41 
41    
42  =item erdb  =item erdb
43    
44  [[SaplingPm]] object for the database being loaded.  L<Sapling> object for the database being loaded.
45    
46  =item options  =item options
47    
# Line 59  Line 59 
59      # Get the parameters.      # Get the parameters.
60      my ($class, $erdb, $options) = @_;      my ($class, $erdb, $options) = @_;
61      # Create the table list.      # Create the table list.
62      my @tables = sort qw(StructuralCue IsFoundIn Compound HasAliasOf AliasType HasReactionAliasOf Reaction Involves IsTriggeredBy RoleSet IsCombinationOf IsCategorizedInto EcNumber IsConsistentWith IsStimulatedBy  FeatureSet IsSetOf IsRequiredBy Model Encompasses IsModeledBy);      my @tables = sort qw(StructuralCue IsFoundIn Compound HasAliasOf AliasType HasReactionAliasOf Reaction Involves IsTriggeredBy RoleSet IsCombinationOf IsCategorizedInto EcNumber IsConsistentWith IsStimulatedBy  FeatureSet IsSetOf IsRequiredBy Model IsModeledBy); # Encompasses);
63      # Create the BaseSaplingLoader object.      # Create the BaseSaplingLoader object.
64      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);
65      # Return it.      # Return it.
# Line 145  Line 145 
145      my ($self,$model) = @_;      my ($self,$model) = @_;
146    
147      #First getting the compound table which has a list of all compounds in the database as well as alot of compound information      #First getting the compound table which has a list of all compounds in the database as well as alot of compound information
148      my $CompoundTable = $model->GetDBTable("COMPOUNDS");      my $CompoundTable = $model->database()->GetDBTable("COMPOUNDS");
149    
150      #Adding the universal AliasType that will always exist      #Adding the universal AliasType that will always exist
151      $self->PutE(AliasType => "NAME", source => "NONE");      $self->PutE(AliasType => "NAME", source => "NONE");
# Line 159  Line 159 
159          if (defined($Row) && defined($Row->{"DATABASE"}->[0]) && $Row->{"DATABASE"}->[0] =~ m/cpd\d\d\d\d\d/) {          if (defined($Row) && defined($Row->{"DATABASE"}->[0]) && $Row->{"DATABASE"}->[0] =~ m/cpd\d\d\d\d\d/) {
160              my $Object = FIGMODELObject->load($model->{"compound directory"}->[0].$Row->{"DATABASE"}->[0],"\t");              my $Object = FIGMODELObject->load($model->{"compound directory"}->[0].$Row->{"DATABASE"}->[0],"\t");
161              my @LoadingArray = ($Row->{"DATABASE"}->[0],$Row->{"DATABASE"}->[0],0,"",0,"",0,10000000,10000000,"");              my @LoadingArray = ($Row->{"DATABASE"}->[0],$Row->{"DATABASE"}->[0],0,"",0,"",0,10000000,10000000,"");
162                $self->Track(compoundRow => $LoadingArray[0], 1000);
163              if (defined($Row->{"NAME"}->[0])) {              if (defined($Row->{"NAME"}->[0])) {
164                  $LoadingArray[1] = $Row->{"NAME"}->[0];                  $LoadingArray[1] = $Row->{"NAME"}->[0];
165              }              }
# Line 229  Line 230 
230  sub LoadReactions {  sub LoadReactions {
231      my ($self,$model) = @_;      my ($self,$model) = @_;
232      #First getting the reaction table which has a list of all reactions in the database as well as alot of reaction information      #First getting the reaction table which has a list of all reactions in the database as well as alot of reaction information
233      my $ReactionTable = $model->GetDBTable("REACTIONS");      my $ReactionTable = $model->database()->GetDBTable("REACTIONS");
234    
235      #Cycling through the compound list and adding each individual compound entity      #Cycling through the compound list and adding each individual compound entity
236      my $Count = 0;      my $Count = 0;
# Line 238  Line 239 
239          if (defined($Row) && defined($Row->{"DATABASE"}->[0]) && $Row->{"DATABASE"}->[0] =~ m/rxn\d\d\d\d\d/) {          if (defined($Row) && defined($Row->{"DATABASE"}->[0]) && $Row->{"DATABASE"}->[0] =~ m/rxn\d\d\d\d\d/) {
240              my $Object = FIGMODELObject->load($model->{"reaction directory"}->[0].$Row->{"DATABASE"}->[0],"\t");              my $Object = FIGMODELObject->load($model->{"reaction directory"}->[0].$Row->{"DATABASE"}->[0],"\t");
241              my @LoadingArray = ($Row->{"DATABASE"}->[0],"","","","","",10000000,10000000,10000000,"R");              my @LoadingArray = ($Row->{"DATABASE"}->[0],"","","","","",10000000,10000000,10000000,"R");
242                $self->Track(reactionRow => $LoadingArray[0], 1000);
243              if (defined($Object->{"DEFINITION"}->[0])) {              if (defined($Object->{"DEFINITION"}->[0])) {
244                  $LoadingArray[1] = $Object->{"DEFINITION"}->[0];                  $LoadingArray[1] = $Object->{"DEFINITION"}->[0];
245              }              }
# Line 276  Line 278 
278              $self->PutE(Reaction => $LoadingArray[0], definition => $LoadingArray[1], code => $LoadingArray[2], operator => $LoadingArray[3], pathway => $LoadingArray[4],keggMap => $LoadingArray[5], deltaG => $LoadingArray[6], MMdeltaG => $LoadingArray[7], deltaGerr => $LoadingArray[8], predictedReversibility => $LoadingArray[9]);              $self->PutE(Reaction => $LoadingArray[0], definition => $LoadingArray[1], code => $LoadingArray[2], operator => $LoadingArray[3], pathway => $LoadingArray[4],keggMap => $LoadingArray[5], deltaG => $LoadingArray[6], MMdeltaG => $LoadingArray[7], deltaGerr => $LoadingArray[8], predictedReversibility => $LoadingArray[9]);
279              #Adding relationship between compounds and reactions              #Adding relationship between compounds and reactions
280              my ($Reactants,$Products) = $model->GetReactionSubstrateData($LoadingArray[0]);              my ($Reactants,$Products) = $model->GetReactionSubstrateData($LoadingArray[0]);
281                if (! defined $Reactants) {
282                    $self->Add(missingReactants => 1);
283                } else {
284              for (my $j=0; $j < @{$Reactants}; $j++) {              for (my $j=0; $j < @{$Reactants}; $j++) {
285                  $self->PutR(Involves => $LoadingArray[0],$Reactants->[$j]->{"DATABASE"}->[0],product => 0,stoichiometry => $Reactants->[$j]->{"COEFFICIENT"}->[0],main => 1,compartment => $Reactants->[$j]->{"COMPARTMENT"}->[0],discriminator => $Count);                  $self->PutR(Involves => $LoadingArray[0],$Reactants->[$j]->{"DATABASE"}->[0],product => 0,stoichiometry => $Reactants->[$j]->{"COEFFICIENT"}->[0],main => 1,compartment => $Reactants->[$j]->{"COMPARTMENT"}->[0],discriminator => $Count);
286                  #TODO:Properly identify main reactants in reactions                  #TODO:Properly identify main reactants in reactions
287                  $Count++;                  $Count++;
288              }              }
289                }
290                if (! defined $Products) {
291                    $self->Add(missingProducts => 1);
292                } else {
293              for (my $j=0; $j < @{$Products}; $j++) {              for (my $j=0; $j < @{$Products}; $j++) {
294                  $self->PutR(Involves => $LoadingArray[0],$Products->[$j]->{"DATABASE"}->[0],product => 1,stoichiometry => $Products->[$j]->{"COEFFICIENT"}->[0],main => 1,compartment => $Products->[$j]->{"COMPARTMENT"}->[0],discriminator => $Count);                  $self->PutR(Involves => $LoadingArray[0],$Products->[$j]->{"DATABASE"}->[0],product => 1,stoichiometry => $Products->[$j]->{"COEFFICIENT"}->[0],main => 1,compartment => $Products->[$j]->{"COMPARTMENT"}->[0],discriminator => $Count);
295                  #TODO:Properly identify main reactants in reactions                  #TODO:Properly identify main reactants in reactions
296                  $Count++;                  $Count++;
297              }              }
298                }
299              #Adding relationship between EC number and reactions              #Adding relationship between EC number and reactions
300              if (defined($Object->{"ENZYME"})) {              if (defined($Object->{"ENZYME"})) {
301                  foreach my $Enzyme (@{$Object->{"ENZYME"}}) {                  foreach my $Enzyme (@{$Object->{"ENZYME"}}) {
302                     $self->PutE(EcNumber => $Enzyme, obselete => 0, replacedby => "NONE");                     if ($Enzyme =~ /,/) {
303                        #TODO:Invalid enzyme
304                       } else {
305                        $Enzyme =~ s/\s//g;
306                        $self->PutE(EcNumber => $Enzyme, obsolete => 0, replacedby => "NONE");
307                     $self->PutR(IsCategorizedInto => $LoadingArray[0],$Enzyme,source => "KEGG");                     $self->PutR(IsCategorizedInto => $LoadingArray[0],$Enzyme,source => "KEGG");
308                  }                  }
309              }              }
310                }
311              #Adding the relationship between reaction and alias type              #Adding the relationship between reaction and alias type
312              if (defined($Object->{"NAME"})) {              if (defined($Object->{"NAME"})) {
313                  foreach my $Name (@{$Object->{"NAME"}}) {                  foreach my $Name (@{$Object->{"NAME"}}) {
# Line 322  Line 337 
337  sub LoadRoleSets {  sub LoadRoleSets {
338      my ($self,$model) = @_;      my ($self,$model) = @_;
339      my $sapling =$self->db();      my $sapling =$self->db();
340      my $RoleMappings = $model->GetDBTable("CURATED ROLE MAPPINGS");      my $RoleMappings = $model->database()->GetDBTable("CURATED ROLE MAPPINGS");
341      my $NewSet;      my $NewSet;
342      my $SetHash;      my $SetHash;
343      my $LastComplex = -1;      my $LastComplex = -1;
# Line 388  Line 403 
403  sub LoadModels {  sub LoadModels {
404      my ($self,$model) = @_;      my ($self,$model) = @_;
405      my $sapling = $self->db();      my $sapling = $self->db();
406      my $ModelList = $model->GetDBTable("MODEL LIST");      ## TRS: Get hash of valid genome IDs.
407      my $ModelStats = $model->GetDBTable("MODEL STATS");      my $genomeHash = $sapling->GenomeHash();
408        my $ModelList = $model->database()->GetDBTable("MODEL LIST");
409        my $ModelStats = $model->database()->GetDBTable("MODEL STATS");
410      for (my $i=0; $i < $ModelStats->size(); $i++) {      for (my $i=0; $i < $ModelStats->size(); $i++) {
411          my $Row = $ModelStats->get_row($i);          my $Row = $ModelStats->get_row($i);
412          if (defined($Row) && defined($Row->{"Model ID"}->[0])) {          if (defined($Row) && defined($Row->{"Model ID"}->[0])) {
413              my @LoadingArray = ($Row->{"Model ID"}->[0],"","",0,0,0,"",0,0,0,0,0,0,0,0,0,0,0,0,"","",0,0,"",0,0);              my @LoadingArray = ($Row->{"Model ID"}->[0],"","",0,0,0,"",0,0,0,0,0,0,0,0,0,0,0,0,"","",0,0,"",0,0);
414                if (defined($Row->{"Genome ID"}->[0]) && $genomeHash->{$Row->{"Genome ID"}->[0]}) {
415              if (defined($Row->{"Organism name"}->[0])) {              if (defined($Row->{"Organism name"}->[0])) {
416                  $LoadingArray[1] = $Row->{"Organism name"}->[0];                  $LoadingArray[1] = $Row->{"Organism name"}->[0];
417              }              }
# Line 481  Line 499 
499              #If the model is not obsolete, we add the relationships between model and reaction and featureset              #If the model is not obsolete, we add the relationships between model and reaction and featureset
500              if ($LoadingArray[25] == 0) {              if ($LoadingArray[25] == 0) {
501                  #Loading the model from file                  #Loading the model from file
502                  my $ModelTable = $model->GetDBModel($LoadingArray[0]);                      my $ModelTable = $model->database()->GetDBModel($LoadingArray[0]);
503                        if (! defined $ModelTable) {
504                            $self->Add(missingModelTable => 1);
505                        } else {
506                  for (my $j=0; $j < $ModelTable->size(); $j++) {                  for (my $j=0; $j < $ModelTable->size(); $j++) {
507                      my $RxnRow = $ModelTable->get_row($j);                      my $RxnRow = $ModelTable->get_row($j);
508                      if (defined($RxnRow) && defined($RxnRow->{"LOAD"}->[0])) {                      if (defined($RxnRow) && defined($RxnRow->{"LOAD"}->[0])) {
# Line 520  Line 541 
541                                      #Adding the relationship between the reaction and roleset                                      #Adding the relationship between the reaction and roleset
542                                      $self->PutR(IsStimulatedBy => $RxnRow->{"LOAD"}->[0],$DigestedKey);                                      $self->PutR(IsStimulatedBy => $RxnRow->{"LOAD"}->[0],$DigestedKey);
543                                      #Adding the relationship between the model and featureset                                      #Adding the relationship between the model and featureset
544                                      $self->PutR(Encompasses => $LoadingArray[0],$DigestedKey);                                              #$self->PutR(Encompasses => $LoadingArray[0],$DigestedKey);
545                                      #Adding the relationship between FeatureSet and feature                                      #Adding the relationship between FeatureSet and feature
546                                      my @PegArray = split(/\+/,$FeatureSet);                                      my @PegArray = split(/\+/,$FeatureSet);
547                                      foreach my $Feature (@PegArray) {                                      foreach my $Feature (@PegArray) {
# Line 535  Line 556 
556                          $self->PutR(IsRequiredBy => $RxnRow->{"LOAD"}->[0],$LoadingArray[0], direction => $SubLoadingArray[0], compartment => $SubLoadingArray[1], confidence => $SubLoadingArray[3], class => $SubLoadingArray[4], notes => $SubLoadingArray[5], dependency => $SubLoadingArray[6]);                          $self->PutR(IsRequiredBy => $RxnRow->{"LOAD"}->[0],$LoadingArray[0], direction => $SubLoadingArray[0], compartment => $SubLoadingArray[1], confidence => $SubLoadingArray[3], class => $SubLoadingArray[4], notes => $SubLoadingArray[5], dependency => $SubLoadingArray[6]);
557                      }                      }
558                  }                  }
559                        }
560                  #Clearing the model data from memmory                  #Clearing the model data from memmory
561                  undef $ModelTable;                  undef $ModelTable;
562                  $model->ClearDBModel($LoadingArray[0],"DELETE");                  $model->ClearDBModel($LoadingArray[0],"DELETE");
# Line 542  Line 564 
564          }          }
565      }      }
566  }  }
567    }
568    
569  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3