[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.79, Sat Nov 18 20:38:45 2006 UTC revision 1.81, Wed Feb 21 13:21:42 2007 UTC
# Line 521  Line 521 
521              # Sort and count the list.              # Sort and count the list.
522              my @featureTuples = sort { $a->[0] cmp $b->[0] } @{$features};              my @featureTuples = sort { $a->[0] cmp $b->[0] } @{$features};
523              my $count = scalar @featureTuples;              my $count = scalar @featureTuples;
524                my @fids = map { $_->[0] } @featureTuples;
525              Trace("$count features found for genome $genomeID.") if T(3);              Trace("$count features found for genome $genomeID.") if T(3);
526                # Get the attributes for this genome and put them in a hash by feature ID.
527                my $attributes = GetGenomeAttributes($fig, $genomeID, \@fids);
528              # Set up for our duplicate-feature check.              # Set up for our duplicate-feature check.
529              my $oldFeatureID = "";              my $oldFeatureID = "";
530              # Loop through the features.              # Loop through the features.
# Line 539  Line 542 
542                      # feature ID, the taxonomy, and the organism name.                      # feature ID, the taxonomy, and the organism name.
543                      my @keywords = ($genomeID, $featureID, $fig->genus_species($genomeID),                      my @keywords = ($genomeID, $featureID, $fig->genus_species($genomeID),
544                                      $fig->taxonomy_of($genomeID));                                      $fig->taxonomy_of($genomeID));
545                      # Get the functional assignment and aliases. This                      # Get the functional assignment and aliases.
546                      # depends on the feature type.                      my $assignment = $fig->function_of($featureID);
                     my $assignment;  
                     if ($type eq "peg") {  
                         $assignment = $fig->function_of($featureID);  
547                          # Create the aliases.                          # Create the aliases.
548                          for my $alias ($fig->feature_aliases($featureID)) {                          for my $alias ($fig->feature_aliases($featureID)) {
549                              $loadFeatureAlias->Put($featureID, $alias);                              $loadFeatureAlias->Put($featureID, $alias);
550                              push @keywords, $alias;                              push @keywords, $alias;
551                          }                          }
                     } else {  
                         # For other types, the assignment is the first (and ONLY) alias.  
                         ($assignment) = $fig->feature_aliases($featureID);  
                     }  
552                      Trace("Assignment for $featureID is: $assignment") if T(4);                      Trace("Assignment for $featureID is: $assignment") if T(4);
553                      # Break the assignment into words and shove it onto the                      # Break the assignment into words and shove it onto the
554                      # keyword list.                      # keyword list.
# Line 608  Line 604 
604                      # [name, value, value with URL]. (We don't need the PEG, since                      # [name, value, value with URL]. (We don't need the PEG, since
605                      # we already know it.)                      # we already know it.)
606                      my @attributes = map { [$_->[1], $_->[2], Tracer::CombineURL($_->[2], $_->[3])] }                      my @attributes = map { [$_->[1], $_->[2], Tracer::CombineURL($_->[2], $_->[3])] }
607                                           $fig->get_attributes($featureID);                                           @{$attributes->{$featureID}};
608                      # Now we process each of the special attributes.                      # Now we process each of the special attributes.
609                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
610                                           1, [0,2], '^(essential|potential_essential)$',                                           1, [0,2], '^(essential|potential_essential)$',
# Line 634  Line 630 
630                      my $keywordString = "";                      my $keywordString = "";
631                      my $bustedString = "";                      my $bustedString = "";
632                      for my $keyword (@keywords) {                      for my $keyword (@keywords) {
633                          if (length $keyword >= 4) {                          if (length $keyword >= 3) {
634                              $keywordString .= " $keyword";                              $keywordString .= " $keyword";
635                              if ($keyword =~ /-/) {                              if ($keyword =~ /-/) {
636                                  my @words = grep { length($_) >= 4 } split /-/, $keyword;                                  my @words = split /-/, $keyword;
637                                  $bustedString .= join(" ", "", @words);                                  $bustedString .= join(" ", "", @words);
638                              }                              }
639                          }                          }
# Line 1005  Line 1001 
1001              my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};              my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};
1002              my $featureCount = 0;              my $featureCount = 0;
1003              my $propertyCount = 0;              my $propertyCount = 0;
1004                # Get the properties for this genome's features.
1005                my $attributes = GetGenomeAttributes($fig, $genomeID, \@features);
1006                Trace("Property hash built for $genomeID.") if T(3);
1007              # Loop through the features, creating HasProperty records.              # Loop through the features, creating HasProperty records.
1008              for my $fid (@features) {              for my $fid (@features) {
1009                  # Get all attributes for this feature. We do this one feature at a time                  # Get all attributes for this feature. We do this one feature at a time
1010                  # to insure we do not get any genome attributes.                  # to insure we do not get any genome attributes.
1011                  my @attributeList = $fig->get_attributes($fid);                  my @attributeList = @{$attributes->{$fid}};
                 # Add essentiality and virulence attributes.  
                 if ($fig->essential($fid)) {  
                     push @attributeList, [$fid, 'essential', 1, ''];  
                 }  
                 if ($fig->virulent($fid)) {  
                     push @attributeList, [$fid, 'virulent', 1, ''];  
                 }  
1012                  if (scalar @attributeList) {                  if (scalar @attributeList) {
1013                      $featureCount++;                      $featureCount++;
1014                  }                  }
# Line 2032  Line 2024 
2024      # Return the load statistics.      # Return the load statistics.
2025      return $retVal;      return $retVal;
2026  }  }
2027    =head3 GetGenomeAttributes
2028    
2029    C<< my $aHashRef = GetGenomeAttributes($fig, $genomeID, \@fids); >>
2030    
2031    Return a hash of attributes keyed on feature ID. This method gets all the attributes
2032    for all the features of a genome in a single call, then organizes them into a hash.
2033    
2034    =over 4
2035    
2036    =item fig
2037    
2038    FIG-like object for accessing attributes.
2039    
2040    =item genomeID
2041    
2042    ID of the genome who's attributes are desired.
2043    
2044    =item fids
2045    
2046    Reference to a list of the feature IDs whose attributes are to be kept.
2047    
2048    =item RETURN
2049    
2050    Returns a reference to a hash. The key of the hash is the feature ID. The value is the
2051    reference to a list of the feature's attribute tuples. Each tuple contains the feature ID,
2052    the attribute key, and one or more attribute values.
2053    
2054    =back
2055    
2056    =cut
2057    
2058    sub GetGenomeAttributes {
2059        # Get the parameters.
2060        my ($fig, $genomeID, $fids) = @_;
2061        # Declare the return variable.
2062        my $retVal = {};
2063        # Get the attributes.
2064        my @aList = $fig->get_attributes("fig|$genomeID%");
2065        # Initialize the hash. This not only enables us to easily determine which FIDs to
2066        # keep, it insures that the caller sees a list reference for every known fid,
2067        # simplifying the logic.
2068        for my $fid (@{$fids}) {
2069            $retVal->{$fid} = [];
2070        }
2071        # Populate the hash.
2072        for my $aListEntry (@aList) {
2073            my $fid = $aListEntry->[0];
2074            if (exists $retVal->{$fid}) {
2075                push @{$retVal->{$fid}}, $aListEntry;
2076            }
2077        }
2078        # Return the result.
2079        return $retVal;
2080    }
2081    
2082  1;  1;

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.81

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3