[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.14, Fri Sep 16 02:38:49 2005 UTC revision 1.15, Fri Sep 16 04:12:05 2005 UTC
# Line 629  Line 629 
629      # Get the genome hash. We'll use it to filter the genomes in each      # Get the genome hash. We'll use it to filter the genomes in each
630      # spreadsheet.      # spreadsheet.
631      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my @genomes = sort keys %{$genomeHash};  
632      # Get the subsystem hash. This lists the subsystems we'll process.      # Get the subsystem hash. This lists the subsystems we'll process.
633      my $subsysHash = $self->{subsystems};      my $subsysHash = $self->{subsystems};
634      my @subsysIDs = sort keys %{$subsysHash};      my @subsysIDs = sort keys %{$subsysHash};
# Line 651  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 669  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 matching roles to genomes.          # genomes. Each genome is a row and each role is a column. We may need
673            # 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          for my $genomeID (@genomes) {          for (my $row = 0; defined($genomeID = $sub->get_genome($row)); $row++) {
676                # Only proceed if this is one of our genomes.
677                if (exists $genomeHash->{$genomeID}) {
678              # Count the PEGs and cells found for verification purposes.              # Count the PEGs and cells found for verification purposes.
679              my $pegCount = 0;              my $pegCount = 0;
680              my $cellCount = 0;              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                      $cellCount++;                      $cellCount++;
690                      my $cellID = "$subsysID:$genomeID:$i";                          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) {
# Line 706  Line 707 
707              }              }
708          }          }
709      }      }
710        }
711      # Finish the load.      # Finish the load.
712      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
713      return $retVal;      return $retVal;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3