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

Diff of /Sprout/SproutLoad.pm

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

revision 1.19, Thu Oct 20 09:34:09 2005 UTC revision 1.20, Wed Nov 2 21:54:40 2005 UTC
# Line 608  Line 608 
608      OccursInSubsystem      OccursInSubsystem
609      ParticipatesIn      ParticipatesIn
610      HasSSCell      HasSSCell
     Catalyzes  
     Reaction  
611      ConsistsOfRoles      ConsistsOfRoles
612      RoleSubset      RoleSubset
613      HasRoleSubset      HasRoleSubset
614      ConsistsOfGenomes      ConsistsOfGenomes
615      GenomeSubset      GenomeSubset
616      HasGenomeSubset      HasGenomeSubset
617        Catalyzes
618    
619  =over 4  =over 4
620    
# Line 645  Line 644 
644      my $loadSubsystem = $self->_TableLoader('Subsystem', $subsysCount);      my $loadSubsystem = $self->_TableLoader('Subsystem', $subsysCount);
645      my $loadRole = $self->_TableLoader('Role', $featureCount * 6);      my $loadRole = $self->_TableLoader('Role', $featureCount * 6);
646      my $loadRoleEC = $self->_TableLoader('RoleEC', $featureCount * 6);      my $loadRoleEC = $self->_TableLoader('RoleEC', $featureCount * 6);
647        my $loadCatalyzes = $self->_TableLoader('Catalyzes', $genomeCount * $featureCount);
648      my $loadSSCell = $self->_TableLoader('SSCell', $featureCount * $genomeCount);      my $loadSSCell = $self->_TableLoader('SSCell', $featureCount * $genomeCount);
649      my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $featureCount * $subsysCount);      my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $featureCount * $subsysCount);
650      my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $featureCount * $genomeCount);      my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $featureCount * $genomeCount);
# Line 652  Line 652 
652      my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $featureCount * 6);      my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $featureCount * 6);
653      my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $subsysCount * $genomeCount);      my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $subsysCount * $genomeCount);
654      my $loadHasSSCell = $self->_TableLoader('HasSSCell', $featureCount * $genomeCount);      my $loadHasSSCell = $self->_TableLoader('HasSSCell', $featureCount * $genomeCount);
     my $loadReaction = $self->_TableLoader('Reaction', $featureCount * $genomeCount);  
     my $loadCatalyzes = $self->_TableLoader('Catalyzes', $featureCount * $genomeCount);  
655      my $loadRoleSubset = $self->_TableLoader('RoleSubset', $subsysCount * 50);      my $loadRoleSubset = $self->_TableLoader('RoleSubset', $subsysCount * 50);
656      my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $subsysCount * 50);      my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $subsysCount * 50);
657      my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $featureCount * $genomeCount);      my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $featureCount * $genomeCount);
# Line 661  Line 659 
659      my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $subsysCount * 50);      my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $subsysCount * 50);
660      my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $subsysCount * 50);      my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $subsysCount * 50);
661      Trace("Beginning subsystem data load.") if T(2);      Trace("Beginning subsystem data load.") if T(2);
662      # The reaction hash will contain a list of reactions for each role. When we're done,      # This hash will contain the role for each EC. When we're done, this
663      # a complicated sort and merge will be used to generate the Reaction and Catalyzes      # information will be used to generate the Catalyzes table.
664      # tables.      my %ecToRoles = ();
     my %reactionsToRoles = ();  
665      # Loop through the subsystems. Our first task will be to create the      # Loop through the subsystems. Our first task will be to create the
666      # roles. We do this by looping through the subsystems and creating a      # roles. We do this by looping through the subsystems and creating a
667      # role hash. The hash tracks each role ID so that we don't create      # role hash. The hash tracks each role ID so that we don't create
# Line 677  Line 674 
674          $loadSubsystem->Add("subsystemIn");          $loadSubsystem->Add("subsystemIn");
675          # Get the subsystem object.          # Get the subsystem object.
676          my $sub = $fig->get_subsystem($subsysID);          my $sub = $fig->get_subsystem($subsysID);
         # Get its reaction hash.  
         my $reactionHash = $sub->get_reactions();  
