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

Diff of /Sprout/SproutSubsys.pm

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

revision 1.18, Tue Sep 9 21:02:10 2008 UTC revision 1.19, Tue Sep 16 18:45:06 2008 UTC
# Line 138  Line 138 
138                                      'OccursInSubsystem(to-link) = ? ORDER BY OccursInSubsystem(column-number)',                                      'OccursInSubsystem(to-link) = ? ORDER BY OccursInSubsystem(column-number)',
139                                      [$subName], ['OccursInSubsystem(from-link)', 'OccursInSubsystem(abbr)',                                      [$subName], ['OccursInSubsystem(from-link)', 'OccursInSubsystem(abbr)',
140                                                   'OccursInSubsystem(auxiliary)']);                                                   'OccursInSubsystem(auxiliary)']);
141          # Now we need to create the role ID directory and the reaction hash.          # Now we need to create the role ID directory, which maps role IDs and their
142          # The role ID directory maps role IDs and their abbreviations to column numbers.          # abbreviations to column numbers.
         # The reaction hash maps a role ID to a list of the IDs for the reactions it  
         # catalyzes.  
143          my %roleHash = ();          my %roleHash = ();
144          my %abbrHash = ();          my %abbrHash = ();
145          my %auxHash = ();          my %auxHash = ();
         my %reactionHash = ();  
146          for ($idx = 0; $idx <= $#roles; $idx++) {          for ($idx = 0; $idx <= $#roles; $idx++) {
147              # Get the role ID, aux flag, and abbreviation for this column's role.              # Get the role ID, aux flag, and abbreviation for this column's role.
148              my ($roleID, $abbr, $aux) = @{$roles[$idx]};              my ($roleID, $abbr, $aux) = @{$roles[$idx]};
# Line 156  Line 153 
153              $auxHash{$roleID} = $aux;              $auxHash{$roleID} = $aux;
154              # Put the full name in the abbreviation directory.              # Put the full name in the abbreviation directory.
155              $abbrHash{$abbr} = $roleID;              $abbrHash{$abbr} = $roleID;
             # Get this role's reactions.  
             my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',  
                                              [$roleID], 'Catalyzes(to-link)');  
             # Put them in the reaction hash.  
             if (@reactions > 0) {  
                 $reactionHash{$roleID} = \@reactions;  
             }  
