[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.10, Tue Apr 10 06:16:22 2007 UTC revision 1.18, Tue Sep 9 21:02:10 2008 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 = SproutSubsys->new($subName, $sprout);
88    
89  Load the subsystem.  Load the subsystem.
90    
# Line 106  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, $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 125  Line 134 
134          # Get the role IDs and abbreviations. The list returned by GetAll will be          # Get the role IDs and abbreviations. The list returned by GetAll will be
135          # a list of 2-tuples, each consisting of a role ID and abbreviation. The          # a list of 2-tuples, each consisting of a role ID and abbreviation. The
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', 'Role'],          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)', 'Role(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 = ();
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.
158                $abbrHash{$abbr} = $roleID;
159              # Get this role's reactions.              # Get this role's reactions.
160              my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',              my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',
161                                               [$roleID], 'Catalyzes(to-link)');                                               [$roleID], 'Catalyzes(to-link)');
# Line 174  Line 190 
190                      roles => \@roles,                      roles => \@roles,
191                      # Map of PEG IDs to cluster numbers.                      # Map of PEG IDs to cluster numbers.
192                      colorHash => {},                      colorHash => {},
193                        # Map of abbreviations to role names.
194                        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 183  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
240    
241        my $rowData = $sub->get_row($rowIndex);
242    
243    Return the specified row in the subsystem spreadsheet. The row consists
244    of a list of lists. Each position in the major list represents the role
245    for that position, and contains a list of the IDs for the features that
246    perform the role.
247    
248    =over 4
249    
250    =item rowIndex
251    
252    Index of the row to return. A row contains data for a single genome.
253    
254    =item RETURN
255    
256    Returns a reference to a list of lists. Each element in the list represents
257    a spreadsheet column (role) and contains a list of features that perform the
258    role.
259    
260    =back
261    
262    =cut
263    
264    sub get_row {
265        # Get the parameters.
266        my ($self, $rowIndex) = @_;
267        # Get the genome ID for the specified row's genome.
268        my $genomeID = $self->{genomes}->[$rowIndex]->[0];
269        # Read the row from the database. We won't get exactly what we want. Instead, we'll
270        # get a list of triplets, each consisting of a role name, a feature ID, and a cluster
271        # number. We need to convert this into a list of lists and stash the clustering information
272        # in the color hash.
273        my @rowData = $self->{sprout}->GetAll([qw(Subsystem HasSSCell IsGenomeOf IsRoleOf ContainsFeature)],
274                                              "Subsystem(id) = ? AND IsGenomeOf(from-link) = ?",
275                                              [$self->{name}, $genomeID],
276                                              [qw(IsRoleOf(from-link) ContainsFeature(to-link)
277                                                  ContainsFeature(cluster-number))]);
278        # Now we do the conversion. We must first create an array of empty lists, one per
279        # row index.
280        my @retVal = map { [] } @{$self->{roles}};
281        # Get the hash for converting role IDs to role indexes.
282        my $roleHash = $self->{roleHash};
283        # Now we stash all the feature IDs in the appropriate columns of the row list.
284        for my $rowDatum (@rowData) {
285            # Get the role ID, the peg ID, and the cluster number.
286            my ($role, $peg, $cluster) = @{$rowDatum};
287            # Put the peg in the role's peg list.
288            push @{$retVal[$roleHash->{$role}]}, $peg;
289            # Put the cluster number in the color hash.
290            $self->{colorHash}->{$peg} = $cluster;
291        }
292        # Return the result.
293        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
335    
336        my $abbr = $sub->get_abbr_for_role($name);
337    
338    Get this subsystem's abbreviation for the specified role.
339    
340    =over 4
341    
342    =item name
343    
344    Name of the relevant role.
345    
346    =item RETURN
347    
348    Returns the abbreviation for the role. Each subsystem has its own abbreviation
349    system; the abbreviations make it easier to display the subsystem spreadsheet.
350    
351    =back
352    
353    =cut
354    
355    sub get_abbr_for_role {
356        # Get the parameters.
357        my ($self, $name) = @_;
358        # Get the index for this role.
359        my $idx = $self->get_role_index($name);
360        # Return the abbreviation.
361        return $self->get_role_abbr($idx);
362    }
363    
364    =head3 get_subsetC
365    
366        my @columns = $sub->get_subsetC($subsetName);
367    
368    Return a list of the column numbers for the columns in the named role
369    subset.
370    
371    =over 4
372    
373    =item subsetName
374    
375    Name of the subset whose columns are desired.
376    
377    =item RETURN
378    
379    Returns a list of the indices for the columns in the named subset.
380    
381    =back
382    
383    =cut
384    
385    sub get_subsetC {
386        # Get the parameters.
387        my ($self, $subsetName) = @_;
388        # Get the roles in the subset.
389        my @roles = $self->get_subsetC_roles($subsetName);
390        # Convert them to indices.
391        my $roleHash = $self->{roleHash};
392        my @retVal = map { $roleHash->{$_} } @roles;
393        # Return the result.
394        return @retVal;
395    }
396    
397  =head3 get_genomes  =head3 get_genomes
398    
399  C<< my @genomeList = $sub->get_genomes(); >>      my @genomeList = $sub->get_genomes();
400    
401  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
402  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 205  Line 416 
416    
417  =head3 get_variant_code  =head3 get_variant_code
418    
419  C<< my $code = $sub->get_variant_code($gidx); >>      my $code = $sub->get_variant_code($gidx);
420    
421  Return the variant code for the specified genome. Each subsystem has multiple  Return the variant code for the specified genome. Each subsystem has multiple
422  variants which involve slightly different chemical reactions, and each variant  variants which involve slightly different chemical reactions, and each variant
# Line 237  Line 448 
448    
449  =head3 get_curator  =head3 get_curator
450    
451  C<< my $userName = $sub->get_curator(); >>      my $userName = $sub->get_curator();
452    
453  Return the name of this subsystem's official curator.  Return the name of this subsystem's official curator.
454    
# Line 252  Line 463 
463    
464  =head3 get_notes  =head3 get_notes
465    
466  C<< my $text = $sub->get_notes(); >>      my $text = $sub->get_notes();
467    
468  Return the descriptive notes for this subsystem.  Return the descriptive notes for this subsystem.
469    
# Line 265  Line 476 
476      return $self->{notes};      return $self->{notes};
477  }  }
478    
479    =head3 get_description
480    
481        my $text = $sub->get_description();
482    
483    Return the description for this subsystem.
484    
485    =cut
486    
487    sub get_description
488    {
489        my($self) = @_;
490        return $self->{description};
491    }
492    
493  =head3 get_roles  =head3 get_roles
494    
495  C<< my @roles = $sub->get_roles(); >>      my @roles = $sub->get_roles();
496    
497  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
498  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 286  Line 511 
511    
512  =head3 get_reactions  =head3 get_reactions
513    
514  C<< my $reactHash = $sub->get_reactions(); >>      my $reactHash = $sub->get_reactions();
515    
516  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
517  catalyzed by the role.  catalyzed by the role.
# Line 302  Line 527 
527    
528  =head3 get_subset_namesC  =head3 get_subset_namesC
529    
530  C<< my @subsetNames = $sub->get_subset_namesC(); >>      my @subsetNames = $sub->get_subset_namesC();
531    
532  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
533  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 324  Line 549 
549      return @retVal;      return @retVal;
550  }  }
551    
552    =head3 get_subset_names
553    
554        my @subsetNames = $sub->get_subset_names();
555    
556    Return the names of the column subsets.
557    
558    =cut
559    
560    sub get_subset_names{
561        # Get the parameters.
562        my ($self) = @_;
563        # Return the result.
564        return $self->get_subset_namesC();
565    }
566    
567  =head3 get_role_abbr  =head3 get_role_abbr
568    
569  C<< my $abbr = $sub->get_role_abbr($ridx); >>      my $abbr = $sub->get_role_abbr($ridx);
570    
571  Return the abbreviation for the role in the specified column. The abbreviation  Return the abbreviation for the role in the specified column. The abbreviation
572  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 355  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
685    
686        my %reactionHash = $subsys->get_hope_reactions();
687    
688    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
690    if the Hope reactions are not yet known.
691    
692    =cut
693    
694    sub get_hope_reactions {
695        # Get the parameters.
696        my ($self) = @_;
697        # Try to get the hope reactions from the object.
698        my $retVal = $self->{hopeReactions};
699        if (! defined($retVal)) {
700            # They do not exist, so we must create them.
701            $retVal = FIGRules::GetHopeReactions($self, $self->{dir}); ##HACK
702            # Insure we have it if we need it again.
703            $self->{hopeReactions} = $retVal;
704        }
705        # 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;
757    }
758    
759  =head3 get_role_index  =head3 get_role_index
760    
761  C<< my $idx = $sub->get_role_index($role); >>      my $idx = $sub->get_role_index($role);
762    
763  Return the column index for the role with the specified ID.  Return the column index for the role with the specified ID.
764    
# Line 385  Line 786 
786    
787  =head3 get_subsetC_roles  =head3 get_subsetC_roles
788    
789  C<< my @roles = $sub->get_subsetC_roles($subname); >>      my @roles = $sub->get_subsetC_roles($subname);
790    
791  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.
792    
# Line 423  Line 824 
824    
825  =head3 get_genome_index  =head3 get_genome_index
826    
827  C<< my $idx = $sub->get_genome_index($genome); >>      my $idx = $sub->get_genome_index($genome);
828    
829  Return the row index for the genome with the specified ID.  Return the row index for the genome with the specified ID.
830    
# Line 452  Line 853 
853    
854  =head3 get_cluster_number  =head3 get_cluster_number
855    
856  C<< my $number = $sub->get_cluster_number($pegID); >>      my $number = $sub->get_cluster_number($pegID);
857    
858  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
859  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 492  Line 893 
893    
894  =head3 get_pegs_from_cell  =head3 get_pegs_from_cell
895    
896  C<< my @pegs = $sub->get_pegs_from_cell($rowstr, $colstr); >>      my @pegs = $sub->get_pegs_from_cell($rowstr, $colstr);
897    
898  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.
899    
# Line 561  Line 962 
962    
963  =head3 get_subsetR  =head3 get_subsetR
964    
965  C<< my @genomes = $sub->get_subsetR($subName); >>      my @genomes = $sub->get_subsetR($subName);
966    
967  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.
968    
# Line 592  Line 993 
993    
994  =head3 get_diagrams  =head3 get_diagrams
995    
996  C<< my @list = $sub->get_diagrams(); >>      my @list = $sub->get_diagrams();
997    
998  Return a list of the diagrams associated with this subsystem. Each diagram  Return a list of the diagrams associated with this subsystem. Each diagram
999  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 646  Line 1047 
1047    
1048  =head3 get_diagram  =head3 get_diagram
1049    
1050  C<< my ($name, $pageURL, $imgURL) = $sub->get_diagram($id); >>      my ($name, $pageURL, $imgURL) = $sub->get_diagram($id);
1051    
1052  Get the information (if any) for the specified diagram. The diagram corresponds  Get the information (if any) for the specified diagram. The diagram corresponds
1053  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 674  Line 1075 
1075  sub get_diagram {  sub get_diagram {
1076      my($self, $id) = @_;      my($self, $id) = @_;
1077      my $name = Subsystem::GetDiagramName($self->{dir}, $id);      my $name = Subsystem::GetDiagramName($self->{dir}, $id);
1078      my ($link, $img_link) = Subsystem::ComputeDiagramURLs($self->{name}, $id, 1);      my ($link, $img_link) = Subsystem::ComputeDiagramURLs($self, $self->{name}, $id, 1);
1079      return($name, $link, $img_link);      return($name, $link, $img_link);
1080  }  }
1081    
1082    
1083  =head3 get_diagram_html_file  =head3 get_diagram_html_file
1084    
1085  C<< my $fileName = $sub->get_diagram_html_file($id); >>      my $fileName = $sub->get_diagram_html_file($id);
1086    
1087  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
1088  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 716  Line 1117 
1117      return $retVal;      return $retVal;
1118  }  }
1119    
1120    =head3 is_new_diagram
1121    
1122        my $flag = $sub->is_new_diagram($id);
1123    
1124    Return TRUE if the specified diagram is in the new format, else FALSE.
1125    
1126    =over 4
1127    
1128    =item id
1129    
1130    ID code (e.g. C<d03>) of the relevant diagram.
1131    
1132    =item RETURN
1133    
1134    Returns TRUE if the diagram is in the new format, else FALSE.
1135    
1136    =back
1137    
1138    =cut
1139    
1140    sub is_new_diagram {
1141      my ($self, $id) = @_;
1142    
1143      my $image_map = $self->get_diagram_html_file($id);
1144      if ($image_map) {
1145        Trace("Image map found for diagram $id at $image_map.") if T(3);
1146        Open(\*IN, "<$image_map");
1147        my $header = <IN>;
1148        close(IN);
1149    
1150        if ($header =~ /\<map name=\"GraffleExport\"\>/) {
1151          return 1;
1152        }
1153      }
1154    
1155      return undef;
1156    }
1157    
1158    =head3 get_role_from_abbr
1159    
1160        my $roleName = $sub->get_role_from_abbr($abbr);
1161    
1162    Return the role name corresponding to an abbreviation.
1163    
1164    =over 4
1165    
1166    =item abbr
1167    
1168    Abbreviation name of the relevant role.
1169    
1170    =item RETURN
1171    
1172    Returns the full name of the specified role.
1173    
1174    =back
1175    
1176    =cut
1177    
1178    sub get_role_from_abbr {
1179        # Get the parameters.
1180        my($self, $abbr) = @_;
1181        # Get the role name from the abbreviation hash.
1182        my $retVal = $self->{abbrHash}->{$abbr};
1183        # Check for a case incompatability.
1184        if (! defined $retVal) {
1185            $retVal = $self->{abbrHash}->{lcfirst $abbr};
1186        }
1187        # Return the result.
1188        return $retVal;
1189    }
1190    
1191    
1192  =head3 get_name  =head3 get_name
1193    
1194  C<< my $name = $sub->get_name(); >>      my $name = $sub->get_name();
1195    
1196  Return the name of this subsystem.  Return the name of this subsystem.
1197    
# Line 733  Line 1206 
1206    
1207  =head3 open_diagram_image  =head3 open_diagram_image
1208    
1209  C<< my ($type, $fh) = $sub->open_diagram_image($id); >>      my ($type, $fh) = $sub->open_diagram_image($id);
1210    
1211  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.
1212    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3