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

Diff of /Sprout/Sprout.pm

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

revision 1.92, Mon Oct 16 07:41:50 2006 UTC revision 1.96, Wed Dec 6 03:37:26 2006 UTC
# Line 921  Line 921 
921      my ($self, $genomeID) = @_;      my ($self, $genomeID) = @_;
922      # Declare the return variable.      # Declare the return variable.
923      my $retVal = {};      my $retVal = {};
924      # Query the genome's features and annotations. We'll put the oldest annotations      # Query the genome's features.
925      # first so that the last assignment to go into the hash will be the correct one.      my $query = $self->Get(['HasFeature', 'Feature'], "HasFeature(from-link) = ?",
     my $query = $self->Get(['HasFeature', 'IsTargetOfAnnotation', 'Annotation'],  
                            "HasFeature(from-link) = ? ORDER BY Annotation(time)",  
926                             [$genomeID]);                             [$genomeID]);
927      # Loop through the annotations.      # Loop through the features.
928      while (my $data = $query->Fetch) {      while (my $data = $query->Fetch) {
929          # Get the feature ID and annotation text.          # Get the feature ID and assignment.
930          my ($fid, $annotation) = $data->Values(['HasFeature(to-link)',          my ($fid, $assignment) = $data->Values(['Feature(id)', 'Feature(assignment)']);
931                                                  'Annotation(annotation)']);          if ($assignment) {
         # Check to see if this is an assignment. Note that the user really  
         # doesn't matter to us, other than we use it to determine whether or  
         # not this is an assignment.  
         my ($user, $assignment) = _ParseAssignment('fig', $annotation);  
         if ($user) {  
             # Here it's an assignment. We put it in the return hash, overwriting  
             # any older assignment that might be present.  
932              $retVal->{$fid} = $assignment;              $retVal->{$fid} = $assignment;
933          }          }
934      }      }
# Line 1299  Line 1290 
1290  Return the most recently-determined functional assignment of a particular feature.  Return the most recently-determined functional assignment of a particular feature.
1291    
1292  The functional assignment is handled differently depending on the type of feature. If  The functional assignment is handled differently depending on the type of feature. If
1293  the feature is identified by a FIG ID (begins with the string C<fig|>), then a functional  the feature is identified by a FIG ID (begins with the string C<fig|>), then the functional
1294  assignment is a type of annotation. The format of an assignment is described in  assignment is taken from the B<Feature> or C<Annotation> table, depending.
 L</ParseAssignment>. Its worth noting that we cannot filter on the content of the  
 annotation itself because it's a text field; however, this is not a big problem because  
 most features only have a small number of annotations.  
