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

Diff of /Sprout/ScenarioSaplingLoader.pm

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

revision 1.11, Wed Dec 22 17:46:06 2010 UTC revision 1.12, Mon Jan 24 03:52:18 2011 UTC
# Line 22  Line 22 
22      use strict;      use strict;
23      use Tracer;      use Tracer;
24      use ERDB;      use ERDB;
     use FIGMODEL;  
25      use Rectangle;      use Rectangle;
26      use GD;      use GD;
27      use base 'BaseSaplingLoader';      use base 'BaseSaplingLoader';
# Line 116  Line 115 
115      my ($self, $fig) = @_;      my ($self, $fig) = @_;
116      # Get the Sapling object.      # Get the Sapling object.
117      my $erdb = $self->db();      my $erdb = $self->db();
     # Get the FIGMODEL object. This is used to map KEGG reaction IDs (used in  
     # scenarios) to our reaction IDs.  
     my $figmodel = $self->GetFigModel();  
118      # We run through the subsystems and roles, generating the scenarios.      # We run through the subsystems and roles, generating the scenarios.
119      # We'll need a role hash to prevent duplicates.      # We'll need a role hash to prevent duplicates.
120      my %roles = ();      my %roles = ();
# Line 164  Line 160 
160                  # Attach the input compounds.                  # Attach the input compounds.
161                  for my $input ($sub->get_hope_input_compounds($scenarioName)) {                  for my $input ($sub->get_hope_input_compounds($scenarioName)) {
162                      # Resolve the compound ID.                      # Resolve the compound ID.
163                      my $inputID = $figmodel->id_of_compound($input);                      my $inputID = $self->CompoundID($input);
164                      # Write the relationship record.                      # Write the relationship record.
165                      $self->PutR(IsTerminusFor => $inputID, $scenarioID,                      $self->PutR(IsTerminusFor => $inputID, $scenarioID,
166                                  group_number => 0);                                  group_number => 0);
# Line 176  Line 172 
172                          # Attach the compounds.                          # Attach the compounds.
173                          for my $compound (@$outputGroup) {                          for my $compound (@$outputGroup) {
174                              # Resolve the compound ID.                              # Resolve the compound ID.
175                              my $compoundID = $figmodel->id_of_compound($compound);                              my $compoundID = $self->CompoundID($compound);
176                              # Write the relationship record.                              # Write the relationship record.
177                              $self->PutR(IsTerminusFor => $compoundID, $scenarioID,                              $self->PutR(IsTerminusFor => $compoundID, $scenarioID,
178                                          group_number => $outputGroupID);                                          group_number => $outputGroupID);
# Line 189  Line 185 
185                      my @addReactions = $sub->get_hope_additional_reactions($scenarioName);                      my @addReactions = $sub->get_hope_additional_reactions($scenarioName);
186                      for my $reaction (@addReactions) {                      for my $reaction (@addReactions) {
187                          # Resolve the reaction ID.                          # Resolve the reaction ID.
188                          my $reactionID = $figmodel->id_of_reaction($reaction);                          my $reactionID = $self->ReactionID($reaction);
189                          # Write the relationship record.                          # Write the relationship record.
190                          $self->PutR(HasParticipant => $scenarioID, $reactionID,                          $self->PutR(HasParticipant => $scenarioID, $reactionID,
191                                      type => 1);                                      type => 1);
# Line 201  Line 197 
197                      my %notReactions = map { $_ => 2 } $sub->get_hope_ignore_reactions($scenarioName);                      my %notReactions = map { $_ => 2 } $sub->get_hope_ignore_reactions($scenarioName);
198                      for my $reaction (@reactions) {                      for my $reaction (@reactions) {
199                          # Resolve the reaction ID.                          # Resolve the reaction ID.
200                          my $reactionID = $figmodel->id_of_reaction($reaction);                          my $reactionID = $self->ReactionID($reaction);
201                          # Write the relationship record.                          # Write the relationship record.
202                          $self->PutR(HasParticipant => $scenarioID, $reactionID,                          $self->PutR(HasParticipant => $scenarioID, $reactionID,
203                                      type => ($notReactions{$reaction} || 0));                                      type => ($notReactions{$reaction} || 0));
# Line 258  Line 254 
254              $self->PutE(Diagram => $map, name => $name);              $self->PutE(Diagram => $map, name => $name);
255              $self->PutE(DiagramContent => $map, content => $diagram);              $self->PutE(DiagramContent => $map, content => $diagram);
256              # Now we connect it to the compounds.              # Now we connect it to the compounds.
257              $self->Connect($map, $mapTitle . "_cpd.coord", 'Shows', 'id_of_compound');              $self->Connect($map, $mapTitle . "_cpd.coord", 'Shows', 'CompoundID');
258              # Finally, the reactions.              # Finally, the reactions.
259              $self->Connect($map, $mapTitle . "_rn.coord", 'Displays', 'id_of_reaction');              $self->Connect($map, $mapTitle . "_rn.coord", 'Displays', 'ReactionID');
260          } else {          } else {
261              $self->Add(mapNotPNG => 1);              $self->Add(mapNotPNG => 1);
262          }          }
# Line 304  Line 300 
300  sub Connect {  sub Connect {
301      # Get the parameters.      # Get the parameters.
302      my ($self, $mapID, $fileName, $relName, $method) = @_;      my ($self, $mapID, $fileName, $relName, $method) = @_;
     # Get the FIGMODEL object. This is used to map KEGG reaction and compound IDs  
     # (used in disagrams) to our IDs.  
     my $figmodel = $self->GetFigModel();  
303      # Check the file.      # Check the file.
304      if (! -s $fileName) {      if (! -s $fileName) {
305          Trace("File \"$fileName\" not found for map $mapID.") if T(ERDBLoadGroup => 1);          Trace("File \"$fileName\" not found for map $mapID.") if T(ERDBLoadGroup => 1);
# Line 319  Line 312 
312              # Get the ID and the coordinates.              # Get the ID and the coordinates.
313              my ($id, @coords) = Tracer::GetLine($ih);              my ($id, @coords) = Tracer::GetLine($ih);
314              # Resolve the ID.              # Resolve the ID.
315              my $realID = eval("\$figmodel->$method(\$id)");              my $realID = eval("\$self->$method(\$id)");
316              # Connect the ID to the diagram.              # Connect the ID to the diagram.
317              $self->PutR($relName => $mapID, $realID, location => Rectangle->new(@coords));              $self->PutR($relName => $mapID, $realID, location => Rectangle->new(@coords));
318          }          }
# Line 344  Line 337 
337      my $retVal = $self->{figModel};      my $retVal = $self->{figModel};
338      if (! defined $retVal) {      if (! defined $retVal) {
339          # It doesn't exist, so create one.          # It doesn't exist, so create one.
340            require FIGMODEL;
341          $retVal = FIGMODEL->new();          $retVal = FIGMODEL->new();
342          $self->{figModel} = $retVal;          $self->{figModel} = $retVal;
343      }      }
# Line 351  Line 345 
345      return $retVal;      return $retVal;
346  }  }
347    
348    =head3 CompoundID
349    
350        my $id = $self->CompoundID($compound);
351    
352    Return the ModelSEED ID for a given compound.
353    
354    =over 4
355    
356    =item compound
357    
358    Regular compound ID to convert.
359    
360    =item RETURN
361    
362    Returns the internal ID for the incoming compound, or the incoming value if it is
363    an unknown compound.
364    
365    =back
366    
367    =cut
368    
369    sub CompoundID {
370        # Get the parameters.
371        my ($self, $compound) = @_;
372        # Declare the return variable.
373        my $retVal = $compound;
374        # Get the model object.
375        my $figModel = $self->GetFigModel();
376        # Get the object for the given compound ID.
377        my $obj = $figModel->database()->get_object("cpdals", {alias => $compound});
378        # If we found the compound, get its real ID.
379        if (defined($obj)) {
380            $retVal = $obj->COMPOUND();
381        }
382        # Return the result.
383        return $retVal;
384    }
385    
386    =head3 ReactionID
387    
388        my $id = $self->ReactionID($reaction);
389    
390    Return the ModelSEED ID for a given reaction.
391    
392    =over 4
393    
394    =item reaction
395    
396    Regular reaction ID to convert.
397    
398    =item RETURN
399    
400    Returns the internal ID for the incoming reaction, or the incoming value if it is
401    an unknown reaction.
402    
403    =back
404    
405    =cut
406    
407    sub ReactionID {
408        # Get the parameters.
409        my ($self, $reaction) = @_;
410        # Declare the return variable.
411        my $retVal = $reaction;
412        # Get the model object.
413        my $figModel = $self->GetFidModel();
414        # Get the reaction ID.
415        $retVal = $figModel->id_of_reaction($reaction);
416        # Return the result.
417        return $retVal;
418    }
419    
420  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3