[Bio] / Sprout / ReactionSproutLoader.pm Repository:
ViewVC logotype

Diff of /Sprout/ReactionSproutLoader.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Thu Oct 9 18:16:26 2008 UTC revision 1.2, Mon Jan 19 21:46:21 2009 UTC
# Line 22  Line 22 
22      use strict;      use strict;
23      use Tracer;      use Tracer;
24      use ERDB;      use ERDB;
25        use HTML;
26      use base 'BaseSproutLoader';      use base 'BaseSproutLoader';
27    
28  =head1 Sprout Reaction Load Group Class  =head1 Sprout Reaction Load Group Class
# Line 42  Line 43 
43    
44  [[SproutPm]] object for the database being loaded.  [[SproutPm]] object for the database being loaded.
45    
 =item source  
   
 [[FigPm]] object used to access the source data. If this parameter is undefined,  
 it will be created the first time the L</source> method is called.  
   
46  =item options  =item options
47    
48  Reference to a hash of command-line options.  Reference to a hash of command-line options.
# Line 61  Line 57 
57    
58  sub new {  sub new {
59      # Get the parameters.      # Get the parameters.
60      my ($class, $erdb, $source, $options) = @_;      my ($class, $erdb, $options) = @_;
61      # Create the table list.      # Create the table list.
62      my @tables = sort qw(Reaction ReactionURL Compound CompoundName CompoundCAS IsIdentifiedByCAS HasCompoundName IsAComponentOf Scenario Catalyzes HasScenario IsInputFor IsOutputOf ExcludesReaction IncludesReaction IsOnDiagram IncludesReaction);      my @tables = sort qw(Reaction ReactionURL Compound CompoundName CompoundCAS IsIdentifiedByCAS HasCompoundName IsAComponentOf Scenario Catalyzes HasScenario IsInputFor IsOutputOf ExcludesReaction IncludesReaction IsOnDiagram IncludesReaction);
63      # Create the BaseSproutLoader object.      # Create the BaseSproutLoader object.
64      my $retVal = BaseSproutLoader::new($class, $erdb, $source, $options, @tables);      my $retVal = BaseSproutLoader::new($class, $erdb, $options, @tables);
65      # Return it.      # Return it.
66      return $retVal;      return $retVal;
67  }  }
# Line 99  Line 95 
95              # Check for names.              # Check for names.
96              my @names = $fig->names_of_compound($cid);              my @names = $fig->names_of_compound($cid);
97              # Each name will be given a priority number, starting with 1.              # Each name will be given a priority number, starting with 1.
98              my $prio = 1;              my $prio = 0;
99              for my $name (@names) {              for my $name (@names) {
100                  if (! exists $compoundNames{$name}) {                  if (! exists $compoundNames{$name}) {
101                      $self->PutE(CompoundName => $name);                      $self->PutE(CompoundName => $name);
102                      $compoundNames{$name} = 1;                      $compoundNames{$name} = 1;
103                  }                  }
104                  $$self->PutRl(HasCompoundName => $cid, $name, priority => $prio++);                  $self->PutR(HasCompoundName => $cid, $name, priority => ++$prio);
105              }              }
106              # Create the main compound record. Note that the first name              # Create the main compound record. Note that the first name
107              # becomes the label.              # becomes the label.
# Line 115  Line 111 
111              my $cas = $fig->cas($cid);              my $cas = $fig->cas($cid);
112              if ($cas) {              if ($cas) {
113                  $self->PutR(IsIdentifiedByCAS => $cid, $cas);                  $self->PutR(IsIdentifiedByCAS => $cid, $cas);
114                  $self->PutE(CompoundCAR => $cas);                  $self->PutE(CompoundCAS => $cas);
115              }              }
116          }          }
117          # All the compounds are set up, so we need to loop through the reactions next. First,          # All the compounds are set up, so we need to loop through the reactions next. First,
# Line 125  Line 121 
121          my %reactions = map { $_ => 1 } $fig->all_reactions();          my %reactions = map { $_ => 1 } $fig->all_reactions();
122          for my $reactionID (keys %reactions) {          for my $reactionID (keys %reactions) {
123              # Create the reaction record.              # Create the reaction record.
124              $self->Put(Reaction => $reactionID, rev => $fig->reversible($reactionID));              $self->PutE(Reaction => $reactionID, rev => $fig->reversible($reactionID));
125              # Compute the reaction's URL.              # Compute the reaction's URL.
126              my $url = HTML::reaction_link($reactionID);              my $url = HTML::reaction_link($reactionID);
127              # Put it in the ReactionURL table.              # Put it in the ReactionURL table.
128              $self->Put(ReactionURL => $reactionID, url => $url);              $self->PutE(ReactionURL => $reactionID, url => $url);
129              # Now we need all of the reaction's compounds. We get these in two phases,              # Now we need all of the reaction's compounds. We get these in two phases,
130              # substrates first and then products.              # substrates first and then products.
131              for my $product (0, 1) {              for my $product (0, 1) {
# Line 153  Line 149 
149          # duplicates and a counter for compound group keys.          # duplicates and a counter for compound group keys.
150          my %roles = ();          my %roles = ();
151          my %scenarios = ();          my %scenarios = ();
152          my @subsystems = $fig->all_subsystems();          my @subsystems = sort keys %{$self->GetSubsystems()};
153          for my $subName (@subsystems) {          for my $subName (@subsystems) {
154              my $sub = $fig->get_subsystem($subName);              my $sub = $fig->get_subsystem($subName);
155              Trace("Processing $subName reactions.") if T(3);              Trace("Processing $subName reactions.") if T(3);
# Line 171  Line 167 
167                  }                  }
168              }              }
169              Trace("Processing $subName scenarios.") if T(3);              Trace("Processing $subName scenarios.") if T(3);
170              # Get the subsystem's scenarios.              # Get the subsystem's scenarios. Note we ignore un-named scenarios.
171              my @scenarioNames = $sub->get_hope_scenario_names();              # None of them have any data, so we don't need to keep them.
172                my @scenarioNames = grep { $_ } $sub->get_hope_scenario_names();
173              # Loop through the scenarios, creating scenario data.              # Loop through the scenarios, creating scenario data.
174              for my $scenarioName (@scenarioNames) {              for my $scenarioName (@scenarioNames) {
175                    $self->Track(Scenarios => $scenarioName, 100);
176                  # Link this scenario to this subsystem.                  # Link this scenario to this subsystem.
177                  $self->PutR(HasScenario => $subName, $scenarioName);                  $self->PutR(HasScenario => $subName, $scenarioName);
178                  # If this scenario is new, we need to create it.                  # If this scenario is new, we need to create it.
# Line 189  Line 187 
187                      }                      }
188                      # Now we need to set up the output compounds. They come in two                      # Now we need to set up the output compounds. They come in two
189                      # groups, which we mark 0 and 1.                      # groups, which we mark 0 and 1.
190                      my $outputGroup = 0;                      my $outputGroupID = 0;
191                      # Set up the output compounds.                      # Set up the output compounds.
192                      for my $outputGroup ($sub->get_hope_output_compounds($scenarioName)) {                      for my $outputGroup ($sub->get_hope_output_compounds($scenarioName)) {
193                          # Attach the compounds.                          # Attach the compounds.
194                          for my $compound (@$outputGroup) {                          for my $compound (@$outputGroup) {
195                              $self->PutR(IsOutputOf => $scenarioName, $compound,                              $self->PutR(IsOutputOf => $compound, $scenarioName,
196                                          auxiliary => $outputGroup);                                          auxiliary => $outputGroupID);
197                          }                          }
198                            $outputGroupID = 1;
199                      }                      }
200                      # Create the reaction lists.                      # Create the reaction lists.
201                      my @addReactions = $sub->get_hope_additional_reactions($scenarioName);                      my @addReactions = $sub->get_hope_additional_reactions($scenarioName);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3