[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.40, Thu Jun 8 15:37:32 2006 UTC revision 1.45, Sun Jun 25 07:53:37 2006 UTC
# Line 785  Line 785 
785                          if ($pegCount > 0) {                          if ($pegCount > 0) {
786                              Trace("$pegCount PEGs in $cellCount cells for $genomeID.") if T(3);                              Trace("$pegCount PEGs in $cellCount cells for $genomeID.") if T(3);
787                              $loadParticipatesIn->Put($genomeID, $subsysID, $variantCode);                              $loadParticipatesIn->Put($genomeID, $subsysID, $variantCode);
                             # Partition the PEGs found into clusters.  
                             my @clusters = $fig->compute_clusters(\@pegsFound, $sub);  
788                              # Create a hash mapping PEG IDs to cluster numbers.                              # Create a hash mapping PEG IDs to cluster numbers.
789                              # We default to -1 for all of them.                              # We default to -1 for all of them.
790                              my %clusterOf = map { $_ => -1 } @pegsFound;                              my %clusterOf = map { $_ => -1 } @pegsFound;
791                                # Partition the PEGs found into clusters.
792                                my @clusters = $fig->compute_clusters([keys %clusterOf], $sub);
793                              for (my $i = 0; $i <= $#clusters; $i++) {                              for (my $i = 0; $i <= $#clusters; $i++) {
794                                  my $subList = $clusters[$i];                                  my $subList = $clusters[$i];
795                                  for my $peg (@{$subList}) {                                  for my $peg (@{$subList}) {
# Line 1042  Line 1042 
1042                  # Get the annotation tuple.                  # Get the annotation tuple.
1043                  my ($peg, $timestamp, $user, $text) = @{$tuple};                  my ($peg, $timestamp, $user, $text) = @{$tuple};
1044                  # Here we fix up the annotation text. "\r" is removed,                  # Here we fix up the annotation text. "\r" is removed,
1045                  # and "\t" and "\n" are escaped. Note we use the "s"                  # and "\t" and "\n" are escaped. Note we use the "gs"
1046                  # modifier so that new-lines inside the text do not                  # modifier so that new-lines inside the text do not
1047                  # stop the substitution search.                  # stop the substitution search.
1048                  $text =~ s/\r//gs;                  $text =~ s/\r//gs;
# Line 1396  Line 1396 
1396      return $retVal;      return $retVal;
1397  }  }
1398    
1399    =head3 LoadSynonymData
1400    
1401    C<< my $stats = $spl->LoadSynonymData(); >>
1402    
1403    Load the synonym groups into Sprout.
1404    
1405    The following relations are loaded by this method.
1406    
1407        SynonymGroup
1408        IsSynonymGroupFor
1409    
1410    The source information for these relations is taken from the C<maps_to_id> method
1411    of the B<FIG> object. The process starts from the features, so it is possible
1412    that there will be duplicates in the SynonymGroup load file, since the relationship
1413    is one-to-many toward the features. The automatic sort on primary entity relations
1414    will fix this for us.
1415    
1416    =over 4
1417    
1418    =item RETURNS
1419    
1420    Returns a statistics object for the loads.
1421    
1422    =back
1423    
1424    =cut
1425    #: Return Type $%;
1426    sub LoadSynonymData {
1427        # Get this object instance.
1428        my ($self) = @_;
1429        # Get the FIG object.
1430        my $fig = $self->{fig};
1431        # Get the genome hash.
1432        my $genomeHash = $self->{genomes};
1433        # Create a load object for the table we're loading.
1434        my $loadSynonymGroup = $self->_TableLoader('SynonymGroup');
1435        my $loadIsSynonymGroupFor = $self->_TableLoader('IsSynonymGroupFor');
1436        if ($self->{options}->{loadOnly}) {
1437            Trace("Loading from existing files.") if T(2);
1438        } else {
1439            Trace("Generating synonym group data.") if T(2);
1440            # Loop through the genomes.
1441            for my $genomeID (sort keys %{$genomeHash}) {
1442                Trace("Processing $genomeID.") if T(3);
1443                # Get all of the features for this genome. The only method that does this is
1444                # all_features_detailed, which returns extra baggage that we discard.
1445                my $featureData = $fig->all_features_detailed($genomeID);
1446                my @fids = map { $_->[0] } @{$featureData};
1447                Trace(scalar(@fids) . " features found for genome $genomeID.") if T(3);
1448                # Loop through the feature IDs.
1449                for my $fid (@fids) {
1450                    # Get the group for this feature.
1451                    my $synonym = $fig->maps_to_id($fid);
1452                    # Only proceed if the synonym is a real group.
1453                    if ($synonym ne $fid) {
1454                        $loadSynonymGroup->Put($synonym);
1455                        $loadIsSynonymGroupFor->Put($synonym, $fid);
1456                    }
1457                }
1458            }
1459        }
1460        # Finish the load.
1461        my $retVal = $self->_FinishAll();
1462        return $retVal;
1463    }
1464    
1465    
1466  =head2 Internal Utility Methods  =head2 Internal Utility Methods
1467    
1468  =head3 TableLoader  =head3 TableLoader

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.45

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3