[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.14, Tue Apr 29 20:56:39 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, $description) = $sprout->GetEntityValues('Subsystem', $subName,      my $subsystemObject = $sprout->GetEntity('Subsystem', $subName);
116                                                                     ['Subsystem(curator)', 'Subsystem(notes)',      if (! defined $subsystemObject) {
117            # Here we're stuck.
118            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)']);                                                                      'Subsystem(description)']);
     # Only proceed if we found the subsystem.  
     if (defined $curator) {  
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 251  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 517  Line 558 
558    
559  =head3 get_hope_reactions  =head3 get_hope_reactions
560    
561      my $reactionHash = $subsys->get_hope_reactions();      my %reactionHash = $subsys->get_hope_reactions();
562    
563  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
564  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 537  Line 578 
578          $self->{hopeReactions} = $retVal;          $self->{hopeReactions} = $retVal;
579      }      }
580      # Return the result.      # Return the result.
581      return $retVal;      return %{$retVal};
582  }  }
583    
584  =head3 get_role_index  =head3 get_role_index

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3