[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.13, Sun Mar 23 16:34:17 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 111  Line 111 
111      }      }
112      # Declare the return value.      # Declare the return value.
113      my $retVal;      my $retVal;
114      # Get the subsystem's data fields.      # Get the subsystem's object.
115      my ($curator, $notes, $description) = $sprout->GetEntityValues('Subsystem', $subName,      my $subsystemObject = $sprout->GetEntity('Subsystem', $subName);
116                                                                     ['Subsystem(curator)', 'Subsystem(notes)',      if (! defined $subsystemObject) {
117                                                                      'Subsystem(description)']);          # Here we're stuck.
118      # Only proceed if we found the subsystem.          Confess("Subsystem \"$subName\" not found in database.");
119      if (defined $curator) {      } else {
120            # We've found it, so get the major data.
121            my ($curator, $notes, $description, $version) = $subsystemObject->Values(['Subsystem(curator)', 'Subsystem(notes)',
122                                                                '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 133  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 185  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 194  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 251  Line 293 
293      return \@retVal;      return \@retVal;
294  }  }
295    
296    =head3 get_roles_for_genome
297    
298        my @roles = $sub->get_roles_for_genome($genome_id);
299    
300    Return a list of the roles in this subsystem that have nonempty
301    spreadsheet cells for the given genome.
302    
303    =over 4
304    
305    =item genome_id
306    
307    ID of the relevant genome.
308    
309    =item RETURN
310    
311    Returns a list of role IDs.
312    
313    =back
314    
315    =cut
316    
317    sub get_roles_for_genome {
318        # Get the parameters.
319        my ($self, $genome_id) = @_;
320        # This next statement gets all of the nonempty cells for the genome's row and memorizes
321        # the roles by rolling them into a hash. The query connects four relationship tables on
322        # a single common key-- the spreadsheet cell ID. The IsGenomeOf table insures the cell is for the
323        # correct genome. The HasSSCell table insures that it belongs to the correct subsystem. The
324        # ContainsFeature table insures that it contains at least one feature. Finally, IsRoleOf tells
325        # us the cell's role. If a cell has more than one feature, the result list from the query will return
326        # one instance of the role for every distinct feature. The hash collapses the duplicates automatically.
327        my %retVal = map { $_ => 1 } $self->{sprout}->GetFlat([qw(ContainsFeature HasSSCell IsGenomeOf IsRoleOf)],
328                                                              "HasSSCell(from-link) = ? AND IsGenomeOf(from-link) = ?",
329                                                              [$self->{name}, $genome_id], 'IsRoleOf(from-link)');
330        # Return the result.
331        return keys %retVal;
332    }
333    
334  =head3 get_abbr_for_role  =head3 get_abbr_for_role
335    
336      my $abbr = $sub->get_abbr_for_role($name);      my $abbr = $sub->get_abbr_for_role($name);
# Line 515  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();
687    
688  Return a hash mapping the roles of this subsystem to the EC numbers for  Return a hash mapping the roles of this subsystem to the EC numbers for
689  the reactions used in scenarios (if any). It may return an empty hash  the reactions used in scenarios (if any). It may return an empty hash
# Line 532  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      }      }
705      # Return the result.      # Return the result.
706        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;      return $retVal;
757  }  }
758    
# Line 927  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.13  
changed lines
  Added in v.1.18

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3