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

Diff of /Sprout/FeatureSproutLoader.pm

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

revision 1.7, Mon Mar 2 22:22:54 2009 UTC revision 1.8, Mon Mar 16 00:11:19 2009 UTC
# Line 27  Line 27 
27      use DBMaster;      use DBMaster;
28      use HyperLink;      use HyperLink;
29      use FFs;      use FFs;
30        use SOAP::Lite;
31      use base 'BaseSproutLoader';      use base 'BaseSproutLoader';
32    
33  =head1 Sprout Feature Load Group Class  =head1 Sprout Feature Load Group Class
# Line 151  Line 152 
152                  # We need to insure we don't put multiple copies of the same alias                  # We need to insure we don't put multiple copies of the same alias
153                  # in the keyword list, so we'll put all aliases found in this hash.                  # in the keyword list, so we'll put all aliases found in this hash.
154                  my %aliasHash;                  my %aliasHash;
155                    # We need a list of all the aliases. These come from two sources: one
156                    # from the annotation clearinghouse, and one from the detailed features
157                    # list.
158                    my @rawAliasList = split /,/, $aliases;
159                    # Only PEGs appear in the clearinghouse.
160                    if ($type eq 'peg') {
161                        push @rawAliasList, AliasAnalysis::QueryACLH($fig, $featureID);
162                    }
163                  # Loop through the aliases, recording the normal and natural forms/                  # Loop through the aliases, recording the normal and natural forms/
164                  for my $alias (split /,/, $aliases) {                  for my $alias (@rawAliasList) {
165                      # Save the alias.                      # Save the alias.
166                      $aliasHash{$alias} = 1;                      $aliasHash{$alias} = 1;
167                      # Check for a natural form.                      # Check for a natural form.
# Line 498  Line 507 
507  }  }
508    
509    
510    =head3 AliasFix
511    
512        $sl->AliasFix($orgName, $fidArray);
513    
514    Ask the %FIG{Annotation Clearinghouse}% for additional aliases of the
515    features in the specified array. The array should be a result array from
516    the [[FigPm]] method C<all_features_detailed_fast>. The first column of
517    the array contains feature IDs. The third column contains a
518    comma-delimited list of aliases. This method modifies the third column so
519    that it contains any additional aliases available from the Clearinghouse.
520    
521    =over 4
522    
523    =item orgName
524    
525    Organism name for the current genome.
526    
527    =item fidArray
528    
529    Reference to a list of feature data. Each feature is represented by an n-tuple
530    in the array: the tuple's first element is the feature ID, and the third element
531    (which we will be modifying) is a comma-delimited list of aliases.
532    
533    =back
534    
535    =cut
536    
537    sub AliasFix {
538        # Get the parameters.
539        my ($self, $orgName, $fidArray) = @_;
540        # To control the cost of this operation, we process the features in
541        # batches. The batch size is controlled by a FIG_Config parameter.
542        my $fidCount = scalar @$fidArray;
543        my $fidNext;
544        for (my $fidIdx = 0; $fidIdx < $fidCount; $fidIdx = $fidNext) {
545            # Compute the index of the first feature in the next batch.
546            $fidNext = $fidIdx + $FIG_Config::ach_fixup_batch_size;
547            $fidNext = $fidCount if $fidNext > $fidCount;
548            Trace("Processing ACH feature batch from $fidIdx to $fidNext.") if T(3);
549            # The hash below will map the IDs of the features in this batch
550            # to the alias strings we want to fix up.
551            my %batch;
552            for (my $i = $fidIdx; $i < $fidNext; $i++) {
553                # Get this feature ID.
554                my $fid = $fidArray->[$i][0];
555                # Only proceed if it's a PEG.
556                if ($fid =~ /peg/) {
557                    # It is, so put it in the batch hash. The
558                    # value is a reference to the PEG's alias string.
559                    $batch{$fid} = \$fidArray->[$i][2];
560                }
561            }
562            # Now we have our batch. Ask the clearinghouse for any data it might
563            # have about these FIDs.
564            my $resp = SOAP::Lite->uri($FIG_Config::ach_soap)->proxy($FIG_Config::ach_proxy)
565                                 ->get_annotations([keys %batch]);
566            Trace("Processing results from clearinghouse.") if T(3);
567            # Insure we got a result.
568            if (! $resp) {
569                Confess("No response from Clearinghouse.");
570            } elsif ($resp->fault) {
571                Confess("Error requesting alias data from Clearinghouse: " . $resp->faultstring);
572            } else {
573                # Extract the result. It will be a hash mapping FIDs to tuple arrays.
574                my $respHash = $resp->result;
575                # Loop through the result hash.
576                for my $respFid (keys %$respHash) {
577                    # Get a reference to the alias string.
578                    my $pointer = $batch{$respFid};
579                    # Build a hash of the existing aliases.
580                    my %aliasHash = map { $_ => 1 } split /,/, $$pointer;
581                    # Add aliases from the clearinghouse response.
582                    my $tuples = $respHash->{$respFid};
583                    my @newAliases = AliasAnalysis::AnalyzeClearinghouseArray($orgName,
584                                                                              $tuples);
585                    for my $newAlias (@newAliases) {
586                        if (! exists $aliasHash{$newAlias}) {
587                            $aliasHash{$newAlias} = 1;
588                            $self->Add(ACLHaliases => 1);
589                        }
590                    }
591                    # Save the result.
592                    $$pointer = join(",", sort keys %aliasHash);
593                }
594            }
595        }
596    }
597    
598    
599  =head3 SpecialAttribute  =head3 SpecialAttribute
600    
601      my $count = $sl->SpecialAttribute($id, \@attributes, $idxMatch, \@idxValues, $pattern, $tableName, $field);      my $count = $sl->SpecialAttribute($id, \@attributes, $idxMatch, \@idxValues, $pattern, $tableName, $field);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3