[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.11, Mon Jul 16 19:59:33 2007 UTC
# Line 125  Line 125 
125          # 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
126          # 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
127          # 2-tuples will be ordered by the spreadsheet column number.          # 2-tuples will be ordered by the spreadsheet column number.
128          my @roles = $sprout->GetAll(['OccursInSubsystem', 'Role'],          my @roles = $sprout->GetAll(['OccursInSubsystem'],
129                                      'OccursInSubsystem(to-link) = ? ORDER BY OccursInSubsystem(column-number)',                                      'OccursInSubsystem(to-link) = ? ORDER BY OccursInSubsystem(column-number)',
130                                      [$subName], ['OccursInSubsystem(from-link)', 'Role(abbr)']);                                      [$subName], ['OccursInSubsystem(from-link)', 'OccursInSubsystem(abbr)']);
131          # 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.
132          # 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.
133          # 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
134          # catalyzes.          # catalyzes.
135          my %roleHash = ();          my %roleHash = ();
136            my %abbrHash = ();
137          my %reactionHash = ();          my %reactionHash = ();
138          for ($idx = 0; $idx <= $#roles; $idx++) {          for ($idx = 0; $idx <= $#roles; $idx++) {
139              # Get the role ID and abbreviation for this column's role.              # Get the role ID and abbreviation for this column's role.
# Line 140  Line 141 
141              # Put them both in the role directory.              # Put them both in the role directory.
142              $roleHash{$roleID} = $idx;              $roleHash{$roleID} = $idx;
143              $roleHash{$abbr} = $idx;              $roleHash{$abbr} = $idx;
144                # Put the full name in the abbreviation directory.
145                $abbrHash{$abbr} = $roleID;
146              # Get this role's reactions.              # Get this role's reactions.
147              my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',              my @reactions = $sprout->GetFlat(['Catalyzes'], 'Catalyzes(from-link) = ?',
148                                               [$roleID], 'Catalyzes(to-link)');                                               [$roleID], 'Catalyzes(to-link)');
# Line 174  Line 177 
177                      roles => \@roles,                      roles => \@roles,
178                      # Map of PEG IDs to cluster numbers.                      # Map of PEG IDs to cluster numbers.
179                      colorHash => {},                      colorHash => {},
180                        # Map of abbreviations to role names.
181                        abbrHash => \%abbrHash,
182                      # Map of role IDs to reactions.                      # Map of role IDs to reactions.
183                      reactionHash => \%reactionHash,                      reactionHash => \%reactionHash,
184                  };                  };
# Line 674  Line 679 
679  sub get_diagram {  sub get_diagram {
680      my($self, $id) = @_;      my($self, $id) = @_;
681      my $name = Subsystem::GetDiagramName($self->{dir}, $id);      my $name = Subsystem::GetDiagramName($self->{dir}, $id);
682      my ($link, $img_link) = Subsystem::ComputeDiagramURLs($self->{name}, $id, 1);      my ($link, $img_link) = Subsystem::ComputeDiagramURLs($self, $self->{name}, $id, 1);
683      return($name, $link, $img_link);      return($name, $link, $img_link);
684  }  }
685    
# Line 716  Line 721 
721      return $retVal;      return $retVal;
722  }  }
723    
724    =head3 is_new_diagram
725    
726    C<< my $flag = $sub->is_new_diagram($id); >>
727    
728    Return TRUE if the specified diagram is in the new format, else FALSE.
729    
730    =over 4
731    
732    =item id
733    
734    ID code (e.g. C<d03>) of the relevant diagram.
735    
736    =item RETURN
737    
738    Returns TRUE if the diagram is in the new format, else FALSE.
739    
740    =back
741    
742    =cut
743    
744    sub is_new_diagram {
745      my ($self, $id) = @_;
746    
747      my $image_map = $self->get_diagram_html_file($id);
748      if ($image_map) {
749        Trace("Image map found for diagram $id at $image_map.") if T(3);
750        open(IN, "$image_map") or Confess("Unable to open file $image_map.");
751        my $header = <IN>;
752        close(IN);
753    
754        if ($header =~ /\<map name=\"GraffleExport\"\>/) {
755          return 1;
756        }
757      }
758    
759      return undef;
760    }
761    
762    =head3 get_role_from_abbr
763    
764    C<< my $roleName = $sub->get_role_from_abbr($abbr); >>
765    
766    Return the role name corresponding to an abbreviation.
767    
768    =over 4
769    
770    =item abbr
771    
772    Abbreviation name of the relevant role.
773    
774    =item RETURN
775    
776    Returns the full name of the specified role.
777    
778    =back
779    
780    =cut
781    
782    sub get_role_from_abbr {
783        # Get the parameters.
784        my($self, $abbr) = @_;
785        # Get the role name from the abbreviation hash.
786        my $retVal = $self->{abbrHash}->{$abbr};
787        # Check for a case incompatability.
788        if (! defined $retVal) {
789            $retVal = $self->{abbrHash}->{lcfirst $abbr};
790        }
791        # Return the result.
792        return $retVal;
793    }
794    
795    
796  =head3 get_name  =head3 get_name
797    
798  C<< my $name = $sub->get_name(); >>  C<< my $name = $sub->get_name(); >>

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3