[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.12, Thu Dec 6 14:50:08 2007 UTC revision 1.15, Wed Jun 11 17:48:03 2008 UTC
# 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) = $sprout->GetEntityValues('Subsystem', $subName, ['Subsystem(curator)',      my $subsystemObject = $sprout->GetEntity('Subsystem', $subName);
116                                                                               'Subsystem(notes)']);      if (! defined $subsystemObject) {
117      # Only proceed if we found the subsystem.          # Here we're stuck.
118      if (defined $curator) {          Confess("Subsystem \"$subName\" not found in database.");
119        } else {
120            # We've found it, so get the major data.
121            my ($curator, $notes, $description) = $subsystemObject->Values(['Subsystem(curator)', 'Subsystem(notes)',
122                                                                            'Subsystem(description)']);
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 250  Line 254 
254      return \@retVal;      return \@retVal;
255  }  }
256    
257    =head3 get_roles_for_genome
258    
259        my @roles = $sub->get_roles_for_genome($genome_id);
260    
261    Return a list of the roles in this subsystem that have nonempty
262    spreadsheet cells for the given genome.
263    
264    =over 4
265    
266    =item genome_id
267    
268    ID of the relevant genome.
269    
270    =item RETURN
271    
272    Returns a list of role IDs.
273    
274    =back
275    
276    =cut
277    
278    sub get_roles_for_genome {
279        # Get the parameters.
280        my ($self, $genome_id) = @_;
281        # This next statement gets all of the nonempty cells for the genome's row and memorizes
282        # the roles by rolling them into a hash. The query connects four relationship tables on
283        # a single common key-- the spreadsheet cell ID. The IsGenomeOf table insures the cell is for the
284        # correct genome. The HasSSCell table insures that it belongs to the correct subsystem. The
285        # ContainsFeature table insures that it contains at least one feature. Finally, IsRoleOf tells
286        # us the cell's role. If a cell has more than one feature, the result list from the query will return
287        # one instance of the role for every distinct feature. The hash collapses the duplicates automatically.
288        my %retVal = map { $_ => 1 } $self->{sprout}->GetFlat([qw(ContainsFeature HasSSCell IsGenomeOf IsRoleOf)],
289                                                              "HasSSCell(from-link) = ? AND IsGenomeOf(from-link) = ?",
290                                                              [$self->{name}, $genome_id], 'IsRoleOf(from-link)');
291        # Return the result.
292        return keys %retVal;
293    }
294    
295  =head3 get_abbr_for_role  =head3 get_abbr_for_role
296    
297      my $abbr = $sub->get_abbr_for_role($name);      my $abbr = $sub->get_abbr_for_role($name);
# Line 395  Line 437 
437      return $self->{notes};      return $self->{notes};
438  }  }
439    
440    =head3 get_description
441    
442        my $text = $sub->get_description();
443    
444    Return the description for this subsystem.
445    
446    =cut
447    
448    sub get_description
449    {
450        my($self) = @_;
451        return $self->{description};
452    }
453    
454  =head3 get_roles  =head3 get_roles
455    
456      my @roles = $sub->get_roles();      my @roles = $sub->get_roles();
# Line 500  Line 556 
556      return $retVal;      return $retVal;
557  }  }
558    
559    
560    =head3 get_hope_reactions_for_genome
561    
562        my %ss_reactions = $subsys->get_hope_reactions_for_genome($genome);
563    
564    This method returns a hash that maps reactions to the pegs that catalyze
565    them for the specified genome. For each role in the subsystem, the pegs
566    are computed, and these are attached to the reactions for the role.
567    
568    =over 4
569    
570    =item genome
571    
572    ID of the genome whose reactions are to be put into the hash.
573    
574    =item RETURN
575    
576    Returns a hash mapping reactions in the subsystem to pegs in the
577    specified genome, or C<undef> if the genome is not found in the
578    subsystem.
579    
580    =back
581    
582    =cut
583    
584    sub get_hope_reactions_for_genome {
585        my($self, $genome) = @_;
586        my $index = $self->{genome_index}->{$genome};
587        if (defined $index) {
588            my @roles = $self->get_roles;
589            my %hope_reactions = $self->get_hope_reactions;
590    
591            my %ss_reactions;
592    
593            foreach my $role (@roles)
594            {
595                my @peg_list = $self->get_pegs_from_cell($genome,$role);
596    
597                if (defined $hope_reactions{$role} && scalar @peg_list > 0)
598    
599                {
600                    foreach my $reaction (@{$hope_reactions{$role}})
601                    {
602                        push @{$ss_reactions{$reaction}}, @peg_list;
603                    }
604                }
605            }
606    
607            return %ss_reactions;
608        }
609        else {
610            return undef;
611        }
612    }
613    
614    
615    =head3 get_hope_additional_reactions
616    
617        my %ss_reactions = $subsys->get_hope_additional_reactions($scenario_name);
618    
619    Return a list of the additional reactions for the specified scenario.
620    
621    =over 4
622    
623    =item scenario_name
624    
625    Name of the scenario whose additional reactions are desired.
626    
627    =item RETURN
628    
629    Returns a list of the additional reactions attached to the named scenario.
630    
631    =back
632    
633    =cut
634    
635    sub get_hope_additional_reactions
636    {
637        my($self,$scenario_name) = @_;
638        Trace("Hope additional reactions not available in NMPDR.") if T(0);
639        my @retVal;
640        return @retVal;
641    }
642    
643    
644  =head3 get_hope_reactions  =head3 get_hope_reactions
645    
646      my $reactionHash = $subsys->get_hope_reactions();      my %reactionHash = $subsys->get_hope_reactions();
647    
648  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
649  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 522  Line 663 
663          $self->{hopeReactions} = $retVal;          $self->{hopeReactions} = $retVal;
664      }      }
665      # Return the result.      # Return the result.
666      return $retVal;      return %{$retVal};
667  }  }
668    
669  =head3 get_role_index  =head3 get_role_index

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3