[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.14, Tue Apr 29 20:56:39 2008 UTC revision 1.18, Tue Sep 9 21:02:10 2008 UTC
# Line 84  Line 84 
84    
85  =head3 new  =head3 new
86    
87      my $sub = Subsystem->new($subName, $sprout);      my $sub = SproutSubsys->new($subName, $sprout);
88    
89  Load the subsystem.  Load the subsystem.
90    
# Line 118  Line 118 
118          Confess("Subsystem \"$subName\" not found in database.");          Confess("Subsystem \"$subName\" not found in database.");
119      } else {      } else {
120          # We've found it, so get the major data.          # We've found it, so get the major data.
121          my ($curator, $notes, $description) = $subsystemObject->Values(['Subsystem(curator)', 'Subsystem(notes)',          my ($curator, $notes, $description, $version) = $subsystemObject->Values(['Subsystem(curator)', 'Subsystem(notes)',
122                                                                          'Subsystem(description)']);                                                              'Subsystem(description)', 'Subsystem(version)']);
123          # Get the genome IDs and variant codes for the rows. The list returned          # Get the genome IDs and variant codes for the rows. The list returned
124          # by GetAll will be a list of 2-tuples, each consisting of a genome ID          # by GetAll will be a list of 2-tuples, each consisting of a genome ID
125          # and a subsystem variant code.          # and a subsystem variant code.
# Line 136  Line 136 
136          # 2-tuples will be ordered by the spreadsheet column number.          # 2-tuples will be ordered by the spreadsheet column number.
137          my @roles = $sprout->GetAll(['OccursInSubsystem'],          my @roles = $sprout->GetAll(['OccursInSubsystem'],
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)']);
141          # Now we need to create the role ID directory and the reaction hash.          # Now we need to create the role ID directory and the reaction hash.
142          # The role ID directory maps role IDs and their abbreviations to column numbers.          # The role ID directory maps role IDs and their abbreviations to column numbers.
143          # The reaction hash maps a role ID to a list of the IDs for the reactions it          # The reaction hash maps a role ID to a list of the IDs for the reactions it
144          # catalyzes.          # catalyzes.
145          my %roleHash = ();          my %roleHash = ();
146          my %abbrHash = ();          my %abbrHash = ();
147            my %auxHash = ();
148          my %reactionHash = ();          my %reactionHash = ();
149          for ($idx = 0; $idx <= $#roles; $idx++) {          for ($idx = 0; $idx <= $#roles; $idx++) {
150              # Get the role ID and abbreviation for this column's role.              # Get the role ID, aux flag, and abbreviation for this column's role.
151              my ($roleID, $abbr) = @{$roles[$idx]};              my ($roleID, $abbr, $aux) = @{$roles[$idx]};
152              # Put them both in the role directory.              # Put the ID and abbreviation in the role directory.
153              $roleHash{$roleID} = $idx;              $roleHash{$roleID} = $idx;
154              $roleHash{$abbr} = $idx;              $roleHash{$abbr} = $idx;
155                # Put the aux flag in the aux hash.
156                $auxHash{$roleID} = $aux;
157              # Put the full name in the abbreviation directory.              # Put the full name in the abbreviation directory.
158              $abbrHash{$abbr} = $roleID;              $abbrHash{$abbr} = $roleID;
159              # Get this role's reactions.              # Get this role's reactions.
# Line 188  Line 192 
192                      colorHash => {},                      colorHash => {},
193                      # Map of abbreviations to role names.                      # Map of abbreviations to role names.
194                      abbrHash => \%abbrHash,                      abbrHash => \%abbrHash,
195                        # Map of auxiliary rols.
196                        auxHash => \%auxHash,
197                      # Map of role IDs to reactions.                      # Map of role IDs to reactions.
198                      reactionHash => \%reactionHash,                      reactionHash => \%reactionHash,
199                        # Version number.
200                        version => $version,
201                  };                  };
202          # Bless and return it.          # Bless and return it.
203          bless $retVal, $class;          bless $retVal, $class;
# Line 197  Line 205 
205      return $retVal;      return $retVal;
206  }  }
207    
208    =head3 is_aux_role
209    
210        my $flag = $sub->is_aux_role($roleID);
211    
212    Return TRUE if the specified role is auxiliary to this subsystem, FALSE
213    if it is essential to it.
214    
215    =over 4
216    
217    =item roleID
218    
219    ID of the relevant role.
220    
221    =item RETURN
222    
223    Returns TRUE if the specified role is auxiliary, else FALSE.
224    
225    =back
226    
227    =cut
228    
229    sub is_aux_role {
230        # Get the parameters.
231        my ($self, $roleID) = @_;
232        # Declare the return variable.
233        my $retVal = $self->{auxHash}->{$roleID};
234        # Return the result.
235        return $retVal;
236    }
237    
238    
239  =head3 get_row  =head3 get_row
240    
241      my $rowData = $sub->get_row($rowIndex);      my $rowData = $sub->get_row($rowIndex);
# Line 556  Line 595 
595      return $retVal;      return $retVal;
596  }  }
597    
598    
599    =head3 get_hope_reactions_for_genome
600    
601        my %ss_reactions = $subsys->get_hope_reactions_for_genome($genome);
602    
603    This method returns a hash that maps reactions to the pegs that catalyze
604    them for the specified genome. For each role in the subsystem, the pegs
605    are computed, and these are attached to the reactions for the role.
606    
607    =over 4
608    
609    =item genome
610    
611    ID of the genome whose reactions are to be put into the hash.
612    
613    =item RETURN
614    
615    Returns a hash mapping reactions in the subsystem to pegs in the
616    specified genome, or C<undef> if the genome is not found in the
617    subsystem.
618    
619    =back
620    
621    =cut
622    
623    sub get_hope_reactions_for_genome {
624        ##TODO
625        my($self, $genome) = @_;
626        my $index = $self->{genome_index}->{$genome};
627        if (defined $index) {
628            my @roles = $self->get_roles;
629            my %hope_reactions = $self->get_hope_reactions;
630    
631            my %ss_reactions;
632    
633            foreach my $role (@roles)
634            {
635                my @peg_list = $self->get_pegs_from_cell($genome,$role);
636    
637                if (defined $hope_reactions{$role} && scalar @peg_list > 0)
638    
639                {
640                    foreach my $reaction (@{$hope_reactions{$role}})
641                    {
642                        push @{$ss_reactions{$reaction}}, @peg_list;
643                    }
644                }
645            }
646    
647            return %ss_reactions;
648        }
649        else {
650            return undef;
651        }
652    }
653    
654    
655    =head3 get_hope_additional_reactions
656    
657        my %ss_reactions = $subsys->get_hope_additional_reactions($scenario_name);
658    
659    Return a list of the additional reactions for the specified scenario.
660    
661    =over 4
662    
663    =item scenario_name
664    
665    Name of the scenario whose additional reactions are desired.
666    
667    =item RETURN
668    
669    Returns a list of the additional reactions attached to the named scenario.
670    
671    =back
672    
673    =cut
674    
675    sub get_hope_additional_reactions
676    {
677        my($self,$scenario_name) = @_;
678        Trace("Hope additional reactions not available in NMPDR.") if T(0);  ##HACK
679        my @retVal;
680        return @retVal;
681    }
682    
683    
684  =head3 get_hope_reactions  =head3 get_hope_reactions
685    
686      my %reactionHash = $subsys->get_hope_reactions();      my %reactionHash = $subsys->get_hope_reactions();
# Line 573  Line 698 
698      my $retVal = $self->{hopeReactions};      my $retVal = $self->{hopeReactions};
699      if (! defined($retVal)) {      if (! defined($retVal)) {
700          # They do not exist, so we must create them.          # They do not exist, so we must create them.
701          $retVal = FIGRules::GetHopeReactions($self, $self->{dir});          $retVal = FIGRules::GetHopeReactions($self, $self->{dir}); ##HACK
702          # Insure we have it if we need it again.          # Insure we have it if we need it again.
703          $self->{hopeReactions} = $retVal;          $self->{hopeReactions} = $retVal;
704      }      }
# Line 581  Line 706 
706      return %{$retVal};      return %{$retVal};
707  }  }
708    
709    =head3 get_hope_reaction_notes
710    
711        my %roleHash = $sub->get_hope_reaction_notes();
712    
713    Return a hash mapping the roles of the subsystem to any existing notes
714    about the relevant reactions.
715    
716    =cut
717    
718    sub get_hope_reaction_notes {
719        # Get the parameters.
720        my ($self) = @_;
721        # Declare the return variable.
722        my %retVal;
723        ##TODO: Code
724        # Return the result.
725        return %retVal;
726    }
727    
728    =head3 get_hope_reaction_note
729    
730        my $note = $sub->get_hope_reaction_note($role);
731    
732    Return the text note about the curation of the scenario reactions
733    relating to this role.
734    
735    =over 4
736    
737    =item role
738    
739    ##TODO: role description
740    
741    =item RETURN
742    
743    ##TODO: return value description
744    
745    =back
746    
747    =cut
748    
749    sub get_hope_reaction_note {
750        # Get the parameters.
751        my ($self, $role) = @_;
752        # Declare the return variable.
753        my $retVal;
754        ##TODO: Code
755        # Return the result.
756        return $retVal;
757    }
758    
759  =head3 get_role_index  =head3 get_role_index
760    
761      my $idx = $sub->get_role_index($role);      my $idx = $sub->get_role_index($role);
# Line 968  Line 1143 
1143    my $image_map = $self->get_diagram_html_file($id);    my $image_map = $self->get_diagram_html_file($id);
1144    if ($image_map) {    if ($image_map) {
1145      Trace("Image map found for diagram $id at $image_map.") if T(3);      Trace("Image map found for diagram $id at $image_map.") if T(3);
1146      open(IN, "$image_map") or Confess("Unable to open file $image_map.");      Open(\*IN, "<$image_map");
1147      my $header = <IN>;      my $header = <IN>;
1148      close(IN);      close(IN);
1149    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3