[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.11, Mon Jul 16 19:59:33 2007 UTC revision 1.12, Thu Dec 6 14:50:08 2007 UTC
# Line 69  Line 69 
69  Map of PEG IDs to cluster numbers. This is used to create color maps for  Map of PEG IDs to cluster numbers. This is used to create color maps for
70  display of a subsystem's PEGs.  display of a subsystem's PEGs.
71    
72    =item hopeReactions
73    
74    Map of roles to EC numbers for the Hope reactions. This object is not loaded
75    until it is needed.
76    
77  =back  =back
78    
79  =cut  =cut
# Line 79  Line 84 
84    
85  =head3 new  =head3 new
86    
87  C<< my $sub = Subsystem->new($subName, $sprout); >>      my $sub = Subsystem->new($subName, $sprout);
88    
89  Load the subsystem.  Load the subsystem.
90    
# Line 188  Line 193 
193      return $retVal;      return $retVal;
194  }  }
195    
196    =head3 get_row
197    
198        my $rowData = $sub->get_row($rowIndex);
199    
200    Return the specified row in the subsystem spreadsheet. The row consists
201    of a list of lists. Each position in the major list represents the role
202    for that position, and contains a list of the IDs for the features that
203    perform the role.
204    
205    =over 4
206    
207    =item rowIndex
208    
209    Index of the row to return. A row contains data for a single genome.
210    
211    =item RETURN
212    
213    Returns a reference to a list of lists. Each element in the list represents
214    a spreadsheet column (role) and contains a list of features that perform the
215    role.
216    
217    =back
218    
219    =cut
220    
221    sub get_row {
222        # Get the parameters.
223        my ($self, $rowIndex) = @_;
224        # Get the genome ID for the specified row's genome.
225        my $genomeID = $self->{genomes}->[$rowIndex]->[0];
226        # Read the row from the database. We won't get exactly what we want. Instead, we'll
227        # get a list of triplets, each consisting of a role name, a feature ID, and a cluster
228        # number. We need to convert this into a list of lists and stash the clustering information
229        # in the color hash.
230        my @rowData = $self->{sprout}->GetAll([qw(Subsystem HasSSCell IsGenomeOf IsRoleOf ContainsFeature)],
231                                              "Subsystem(id) = ? AND IsGenomeOf(from-link) = ?",
232                                              [$self->{name}, $genomeID],
233                                              [qw(IsRoleOf(from-link) ContainsFeature(to-link)
234                                                  ContainsFeature(cluster-number))]);
235        # Now we do the conversion. We must first create an array of empty lists, one per
236        # row index.
237        my @retVal = map { [] } @{$self->{roles}};
238        # Get the hash for converting role IDs to role indexes.
239        my $roleHash = $self->{roleHash};
240        # Now we stash all the feature IDs in the appropriate columns of the row list.
241        for my $rowDatum (@rowData) {
242            # Get the role ID, the peg ID, and the cluster number.
243            my ($role, $peg, $cluster) = @{$rowDatum};
244            # Put the peg in the role's peg list.
245            push @{$retVal[$roleHash->{$role}]}, $peg;
246            # Put the cluster number in the color hash.
247            $self->{colorHash}->{$peg} = $cluster;
248        }
249        # Return the result.
250        return \@retVal;
251    }
252    
253    =head3 get_abbr_for_role
254    
255        my $abbr = $sub->get_abbr_for_role($name);
256    
257    Get this subsystem's abbreviation for the specified role.
258    
259    =over 4
260    
261    =item name
262    
263    Name of the relevant role.
264    
265    =item RETURN
266    
267    Returns the abbreviation for the role. Each subsystem has its own abbreviation
268    system; the abbreviations make it easier to display the subsystem spreadsheet.
269    
270    =back
271    
272    =cut
273    
274    sub get_abbr_for_role{
275        # Get the parameters.
276        my ($self, $name) = @_;
277        # Get the index for this role.
278        my $idx = $self->get_role_index($name);
279        # Return the abbreviation.
280        return $self->get_role_abbr($idx);
281    }
282    
283    =head3 get_subsetC
284    
285        my @columns = $sub->get_subsetC($subsetName);
286    
287    Return a list of the column numbers for the columns in the named role
288    subset.
289    
290    =over 4
291    
292    =item subsetName
293    
294    Name of the subset whose columns are desired.
295    
296    =item RETURN
297    
298    Returns a list of the indices for the columns in the named subset.
299    
300    =back
301    
302    =cut
303    
304    sub get_subsetC {
305        # Get the parameters.
306        my ($self, $subsetName) = @_;
307        # Get the roles in the subset.
308        my @roles = $self->get_subsetC_roles($subsetName);
309        # Convert them to indices.
310        my $roleHash = $self->{roleHash};
311        my @retVal = map { $roleHash->{$_} } @roles;
312        # Return the result.
313        return @retVal;
314    }
315    
316  =head3 get_genomes  =head3 get_genomes
317    
318  C<< my @genomeList = $sub->get_genomes(); >>      my @genomeList = $sub->get_genomes();
319    
320  Return a list of the genome IDs for this subsystem. Each genome corresponds to a row  Return a list of the genome IDs for this subsystem. Each genome corresponds to a row
321  in the subsystem spreadsheet. Indexing into this list returns the ID of the genome  in the subsystem spreadsheet. Indexing into this list returns the ID of the genome
# Line 210  Line 335 
335    
336  =head3 get_variant_code  =head3 get_variant_code
337    
338  C<< my $code = $sub->get_variant_code($gidx); >>      my $code = $sub->get_variant_code($gidx);
339    
340  Return the variant code for the specified genome. Each subsystem has multiple  Return the variant code for the specified genome. Each subsystem has multiple
341  variants which involve slightly different chemical reactions, and each variant  variants which involve slightly different chemical reactions, and each variant
# Line 242  Line 367 
367    
368  =head3 get_curator  =head3 get_curator
369    
370  C<< my $userName = $sub->get_curator(); >>      my $userName = $sub->get_curator();
371    
372  Return the name of this subsystem's official curator.  Return the name of this subsystem's official curator.
373    
# Line 257  Line 382 
382    
383  =head3 get_notes  =head3 get_notes
384    
385  C<< my $text = $sub->get_notes(); >>      my $text = $sub->get_notes();
386    
387  Return the descriptive notes for this subsystem.  Return the descriptive notes for this subsystem.
388    
# Line 272  Line 397 
397    
398  =head3 get_roles  =head3 get_roles
399    
400  C<< my @roles = $sub->get_roles(); >>      my @roles = $sub->get_roles();
401    
402  Return a list of the subsystem's roles. Each role corresponds to a column  Return a list of the subsystem's roles. Each role corresponds to a column
403  in the subsystem spreadsheet. The list entry at a specified position in  in the subsystem spreadsheet. The list entry at a specified position in
# Line 291  Line 416 
416    
417  =head3 get_reactions  =head3 get_reactions
418    
419  C<< my $reactHash = $sub->get_reactions(); >>      my $reactHash = $sub->get_reactions();
420    
421  Return a reference to a hash that maps each role ID to a list of the reactions  Return a reference to a hash that maps each role ID to a list of the reactions
422  catalyzed by the role.  catalyzed by the role.
# Line 307  Line 432 
432    
433  =head3 get_subset_namesC  =head3 get_subset_namesC
434    
435  C<< my @subsetNames = $sub->get_subset_namesC(); >>      my @subsetNames = $sub->get_subset_namesC();
436    
437  Return a list of the names for all the column (role) subsets. Given a subset  Return a list of the names for all the column (role) subsets. Given a subset
438  name, you can use the L</get_subsetC_roles> method to get the roles in the  name, you can use the L</get_subsetC_roles> method to get the roles in the
# Line 329  Line 454 
454      return @retVal;      return @retVal;
455  }  }
456    
457    =head3 get_subset_names
458    
459        my @subsetNames = $sub->get_subset_names();
460    
461    Return the names of the column subsets.
462    
463    =cut
464    
465    sub get_subset_names{
466        # Get the parameters.
467        my ($self) = @_;
468        # Return the result.
469        return $self->get_subset_namesC();
470    }
471    
472  =head3 get_role_abbr  =head3 get_role_abbr
473    
474  C<< my $abbr = $sub->get_role_abbr($ridx); >>      my $abbr = $sub->get_role_abbr($ridx);
475    
476  Return the abbreviation for the role in the specified column. The abbreviation  Return the abbreviation for the role in the specified column. The abbreviation
477  is a shortened identifier that is not necessarily unique, but is more likely to  is a shortened identifier that is not necessarily unique, but is more likely to
# Line 360  Line 500 
500      return $retVal;      return $retVal;
501  }  }
502    
503    =head3 get_hope_reactions
504    
505        my $reactionHash = $subsys->get_hope_reactions();
506    
507    Return a hash mapping the roles of this subsystem to the EC numbers for
508    the reactions used in scenarios (if any). It may return an empty hash
509    if the Hope reactions are not yet known.
510    
511    =cut
512    
513    sub get_hope_reactions {
514        # Get the parameters.
515        my ($self) = @_;
516        # Try to get the hope reactions from the object.
517        my $retVal = $self->{hopeReactions};
518        if (! defined($retVal)) {
519            # They do not exist, so we must create them.
520            $retVal = FIGRules::GetHopeReactions($self, $self->{dir});
521            # Insure we have it if we need it again.
522            $self->{hopeReactions} = $retVal;
523        }
524        # Return the result.
525        return $retVal;
526    }
527    
528  =head3 get_role_index  =head3 get_role_index
529    
530  C<< my $idx = $sub->get_role_index($role); >>      my $idx = $sub->get_role_index($role);
531    
532  Return the column index for the role with the specified ID.  Return the column index for the role with the specified ID.
533    
# Line 390  Line 555 
555    
556  =head3 get_subsetC_roles  =head3 get_subsetC_roles
557    
558  C<< my @roles = $sub->get_subsetC_roles($subname); >>      my @roles = $sub->get_subsetC_roles($subname);
559    
560  Return the names of the roles contained in the specified role (column) subset.  Return the names of the roles contained in the specified role (column) subset.
561    
# Line 428  Line 593 
593    
594  =head3 get_genome_index  =head3 get_genome_index
595    
596  C<< my $idx = $sub->get_genome_index($genome); >>      my $idx = $sub->get_genome_index($genome);
597    
598  Return the row index for the genome with the specified ID.  Return the row index for the genome with the specified ID.
599    
# Line 457  Line 622 
622    
623  =head3 get_cluster_number  =head3 get_cluster_number
624    
625  C<< my $number = $sub->get_cluster_number($pegID); >>      my $number = $sub->get_cluster_number($pegID);
626    
627  Return the cluster number for the specified PEG, or C<-1> if the  Return the cluster number for the specified PEG, or C<-1> if the
628  cluster number for the PEG is unknown or it is not clustered.  cluster number for the PEG is unknown or it is not clustered.
# Line 497  Line 662 
662    
663  =head3 get_pegs_from_cell  =head3 get_pegs_from_cell
664    
665  C<< my @pegs = $sub->get_pegs_from_cell($rowstr, $colstr); >>      my @pegs = $sub->get_pegs_from_cell($rowstr, $colstr);
666    
667  Return a list of the peg IDs for the features in the specified spreadsheet cell.  Return a list of the peg IDs for the features in the specified spreadsheet cell.
668    
# Line 566  Line 731 
731    
732  =head3 get_subsetR  =head3 get_subsetR
733    
734  C<< my @genomes = $sub->get_subsetR($subName); >>      my @genomes = $sub->get_subsetR($subName);
735    
736  Return the genomes in the row subset indicated by the specified subset name.  Return the genomes in the row subset indicated by the specified subset name.
737    
# Line 597  Line 762 
762    
763  =head3 get_diagrams  =head3 get_diagrams
764    
765  C<< my @list = $sub->get_diagrams(); >>      my @list = $sub->get_diagrams();
766    
767  Return a list of the diagrams associated with this subsystem. Each diagram  Return a list of the diagrams associated with this subsystem. Each diagram
768  is represented in the return list as a 4-tuple C<[diagram_id, diagram_name,  is represented in the return list as a 4-tuple C<[diagram_id, diagram_name,
# Line 651  Line 816 
816    
817  =head3 get_diagram  =head3 get_diagram
818    
819  C<< my ($name, $pageURL, $imgURL) = $sub->get_diagram($id); >>      my ($name, $pageURL, $imgURL) = $sub->get_diagram($id);
820    
821  Get the information (if any) for the specified diagram. The diagram corresponds  Get the information (if any) for the specified diagram. The diagram corresponds
822  to a subdirectory of the subsystem's C<diagrams> directory. For example, if the  to a subdirectory of the subsystem's C<diagrams> directory. For example, if the
# Line 686  Line 851 
851    
852  =head3 get_diagram_html_file  =head3 get_diagram_html_file
853    
854  C<< my $fileName = $sub->get_diagram_html_file($id); >>      my $fileName = $sub->get_diagram_html_file($id);
855    
856  Get the HTML file (if any) for the specified diagram. The diagram corresponds  Get the HTML file (if any) for the specified diagram. The diagram corresponds
857  to a subdirectory of the subsystem's C<diagrams> directory. For example, if the  to a subdirectory of the subsystem's C<diagrams> directory. For example, if the
# Line 723  Line 888 
888    
889  =head3 is_new_diagram  =head3 is_new_diagram
890    
891  C<< my $flag = $sub->is_new_diagram($id); >>      my $flag = $sub->is_new_diagram($id);
892    
893  Return TRUE if the specified diagram is in the new format, else FALSE.  Return TRUE if the specified diagram is in the new format, else FALSE.
894    
# Line 761  Line 926 
926    
927  =head3 get_role_from_abbr  =head3 get_role_from_abbr
928    
929  C<< my $roleName = $sub->get_role_from_abbr($abbr); >>      my $roleName = $sub->get_role_from_abbr($abbr);
930    
931  Return the role name corresponding to an abbreviation.  Return the role name corresponding to an abbreviation.
932    
# Line 795  Line 960 
960    
961  =head3 get_name  =head3 get_name
962    
963  C<< my $name = $sub->get_name(); >>      my $name = $sub->get_name();
964    
965  Return the name of this subsystem.  Return the name of this subsystem.
966    
# Line 810  Line 975 
975    
976  =head3 open_diagram_image  =head3 open_diagram_image
977    
978  C<< my ($type, $fh) = $sub->open_diagram_image($id); >>      my ($type, $fh) = $sub->open_diagram_image($id);
979    
980  Open a diagram's image file and return the type and file handle.  Open a diagram's image file and return the type and file handle.
981    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3