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

Diff of /Sprout/SubsystemSaplingLoader.pm

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

revision 1.2, Thu Feb 5 07:26:14 2009 UTC revision 1.3, Mon Mar 2 22:37:05 2009 UTC
# Line 58  Line 58 
58      # Get the parameters.      # Get the parameters.
59      my ($class, $erdb, $options) = @_;      my ($class, $erdb, $options) = @_;
60      # Create the table list.      # Create the table list.
61      my @tables = sort qw(Subsystem Describes Variant Includes Role IsClassFor      my @tables = sort qw(Subsystem IsClassFor SubsystemClass IsSuperclassOf Includes
62                           SubsystemClass IsSuperclassOf IsImplementedBy                           Describes Role Variant IsRoleOf IsImplementedBy MachineRole
63                           MolecularMachine IsMachineOf MachineRole Uses                           IsMachineOf MolecularMachine IsContainedIn Uses);
                          IsContainedIn IsRoleOf);  
64      # Create the BaseSaplingLoader object.      # Create the BaseSaplingLoader object.
65      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);      my $retVal = BaseSaplingLoader::new($class, $erdb, $options, @tables);
66      # Return it.      # Return it.
# Line 138  Line 137 
137      my %subClassHash = ();      my %subClassHash = ();
138      # Loop through the subsystems.      # Loop through the subsystems.
139      for my $subsystem (keys %$subHash) {      for my $subsystem (keys %$subHash) {
140          # Compute this subsystem's ID.          Trace("Processing subsystem $subsystem.") if T(ERDBLoadGroup => 3);
         my $subsystemID = $erdb->SubsystemID($subsystem);  
         Trace("Processing subsystem $subsystemID ($subsystem).") if T(3);  
141          # Get the FIG subsystem object.          # Get the FIG subsystem object.
142          my $ssData = $fig->get_subsystem($subsystem);          my $ssData = $fig->get_subsystem($subsystem);
         my ($subsystemName, $subID) = $self->AnalyzeSubsystemName($subsystem);  
143          # Get the subsystem properties.          # Get the subsystem properties.
144          my $curator = $ssData->get_curator();          my $curator = $ssData->get_curator();
145          my $description = $ssData->get_description();          my $description = $ssData->get_description();
146          my $notes = $ssData->get_notes();          my $notes = $ssData->get_notes();
147          my $version = $ssData->get_version();          my $version = $ssData->get_version();
148          $self->PutE(Subsystem => $subID, curator => $curator,          $self->PutE(Subsystem => $subsystem, curator => $curator,
149                      description => $description, notes => $notes,                      description => $description, notes => $notes,
150                      name => $subsystemName, version => $version);                      version => $version);
151          # Get this subsystem's roles.          # Get this subsystem's roles.
152          my @roles = $ssData->get_roles();          my @roles = $ssData->get_roles();
153          # This will track the column number for the role.          # This will track the column number for the role.
154          my $col = 0;          my $col = 0;
155          # Loop through the roles.          # Loop through the roles.
156          for my $role (@roles) {          for my $role (@roles) {
157              # Compute this role's ID and type.              # Compute this role's type.
             my ($roleName, $roleID) = $self->AnalyzeSubsystemName($role);  
158              my $hypothetical = ($role =~ /hypothetical/i ? 1 : 0);              my $hypothetical = ($role =~ /hypothetical/i ? 1 : 0);
159              # Create its entity.              # Create its entity.
160              $self->PutE(Role => $roleID, hypothetical => $hypothetical,              $self->PutE(Role => $role, hypothetical => $hypothetical);
                         name => $roleName);  
161              # Connect it to the subsystem.              # Connect it to the subsystem.
162              $self->PutR(Includes => $subID, $roleID,              $self->PutR(Includes => $subsystem, $role,
163                          abbreviation => $ssData->get_abbr_for_role($role),                          abbreviation => $ssData->get_abbr_for_role($role),
164                          sequence => $col++)                          sequence => $col++)
165          }          }
# Line 176  Line 170 
170              # Create the class record.              # Create the class record.
171              $self->CreateClass($class);              $self->CreateClass($class);
172              # Connect it to the subsystem.              # Connect it to the subsystem.
173              $self->PutR(IsClassFor => $class, $subID);              $self->PutR(IsClassFor => $class, $subsystem);
174              # Move up the hierarchy.              # Move up the hierarchy.
175              while (my $newClass = pop @$classes) {              while (my $newClass = pop @$classes) {
176                  $self->CreateClass($newClass);                  $self->CreateClass($newClass);
# Line 200  Line 194 
194          # Create the variants.          # Create the variants.
195          for my $variant (keys %variants) {          for my $variant (keys %variants) {
196              # The variant key is the subsystem ID plus the variant code.              # The variant key is the subsystem ID plus the variant code.
197              my $variantID = "$subID:$variant";              my $variantID = "$subsystem:$variant";
198              # At this time, the role rule is not available, so we only have              # At this time, the role rule is not available, so we only have
199              # the comment.              # the comment.
200              $self->PutE(Variant => $variantID, comment => $variants{$variant},              $self->PutE(Variant => $variantID, comment => $variants{$variant},
201                          role_rule => '');                          role_rule => '');
202              # Link the subsystem to the variant.              # Link the subsystem to the variant.
203              $self->PutR(Describes => $subID, $variantID);              $self->PutR(Describes => $subsystem, $variantID);
204          }          }
205      }      }
206  }  }
# Line 261  Line 255 
255      # machine.      # machine.
256      for my $subName (@subNames) {      for my $subName (@subNames) {
257          $self->Track(MolecularMachines => $subName, 100);          $self->Track(MolecularMachines => $subName, 100);
         # Compute the subsystem ID.  
         my (undef, $subID) = $self->AnalyzeSubsystemName($subName);  
258          # Get the subsystem object.          # Get the subsystem object.
259          my $ssData = $fig->get_subsystem($subName);          my $ssData = $fig->get_subsystem($subName);
260            # Now we find the molecular machines for this subsystem/genome pair.
261            my @rows = $ssData->get_genomes();
262            for (my $gidx = 0; $gidx <= $#rows; $gidx++) {
263                my ($rowGenome, $regionString) = split /:/, $rows[$gidx], 2;
264                if ($rowGenome eq $genomeID) {
265                    # Here we're positioned on a row for our genome. If it is
266                    # a region-restricted molecular machine, then the region
267                    # string will be defined. If it's global, we use an empty
268                    # string for the region.
269                    $regionString ||= "";
270          # Create the molecular machine. To do that, we need the variant code          # Create the molecular machine. To do that, we need the variant code
271          # for this genome.          # for this genome.
         my $gidx = $ssData->get_genome_index($genomeID);  
272          my $raw_variant_code = $ssData->get_variant_code($gidx);          my $raw_variant_code = $ssData->get_variant_code($gidx);
273          # Check for a leading asterisk. This means the variant assignment is not          # Check for a leading asterisk. This means the variant assignment is not
274          # curated.          # curated.
# Line 278  Line 279 
279          my $variant_type = ($variant_code =~ /^0/ ? 'incomplete' :          my $variant_type = ($variant_code =~ /^0/ ? 'incomplete' :
280                              $variant_code =~ /^-/ ? 'vacant' : 'normal');                              $variant_code =~ /^-/ ? 'vacant' : 'normal');
281          # Create the variant and machine IDs.          # Create the variant and machine IDs.
282          my $variantID = "$subID:$variant_code";                  my $variantID = "$subName:$variant_code";
283          my $machineID = "$variantID:$genomeID";                  my $machineID = ERDB::DigestKey("$variantID:$genomeID:$regionString");
284          # Create the molecular machine and connect it to the genome and          # Create the molecular machine and connect it to the genome and
285          # subsystem.          # subsystem.
286          $self->PutE(MolecularMachine => $machineID, type => $variant_type,          $self->PutE(MolecularMachine => $machineID, type => $variant_type,
287                      curated => $curated);                              curated => $curated, region => $regionString);
288          $self->PutR(IsImplementedBy => $variantID, $machineID);          $self->PutR(IsImplementedBy => $variantID, $machineID);
289          $self->PutR(Uses => $genomeID, $machineID);          $self->PutR(Uses => $genomeID, $machineID);
290          # Now we loop through the subsystem's roles, creating the MachineRoles.          # Now we loop through the subsystem's roles, creating the MachineRoles.
# Line 294  Line 295 
295              # Get this role's abbreviation.              # Get this role's abbreviation.
296              my $ridx = $ssData->get_role_index($role);              my $ridx = $ssData->get_role_index($role);
297              my $abbr = $ssData->get_role_abbr($ridx);              my $abbr = $ssData->get_role_abbr($ridx);
             # Compute the role's ID.  
             my (undef, $roleID) = $self->AnalyzeSubsystemName($role);  
298              # Create the machine-role ID.              # Create the machine-role ID.
299              my $machineRoleID = "$machineID:$abbr";              my $machineRoleID = "$machineID:$abbr";
300              # Create the machine-role and connect it to the role and the              # Create the machine-role and connect it to the role and the
301              # machine.              # machine.
302              $self->PutE(MachineRole => $machineRoleID);              $self->PutE(MachineRole => $machineRoleID);
303              $self->PutR(IsMachineOf => $machineID, $machineRoleID);              $self->PutR(IsMachineOf => $machineID, $machineRoleID);
304              $self->PutR(IsRoleOf => $roleID, $machineRoleID);                      $self->PutR(IsRoleOf => $role, $machineRoleID);
305              # Now get a list of the features in this cell.              # Now get a list of the features in this cell.
306              my @pegs = $ssData->get_pegs_from_cell($genomeID, $ridx);              my @pegs = $ssData->get_pegs_from_cell($genomeID, $ridx);
307              # Connect them to the cell.              # Connect them to the cell.
# Line 312  Line 311 
311          }          }
312      }      }
313  }  }
314        }
315    }
316    
317  =head3 CreateClass  =head3 CreateClass
318    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3