1295    
1296  Each user has an associated list of trusted users. The assignment returned will be the most  Each user has an associated list of trusted users. The assignment returned will be the most
1297  recent one by at least one of the trusted users. If no trusted user list is available, then  recent one by at least one of the trusted users. If no trusted user list is available, then
# Line 1322  Line 1310 
1310    
1311  =item userID (optional)  =item userID (optional)
1312    
1313  ID of the user whose function determination is desired. If omitted, only the latest  ID of the user whose function determination is desired. If omitted, the primary
1314  C<FIG> assignment will be returned.  functional assignment in the B<Feature> table will be returned.
1315    
1316  =item RETURN  =item RETURN
1317    
# Line 1340  Line 1328 
1328      my $retVal;      my $retVal;
1329      # Determine the ID type.      # Determine the ID type.
1330      if ($featureID =~ m/^fig\|/) {      if ($featureID =~ m/^fig\|/) {
1331          # Here we have a FIG feature ID. We must build the list of trusted          # Here we have a FIG feature ID.
1332          # users.          if (!$userID) {
1333                # Use the primary assignment.
1334                ($retVal) = $self->GetEntityValues('Feature', $featureID, ['Feature(assignment)']);
1335            } else {
1336                # We must build the list of trusted users.
1337          my %trusteeTable = ();          my %trusteeTable = ();
1338          # Check the user ID.          # Check the user ID.
1339          if (!$userID) {          if (!$userID) {
# Line 1384  Line 1376 
1376                  }                  }
1377              }              }
1378          }          }
1379            }
1380      } else {      } else {
1381          # Here we have a non-FIG feature ID. In this case the user ID does not          # Here we have a non-FIG feature ID. In this case the user ID does not
1382          # matter. We simply get the information from the External Alias Function          # matter. We simply get the information from the External Alias Function
# Line 1504  Line 1497 
1497          # Peel off the BBHs found.          # Peel off the BBHs found.
1498          my @found = ();          my @found = ();
1499          for my $bbh (@bbhData) {          for my $bbh (@bbhData) {
1500              push @found, $bbh->[0];              my $fid = $bbh->[0];
1501                my $bbGenome = $self->GenomeOf($fid);
1502                if ($bbGenome eq $genomeID) {
1503                    push @found, $fid;
1504                }
1505          }          }
1506          $retVal{$featureID} = \@found;          $retVal{$featureID} = \@found;
1507      }      }
# Line 3184  Line 3181 
3181      return @retVal;      return @retVal;
3182  }  }
3183    
3184    =head3 BBHMatrix
3185    
3186    C<< my %bbhMap = $sprout->BBHMatrix($genomeID, $cutoff, @targets); >>
3187    
3188    Find all the bidirectional best hits for the features of a genome in a
3189    specified list of target genomes. The return value will be a hash mapping
3190    features in the original genome to their bidirectional best hits in the
3191    target genomes.
3192    
3193    =over 4
3194    
3195    =item genomeID
3196    
3197    ID of the genome whose features are to be examined for bidirectional best hits.
3198    
3199    =item cutoff
3200    
3201    A cutoff value. Only hits with a score lower than the cutoff will be returned.
3202    
3203    =item targets
3204    
3205    List of target genomes. Only pairs originating in the original
3206    genome and landing in one of the target genomes will be returned.
3207    
3208    =item RETURN
3209    
3210    Returns a hash mapping each feature in the original genome to a hash mapping its
3211    BBH pegs in the target genomes to their scores.
3212    
3213    =back
3214    
3215    =cut
3216    
3217    sub BBHMatrix {
3218        # Get the parameters.
3219        my ($self, $genomeID, $cutoff, @targets) = @_;
3220        # Declare the return variable.
3221        my %retVal = ();
3222        # Ask for the BBHs.
3223        my @bbhList = FIGRules::BatchBBHs("fig|$genomeID.%", $cutoff, @targets);
3224        # We now have a set of 4-tuples that we need to convert into a hash of hashes.
3225        for my $bbhData (@bbhList) {
3226            my ($peg1, $peg2, $score) = @{$bbhData};
3227            if (! exists $retVal{$peg1}) {
3228                $retVal{$peg1} = { $peg2 => $score };
3229            } else {
3230                $retVal{$peg1}->{$peg2} = $score;
3231            }
3232        }
3233        # Return the result.
3234        return %retVal;
3235    }
3236    
3237  =head3 LowBBHs  =head3 LowBBHs
3238    
3239  C<< my %bbhMap = $sprout->LowBBHs($featureID, $cutoff); >>  C<< my %bbhMap = $sprout->LowBBHs($featureID, $cutoff); >>
# Line 3219  Line 3269 
3269      my @bbhList = FIGRules::BBHData($featureID, $cutoff);      my @bbhList = FIGRules::BBHData($featureID, $cutoff);
3270      # Form the results into the return hash.      # Form the results into the return hash.
3271      for my $pair (@bbhList) {      for my $pair (@bbhList) {
3272          $retVal{$pair->[0]} = $pair->[1];          my $fid = $pair->[0];
3273            if ($self->Exists('Feature', $fid)) {
3274                $retVal{$fid} = $pair->[1];
3275            }
3276      }      }
3277      # Return the result.      # Return the result.
3278      return %retVal;      return %retVal;
# Line 3488  Line 3541 
3541      # Get the parameters.      # Get the parameters.
3542      my ($self, $genomeID, $testFlag) = @_;      my ($self, $genomeID, $testFlag) = @_;
3543      # Perform the delete for the genome's features.      # Perform the delete for the genome's features.
3544      my $retVal = $self->Delete('Feature', "fig|$genomeID.%", $testFlag);      my $retVal = $self->Delete('Feature', "fig|$genomeID.%", testMode => $testFlag);
3545      # Perform the delete for the primary genome data.      # Perform the delete for the primary genome data.
3546      my $stats = $self->Delete('Genome', $genomeID, $testFlag);      my $stats = $self->Delete('Genome', $genomeID, testMode => $testFlag);
3547      $retVal->Accumulate($stats);      $retVal->Accumulate($stats);
3548      # Return the result.      # Return the result.
3549      return $retVal;      return $retVal;

Legend:
Removed from v.1.92  
changed lines
  Added in v.1.96

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3