156          }          }
157          # Find the subsystem directory.          # Find the subsystem directory.
158          my $subDir = Subsystem::get_dir_from_name($subName);          my $subDir = Subsystem::get_dir_from_name($subName);
# Line 195  Line 185 
185                      # Map of auxiliary rols.                      # Map of auxiliary rols.
186                      auxHash => \%auxHash,                      auxHash => \%auxHash,
187                      # Map of role IDs to reactions.                      # Map of role IDs to reactions.
188                      reactionHash => \%reactionHash,                      reactionHash => undef,
189                      # Version number.                      # Version number.
190                      version => $version,                      version => $version,
191                  };                  };
# Line 521  Line 511 
511  sub get_reactions {  sub get_reactions {
512      # Get the parameters.      # Get the parameters.
513      my ($self) = @_;      my ($self) = @_;
514      # Return the reaction hash member.      # Do we already have a reaction hash?
515      return $self->{reactionHash};      my $retVal = $self->{reactionHash};
516        if (! $retVal) {
517            # No, so we'll build it.
518            $retVal = {};
519            my $sprout = $self->{sprout};
520            for my $roleID ($self->get_roles()) {
521                # Get this role's reactions.
522                my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',
523                                                 [$roleID], 'Catalyzes(to-link)');
524                # Put them in the reaction hash.
525                if (@reactions > 0) {
526                    $retVal->{$roleID} = \@reactions;
527                }
528            }
529            # Save it for future use.
530            $self->{reactionHash} = $retVal;
531        }
532        # Return the reaction hash.
533        return $retVal;
534  }  }
535    
536  =head3 get_subset_namesC  =head3 get_subset_namesC
# Line 613  Line 621 
621  =item RETURN  =item RETURN
622    
623  Returns a hash mapping reactions in the subsystem to pegs in the  Returns a hash mapping reactions in the subsystem to pegs in the
624  specified genome, or C<undef> if the genome is not found in the  specified genome, or an empty hash if the genome is not found in the
625  subsystem.  subsystem.
626    
627  =back  =back
# Line 621  Line 629 
629  =cut  =cut
630    
631  sub get_hope_reactions_for_genome {  sub get_hope_reactions_for_genome {
632      ##TODO      # Get the parameters.
633      my($self, $genome) = @_;      my($self, $genome) = @_;
634      my $index = $self->{genome_index}->{$genome};      # Declare the return variable.
635        my %retVal;
636        # Look for the genome in our spreadsheet.
637        my $index = $self->get_genome_index($genome);
638        # Only proceed if we found it.
639      if (defined $index) {      if (defined $index) {
640            # Extract the roles.
641          my @roles = $self->get_roles;          my @roles = $self->get_roles;
642          my %hope_reactions = $self->get_hope_reactions;          # Get the hope reaction hash. For each role, this gives us a list
643            # of reactions.
644          my %ss_reactions;          my %hope_reactions = $self->get_hope_reactions();
645            # Loop through the cells in this genome's role.
646          foreach my $role (@roles)          for my $role (@roles) {
647          {              # Get the features in this role's cell.
648              my @peg_list = $self->get_pegs_from_cell($genome,$role);              my @peg_list = $self->get_pegs_from_cell($genome,$role);
649                # Only proceed if we have hope reactions AND pegs for this role.
650              if (defined $hope_reactions{$role} && scalar @peg_list > 0)              if (defined $hope_reactions{$role} && scalar @peg_list > 0) {
651                    # Loop through the reactions, pushing the pegs in this cell onto
652              {                  # the reaction's peg list.
653                  foreach my $reaction (@{$hope_reactions{$role}})                  for my $reaction (@{$hope_reactions{$role}}) {
654                  {                      push @{$retVal{$reaction}}, @peg_list;
                     push @{$ss_reactions{$reaction}}, @peg_list;  
655                  }                  }
656              }              }
657          }          }
   
         return %ss_reactions;  
     }  
     else {  
         return undef;  
658      }      }
659        # Return the result.
660        return %retVal;
661  }  }
662    
663    
# Line 672  Line 681 
681    
682  =cut  =cut
683    
684  sub get_hope_additional_reactions  sub get_hope_additional_reactions {
685  {      # Get the parameters.
686      my($self,$scenario_name) = @_;      my($self,$scenario_name) = @_;
687      Trace("Hope additional reactions not available in NMPDR.") if T(0);  ##HACK      # Ask the database for this scenario's additional reactions.
688      my @retVal;      my @retVal = $self->{sprout}->GetFlat(['IncludesReaction'], "IncludesReaction(from-link) = ?",
689                                              [$scenario_name], 'IncludesReaction(to-link)');
690      return @retVal;      return @retVal;
691  }  }
692    
# Line 697  Line 707 
707      # Try to get the hope reactions from the object.      # Try to get the hope reactions from the object.
708      my $retVal = $self->{hopeReactions};      my $retVal = $self->{hopeReactions};
709      if (! defined($retVal)) {      if (! defined($retVal)) {
710          # They do not exist, so we must create them.          # They do not exist, so we must create them. Make a copy of the role-to-reaction
711          $retVal = FIGRules::GetHopeReactions($self, $self->{dir}); ##HACK          # hash.
712            my %hopeHash = %{$self->get_reactions()};
713          # Insure we have it if we need it again.          # Insure we have it if we need it again.
714            $retVal = \%hopeHash;
715          $self->{hopeReactions} = $retVal;          $self->{hopeReactions} = $retVal;
716      }      }
717      # Return the result.      # Return the result.
# Line 720  Line 732 
732      my ($self) = @_;      my ($self) = @_;
733      # Declare the return variable.      # Declare the return variable.
734      my %retVal;      my %retVal;
735      ##TODO: Code      # Get the database object.
736        my $sprout = $self->{sprout};
737        # Get our name.
738        my $ssName = $self->{name};
739        # Loop through the roles, getting each role's hope notes.
740        for my $role ($self->get_roles()) {
741            my ($note) = $self->get_hop_reaction_note($role);
742            # If this role had a nonempty note, stuff it in the hash.
743            if ($note) {
744                $retVal{$role} = $note;
745            }
746        }
747      # Return the result.      # Return the result.
748      return %retVal;      return %retVal;
749  }  }
# Line 736  Line 759 
759    
760  =item role  =item role
761    
762  ##TODO: role description  ID of the role whose note is desired.
763    
764  =item RETURN  =item RETURN
765    
766  ##TODO: return value description  Returns the relevant role's note for this subsystem's hope reactions, or FALSE (empty string
767    or undefined) if no such note was found.
768    
769  =back  =back
770    
# Line 749  Line 773 
773  sub get_hope_reaction_note {  sub get_hope_reaction_note {
774      # Get the parameters.      # Get the parameters.
775      my ($self, $role) = @_;      my ($self, $role) = @_;
776      # Declare the return variable.      # Ask the database for the note.
777      my $retVal;      my ($retVal) = $self->{sprout}->GetFlat(['OccursInSubsystem'],
778      ##TODO: Code                                              "OccursInSubsystem(from-link) = ? AND OccursInSubsystem(to-link) = ?",
779                                                [$role, $self->{name}], 'OccursInSubsystem(hope-reaction-note)');
780      # Return the result.      # Return the result.
781      return $retVal;      return $retVal;
782  }  }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3