[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.11, Thu Sep 15 23:07:59 2005 UTC revision 1.15, Fri Sep 16 04:12:05 2005 UTC
# Line 650  Line 650 
650      # roles. We do this by looping through the subsystems and creating a      # roles. We do this by looping through the subsystems and creating a
651      # 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
652      # duplicates. As we move along, we'll connect the roles and subsystems.      # duplicates. As we move along, we'll connect the roles and subsystems.
653        my ($genomeID, $roleID);
654      my %roleData = ();      my %roleData = ();
655      for my $subsysID (@subsysIDs) {      for my $subsysID (@subsysIDs) {
656          Trace("Creating subsystem $subsysID.") if T(3);          Trace("Creating subsystem $subsysID.") if T(3);
657          $loadSubsystem->Add("subsystemIn");          $loadSubsystem->Add("subsystemIn");
658          # Create the subsystem record.          # Create the subsystem record.
659          $loadSubsystem->Put($subsysID);          $loadSubsystem->Put($subsysID);
660          # Get the subsystem's roles.          # Get the subsystem object.
661          my @roles = $fig->subsystem_to_roles($subsysID);          my $sub = $fig->get_subsystem($subsysID);
662          # Connect the roles to the subsystem. If a role is new, we create          # Connect it to its roles.
663          # a role record for it.          for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {
         for my $roleID (@roles) {  
664              $loadOccursInSubsystem->Add("roleIn");              $loadOccursInSubsystem->Add("roleIn");
665              $loadOccursInSubsystem->Put($roleID, $subsysID);              $loadOccursInSubsystem->Put($roleID, $subsysID);
666              if (! exists $roleData{$roleID}) {              if (! exists $roleData{$roleID}) {
# Line 668  Line 668 
668                  $roleData{$roleID} = 1;                  $roleData{$roleID} = 1;
669              }              }
670          }          }
671          # Now all roles for this subsystem have been filled in. We create the          # Now we create the spreadsheet for the subsystem by matching roles to
672          # spreadsheet by matches roles to genomes. To do this, we need to          # genomes. Each genome is a row and each role is a column. We may need
673          # get the genomes on the sheet.          # to actually create the roles as we find them.
674          Trace("Creating subsystem $subsysID spreadsheet.") if T(3);          Trace("Creating subsystem $subsysID spreadsheet.") if T(3);
675          my @genomes = map { $_->[0] } @{$fig->subsystem_genomes($subsysID)};          for (my $row = 0; defined($genomeID = $sub->get_genome($row)); $row++) {
676          for my $genomeID (@genomes) {              # Only proceed if this is one of our genomes.
             # Only process this genome if it's one of ours.  
677              if (exists $genomeHash->{$genomeID}) {              if (exists $genomeHash->{$genomeID}) {
678                  # Connect the genome to the subsystem.                  # Count the PEGs and cells found for verification purposes.
679                  $loadParticipatesIn->Put($genomeID, $subsysID);                  my $pegCount = 0;
680                    my $cellCount = 0;
681                  # Loop through the subsystem's roles. We use an index because it is                  # Loop through the subsystem's roles. We use an index because it is
682                  # part of the spreadsheet cell ID.                  # part of the spreadsheet cell ID.
683                  for (my $i = 0; $i <= $#roles; $i++) {                  for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {
                     my $role = $roles[$i];  
684                      # Get the features in the spreadsheet cell for this genome and role.                      # Get the features in the spreadsheet cell for this genome and role.
685                      my @pegs = $fig->pegs_in_subsystem_cell($subsysID, $genomeID, $i);                      my @pegs = $sub->get_pegs_from_cell($row, $col);
686                      # Only proceed if features exist.                      # Only proceed if features exist.
687                      if (@pegs > 0) {                      if (@pegs > 0) {
688                          # Create the spreadsheet cell.                          # Create the spreadsheet cell.
689                          my $cellID = "$subsysID:$genomeID:$i";                          $cellCount++;
690                            my $cellID = "$subsysID:$genomeID:$col";
691                          $loadSSCell->Put($cellID);                          $loadSSCell->Put($cellID);
692                          $loadIsGenomeOf->Put($genomeID, $cellID);                          $loadIsGenomeOf->Put($genomeID, $cellID);
693                          $loadIsRoleOf->Put($role, $cellID);                          $loadIsRoleOf->Put($roleID, $cellID);
694                          $loadHasSSCell->Put($subsysID, $cellID);                          $loadHasSSCell->Put($subsysID, $cellID);
695                          # Attach the features to it.                          # Attach the features to it.
696                          for my $pegID (@pegs) {                          for my $pegID (@pegs) {
697                              $loadContainsFeature->Put($cellID, $pegID);                              $loadContainsFeature->Put($cellID, $pegID);
698                                $pegCount++;
699                            }
700                          }                          }
701                      }                      }
702                    # If we found some cells for this genome, denote it participates in the
703                    # subsystem.
704                    if ($pegCount > 0) {
705                        Trace("$pegCount PEGs in $cellCount cells for $genomeID.") if T(3);
706                        $loadParticipatesIn->Put($genomeID, $subsysID);
707                  }                  }
708              }              }
709          }          }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3