677          # Create the subsystem record.          # Create the subsystem record.
678          my $curator = $sub->get_curator();          my $curator = $sub->get_curator();
679          my $notes = $sub->get_notes();          my $notes = $sub->get_notes();
# Line 697  Line 692 
692                  $roleData{$roleID} = 1;                  $roleData{$roleID} = 1;
693                  # Check for an EC number.                  # Check for an EC number.
694                  if ($roleID =~ /\(EC ([^.]+\.[^.]+\.[^.]+\.[^)]+)\)\s*$/) {                  if ($roleID =~ /\(EC ([^.]+\.[^.]+\.[^.]+\.[^)]+)\)\s*$/) {
695                      $loadRoleEC->Put($roleID, $1);                      my $ec = $1;
696                  }                      $loadRoleEC->Put($roleID, $ec);
697                  # Add the role's reactions.                      $ecToRoles{$ec} = $roleID;
                 my $reactions = $reactionHash->{$roleID};  
                 for my $reactionID (@{$reactions}) {  
                     if (! exists $reactionsToRoles{$reactionID}) {  
                         # Here the reaction is brand-new, so we create its reaction  
                         # record.  
                         $loadReaction->Put($reactionID, $fig->reversible($reactionID));  
                         # We also create a blank list for it in the reaction hash.  
                         $reactionsToRoles{$reactionID} = [];  
                     }  
                     # Add the role to the reaction's role list.  
                     push @{$reactionsToRoles{$reactionID}}, $roleID;  
698                  }                  }
699              }              }
700          }          }
# Line 810  Line 794 
794              }              }
795          }          }
796      }      }
797      # Before we leave, we must create the Catalyzes table. The data is all stored in      # Before we leave, we must create the Catalyzes table. We start with the reactions,
798      # "reactionToRoles" hash.      # then use the "ecToRoles" table to convert EC numbers to role IDs.
799      for my $reactionID (keys %reactionsToRoles) {      my @reactions = $fig->all_reactions();
800          # Get this reaction's list of roles. We sort it so we can merge out duplicates.      for my $reactionID (@reactions) {
801          my @roles = sort @{$reactionsToRoles{$reactionID}};          # Get this reaction's list of roles. The results will be EC numbers.
802          my $lastRole = "";          my @roles = $fig->catalyzed_by($reactionID);
803          # Loop through the roles, creating catalyzation records.          # Loop through the roles, creating catalyzation records.
804          for my $thisRole (@roles) {          for my $thisRole (@roles) {
805              if ($thisRole ne $lastRole) {              if (exists $ecToRoles{$thisRole}) {
806                  $loadCatalyzes->Put($thisRole, $reactionID);                  $loadCatalyzes->Put($ecToRoles{$thisRole}, $reactionID);
807              }              }
808          }          }
809      }      }
# Line 1256  Line 1240 
1240    
1241  The following relations are loaded by this method.  The following relations are loaded by this method.
1242    
1243        Reaction
1244      ReactionURL      ReactionURL
1245      Compound      Compound
1246      CompoundName      CompoundName
# Line 1283  Line 1268 
1268      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
1269      my $genomeCount = (keys %{$genomeHash});      my $genomeCount = (keys %{$genomeHash});
1270      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1271        my $loadReaction = $self->_TableLoader('Reaction', $genomeCount * 4000);
1272      my $loadReactionURL = $self->_TableLoader('ReactionURL', $genomeCount * 4000);      my $loadReactionURL = $self->_TableLoader('ReactionURL', $genomeCount * 4000);
1273      my $loadCompound = $self->_TableLoader('Compound', $genomeCount * 4000);      my $loadCompound = $self->_TableLoader('Compound', $genomeCount * 4000);
1274      my $loadCompoundName = $self->_TableLoader('CompoundName', $genomeCount * 8000);      my $loadCompoundName = $self->_TableLoader('CompoundName', $genomeCount * 8000);
1275      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $genomeCount * 4000);      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $genomeCount * 4000);
1276      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $genomeCount * 12000);      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $genomeCount * 12000);
1277      Trace("Beginning reaction/compound data load.") if T(2);      Trace("Beginning reaction/compound data load.") if T(2);
1278      # Create a hash to remember the compounds we've generated in the compound table.      # First we create the compounds.
1279      my %compoundHash = ();      my @compounds = $fig->all_compounds();
1280      # Loop through the reactions.      for my $cid (@compounds) {
1281            # Check for names.
1282            my @names = $fig->names_of_compound($cid);
1283            # Each name will be given a priority number, starting with 1.
1284            my $prio = 1;
1285            for my $name (@names) {
1286                $loadCompoundName->Put($cid, $name, $prio++);
1287            }
1288            # Create the main compound record. Note that the first name
1289            # becomes the label.
1290            my $label = (@names > 0 ? $names[0] : $cid);
1291            $loadCompound->Put($cid, $label);
1292            # Check for a CAS ID.
1293            my $cas = $fig->cas($cid);
1294            if ($cas) {
1295                $loadCompoundCAS->Put($cid, $cas);
1296            }
1297        }
1298        # All the compounds are set up, so we need to loop through the reactions next. First,
1299        # we initialize the discriminator index. This is a single integer used to insure
1300        # duplicate elements in a reaction are not accidentally collapsed.
1301        my $discrim = 0;
1302      my @reactions = $fig->all_reactions();      my @reactions = $fig->all_reactions();
1303      for my $reactionID (@reactions) {      for my $reactionID (@reactions) {
1304            # Create the reaction record.
1305            $loadReaction->Put($reactionID, $fig->reversible($reactionID));
1306          # Compute the reaction's URL.          # Compute the reaction's URL.
1307          my $url = HTML::reaction_link($reactionID);          my $url = HTML::reaction_link($reactionID);
1308          # Put it in the ReactionURL table.          # Put it in the ReactionURL table.
# Line 1302  Line 1311 
1311          # substrates first and then products.          # substrates first and then products.
1312          for my $product (0, 1) {          for my $product (0, 1) {
1313              # Get the compounds of the current type for the current reaction. FIG will              # Get the compounds of the current type for the current reaction. FIG will
1314              # give us 3-tuples: [ID, Stoichometry, main-flag]. At this time we do not              # give us 3-tuples: [ID, stoichiometry, main-flag]. At this time we do not
1315              # have location data in SEED, so it defaults to the empty string.              # have location data in SEED, so it defaults to the empty string.
1316              my @compounds = $fig->reaction2comp($reactionID, $product);              my @compounds = $fig->reaction2comp($reactionID, $product);
1317              for my $compData (@compounds) {              for my $compData (@compounds) {
1318                  # Extract the compound data from the current tuple.                  # Extract the compound data from the current tuple.
1319                  my ($cid, $stoich, $main) = @{$compData};                  my ($cid, $stoich, $main) = @{$compData};
1320                  # Link the compound to the reaction.                  # Link the compound to the reaction.
1321                  $loadIsAComponentOf->Put($cid, $reactionID, "", $main, $product, $stoich);                  $loadIsAComponentOf->Put($cid, $reactionID, $discrim++, "", $main,
1322                  # If this is a new compound, we need to create its table entries.                                           $product, $stoich);
                 if (! exists $compoundHash{$cid}) {  
                     $compoundHash{$cid} = 1;  
                     # Create the main compound record and denote we've done it.  
                     $loadCompound->Put($cid);  
                     # Check for a CAS ID.  
                     my $cas = $fig->cas($cid);  
                     if ($cas) {  
                         $loadCompoundCAS->Put($cid, $cas);  
                     }  
                     # Check for names.  
                     my @names = $fig->names_of_compound($cid);  
                     # Each name will be given a priority number, starting with 1.  
                     my $prio = 0;  
                     for my $name (@names) {  
                         $loadCompoundName->Put($cid, $name, $prio++);  
                     }  
                 }  
1323              }              }
1324          }          }
1325      }      }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3