[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.6, Thu Aug 27 19:52:40 2009 UTC revision 1.11, Fri Jun 18 20:05:33 2010 UTC
# 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 IsModeledBy); # Encompasses);      my @tables = sort qw(StructuralCue IsFoundIn Compound HasAliasOf AliasType
63                             HasReactionAliasOf Reaction Involves IsTriggeredBy
64                             RoleSet IsCombinationOf IsCategorizedInto EcNumber
65                             IsConsistentWith IsStimulatedBy  FeatureSet IsSetOf
66                             IsRequiredBy Model IsModeledBy ModelUser); # Encompasses);
67      # Create the BaseSaplingLoader object.      # Create the BaseSaplingLoader object.
68      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);
69      # Return it.      # Return it.
# Line 145  Line 149 
149      my ($self,$model) = @_;      my ($self,$model) = @_;
150    
151      #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
152      my $CompoundTable = $model->GetDBTable("COMPOUNDS");      my $CompoundTable = $model->database()->GetDBTable("COMPOUNDS");
153    
154      #Adding the universal AliasType that will always exist      #Adding the universal AliasType that will always exist
155      $self->PutE(AliasType => "NAME", source => "NONE");      $self->PutE(AliasType => "NAME", source => "NONE");
# Line 230  Line 234 
234  sub LoadReactions {  sub LoadReactions {
235      my ($self,$model) = @_;      my ($self,$model) = @_;
236      #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
237      my $ReactionTable = $model->GetDBTable("REACTIONS");      my $ReactionTable = $model->database()->GetDBTable("REACTIONS");
238    
239      #Cycling through the compound list and adding each individual compound entity      #Cycling through the compound list and adding each individual compound entity
240      my $Count = 0;      my $Count = 0;
# Line 337  Line 341 
341  sub LoadRoleSets {  sub LoadRoleSets {
342      my ($self,$model) = @_;      my ($self,$model) = @_;
343      my $sapling =$self->db();      my $sapling =$self->db();
344      my $RoleMappings = $model->GetDBTable("CURATED ROLE MAPPINGS");      my $RoleMappings = $model->database()->GetDBTable("CURATED ROLE MAPPINGS");
345      my $NewSet;      my $NewSet;
346      my $SetHash;      my $SetHash;
347      my $LastComplex = -1;      my $LastComplex = -1;
# Line 391  Line 395 
395          $self->PutE(RoleSet => $Digested, source => "NONE");          $self->PutE(RoleSet => $Digested, source => "NONE");
396          my @ReactionList = keys(%{$SetHash->{$RoleSet}->{"REACTIONS"}});          my @ReactionList = keys(%{$SetHash->{$RoleSet}->{"REACTIONS"}});
397          foreach my $Reaction (@ReactionList) {          foreach my $Reaction (@ReactionList) {
398              $self->PutR(IsTriggeredBy => $Reaction,$Digested, source => "NONE",master => $SetHash->{$RoleSet}->{"REACTIONS"}->{$Reaction}->{"MASTER"}->[0],subsystem => join(";",@{$SetHash->{$RoleSet}->{"REACTIONS"}->{$Reaction}->{"SUBSYSTEMS"}}));              $self->PutR(IsTriggeredBy => $Reaction,$Digested, source => "NONE",master => ($SetHash->{$RoleSet}->{"REACTIONS"}->{$Reaction}->{"MASTER"}->[0] ? 1 : 0),subsystem => join(";",@{$SetHash->{$RoleSet}->{"REACTIONS"}->{$Reaction}->{"SUBSYSTEMS"}}));
399          }          }
400          my @RoleList = keys(%{$SetHash->{$RoleSet}->{"ROLES"}});          my @RoleList = keys(%{$SetHash->{$RoleSet}->{"ROLES"}});
401          foreach my $Role (@RoleList) {          foreach my $Role (@RoleList) {
# Line 405  Line 409 
409      my $sapling = $self->db();      my $sapling = $self->db();
410      ## TRS: Get hash of valid genome IDs.      ## TRS: Get hash of valid genome IDs.
411      my $genomeHash = $sapling->GenomeHash();      my $genomeHash = $sapling->GenomeHash();
412      my $ModelList = $model->GetDBTable("MODEL LIST");      my $ModelList = $model->database()->GetDBTable("MODELS");
413      my $ModelStats = $model->GetDBTable("MODEL STATS");      my $ModelStats = $model->database()->GetDBTable("MODEL STATS");
414      for (my $i=0; $i < $ModelStats->size(); $i++) {      for (my $i=0; $i < $ModelList->size(); $i++) {
415          my $Row = $ModelStats->get_row($i);          my $ListRow = $ModelList->get_row($i);
416            my $Row = $ModelStats->get_row_by_key($ListRow->{id}->[0], "Model ID");
417          if (defined($Row) && defined($Row->{"Model ID"}->[0])) {          if (defined($Row) && defined($Row->{"Model ID"}->[0])) {
418              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,"",0,0,"master",0,-1,"");
419              if (defined($Row->{"Genome ID"}->[0]) && $genomeHash->{$Row->{"Genome ID"}->[0]}) {              if (defined($Row->{"Genome ID"}->[0]) && $genomeHash->{$Row->{"Genome ID"}->[0]}) {
420                  if (defined($Row->{"Organism name"}->[0])) {                  if (defined($Row->{"Organism name"}->[0])) {
421                      $LoadingArray[1] = $Row->{"Organism name"}->[0];                      $LoadingArray[1] = $Row->{"Organism name"}->[0];
# Line 467  Line 472 
472                      $LoadingArray[18] = $Row->{"Gap filling minimal objective"}->[0];                      $LoadingArray[18] = $Row->{"Gap filling minimal objective"}->[0];
473                  }                  }
474                  if (defined($Row->{"Build date"}->[0])) {                  if (defined($Row->{"Build date"}->[0])) {
475                      $LoadingArray[19] = $Row->{"Build date"}->[0];                      $LoadingArray[19] = FixDate($Row->{"Build date"}->[0]);
476                  }                  }
477                  if (defined($Row->{"Gap fill date"}->[0])) {                  if (defined($Row->{"Gap fill date"}->[0])) {
478                      $LoadingArray[20] = $Row->{"Gap fill date"}->[0];                      $LoadingArray[20] = FixDate($Row->{"Gap fill date"}->[0]);
479                  }                  }
480                  if (defined($Row->{"Version"}->[0])) {                  if (defined($Row->{"Version"}->[0])) {
481                      $LoadingArray[21] = $Row->{"Version"}->[0];                      $LoadingArray[21] = $Row->{"Version"}->[0];
# Line 478  Line 483 
483                  if (defined($Row->{"Gap fill version"}->[0])) {                  if (defined($Row->{"Gap fill version"}->[0])) {
484                      $LoadingArray[22] = $Row->{"Gap fill version"}->[0];                      $LoadingArray[22] = $Row->{"Gap fill version"}->[0];
485                  }                  }
486                    $LoadingArray[26] = $ListRow->{"owner"}->[0];
487                    $LoadingArray[27] = $ListRow->{"date"}->[0];
488                    $LoadingArray[28] = $ListRow->{"status"}->[0];
489                    $LoadingArray[29] = $ListRow->{"message"}->[0];
490                  if ($Row->{"Model ID"}->[0] =~ m/Core\d+\.\d+V\d+\.\d+/) {                  if ($Row->{"Model ID"}->[0] =~ m/Core\d+\.\d+V\d+\.\d+/) {
491                      $LoadingArray[25] = 1;                      $LoadingArray[25] = 1;
492                  } elsif (defined($ModelList->get_row_by_key($Row->{"Model ID"}->[0],"MODEL ID"))) {                  } elsif (defined($ModelList->get_row_by_key($Row->{"Model ID"}->[0],"MODEL ID"))) {
# Line 488  Line 497 
497                          $LoadingArray[24] = $ModelList->get_row_by_key($Row->{"Model ID"}->[0],"MODEL ID")->{"JOB ID"}->[0];                          $LoadingArray[24] = $ModelList->get_row_by_key($Row->{"Model ID"}->[0],"MODEL ID")->{"JOB ID"}->[0];
498                      }                      }
499                  }                  }
500                  for my $j (3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,21,22,24,25) {                  for my $j (3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,21,22,24,25,27,28) {
501                      $LoadingArray[$j] = 0 if ($LoadingArray[$j] =~ /[a-z]/i);                      $LoadingArray[$j] = 0 if ($LoadingArray[$j] =~ /[a-z]/i);
502                  }                  }
503                  $self->PutE(Model => $LoadingArray[0], organismName => $LoadingArray[1], source => $LoadingArray[2], totalGenes => $LoadingArray[3], gramPositiveGenes => $LoadingArray[4],gramNegativeGenes => $LoadingArray[5], class => $LoadingArray[6], genesWithFunction => $LoadingArray[7], genesWithReactions => $LoadingArray[8], subsystemGenes => $LoadingArray[9], subsystemGenesWithReactions => $LoadingArray[10], nonsubsystemGenes => $LoadingArray[11], nonsubsystemGenesWithReactions => $LoadingArray[12], numberOfReactions => $LoadingArray[13], numberOfTransporters => $LoadingArray[14], gapFillingReactions => $LoadingArray[15], gapFillingTime => $LoadingArray[16], gapFillingObjective => $LoadingArray[17], gapFillingMinimalObjective => $LoadingArray[18], buildDate => $LoadingArray[19], gapFillDate => $LoadingArray[20], version => $LoadingArray[21], gapFillVersion => $LoadingArray[22], directory => $LoadingArray[23], jobid => $LoadingArray[24], obsolete => $LoadingArray[25]);                  $self->PutE(Model => $LoadingArray[0], organismName => $LoadingArray[1], source => $LoadingArray[2], totalGenes => $LoadingArray[3], gramPositiveGenes => $LoadingArray[4],gramNegativeGenes => $LoadingArray[5], class => $LoadingArray[6], genesWithFunction => $LoadingArray[7], genesWithReactions => $LoadingArray[8], subsystemGenes => $LoadingArray[9], subsystemGenesWithReactions => $LoadingArray[10], nonsubsystemGenes => $LoadingArray[11], nonsubsystemGenesWithReactions => $LoadingArray[12], numberOfReactions => $LoadingArray[13], numberOfTransporters => $LoadingArray[14], gapFillingReactions => $LoadingArray[15], gapFillingTime => $LoadingArray[16], gapFillingObjective => $LoadingArray[17], gapFillingMinimalObjective => $LoadingArray[18], buildDate => $LoadingArray[19], gapFillDate => $LoadingArray[20], version => $LoadingArray[21], gapFillVersion => $LoadingArray[22], directory => $LoadingArray[23], jobid => $LoadingArray[24], obsolete => $LoadingArray[25], owner => $LoadingArray[26], modificationTime => $LoadingArray[27], status => $LoadingArray[28], message => $LoadingArray[29]);
504                    # Get the list of users.
505                    my $userList = $ListRow->{"users"};
506                    if (defined $userList) {
507                        for my $user (@$userList) {
508                            $self->PutE(ModelUser => $LoadingArray[0], users => $user);
509                        }
510                    }
511                  #Adding the relationship between model and genome                  #Adding the relationship between model and genome
512                  if (defined($Row->{"Genome ID"}->[0])) {                  if (defined($Row->{"Genome ID"}->[0])) {
513                      $self->PutR(IsModeledBy => $Row->{"Genome ID"}->[0],$LoadingArray[0]);                      $self->PutR(IsModeledBy => $Row->{"Genome ID"}->[0],$LoadingArray[0]);
# Line 499  Line 515 
515                  #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
516                  if ($LoadingArray[25] == 0) {                  if ($LoadingArray[25] == 0) {
517                      #Loading the model from file                      #Loading the model from file
518                      my $ModelTable = $model->GetDBModel($LoadingArray[0]);                      my $ModelTable = $model->database()->GetDBModel($LoadingArray[0]);
519                        if (! defined $ModelTable) {
520                            $self->Add(missingModelTable => 1);
521                        } else {
522                      for (my $j=0; $j < $ModelTable->size(); $j++) {                      for (my $j=0; $j < $ModelTable->size(); $j++) {
523                          my $RxnRow = $ModelTable->get_row($j);                          my $RxnRow = $ModelTable->get_row($j);
524                          if (defined($RxnRow) && defined($RxnRow->{"LOAD"}->[0])) {                          if (defined($RxnRow) && defined($RxnRow->{"LOAD"}->[0])) {
# Line 553  Line 572 
572                              $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]);
573                          }                          }
574                      }                      }
575                        }
576                      #Clearing the model data from memmory                      #Clearing the model data from memmory
577                      undef $ModelTable;                      undef $ModelTable;
578                      $model->ClearDBModel($LoadingArray[0],"DELETE");                      $model->database()->ClearDBModel($LoadingArray[0],"DELETE");
579                  }                  }
580              }              }
581          }          }
582      }      }
583  }  }
584    
585    sub FixDate {
586        my ($date) = @_;
587        my $retVal = ($date eq 'NA' ? 0 : $date);
588        return $retVal;
589    }
590    
591  1;  1;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3