[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.80, Wed Dec 20 20:04:58 2006 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 608  Line 611 
611                      # [name, value, value with URL]. (We don't need the PEG, since                      # [name, value, value with URL]. (We don't need the PEG, since
612                      # we already know it.)                      # we already know it.)
613                      my @attributes = map { [$_->[1], $_->[2], Tracer::CombineURL($_->[2], $_->[3])] }                      my @attributes = map { [$_->[1], $_->[2], Tracer::CombineURL($_->[2], $_->[3])] }
614                                           $fig->get_attributes($featureID);                                           @{$attributes->{$featureID}};
615                      # Now we process each of the special attributes.                      # Now we process each of the special attributes.
616                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
617                                           1, [0,2], '^(essential|potential_essential)$',                                           1, [0,2], '^(essential|potential_essential)$',
# Line 634  Line 637 
637                      my $keywordString = "";                      my $keywordString = "";
638                      my $bustedString = "";                      my $bustedString = "";
639                      for my $keyword (@keywords) {                      for my $keyword (@keywords) {
640                          if (length $keyword >= 4) {                          if (length $keyword >= 3) {
641                              $keywordString .= " $keyword";                              $keywordString .= " $keyword";
642                              if ($keyword =~ /-/) {                              if ($keyword =~ /-/) {
643                                  my @words = grep { length($_) >= 4 } split /-/, $keyword;                                  my @words = split /-/, $keyword;
644                                  $bustedString .= join(" ", "", @words);                                  $bustedString .= join(" ", "", @words);
645                              }                              }
646                          }                          }
# Line 1005  Line 1008 
1008              my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};              my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};
1009              my $featureCount = 0;              my $featureCount = 0;
1010              my $propertyCount = 0;              my $propertyCount = 0;
1011                # Get the properties for this genome's features.
1012                my $attributes = GetGenomeAttributes($fig, $genomeID, \@features);
1013                Trace("Property hash built for $genomeID.") if T(3);
1014              # Loop through the features, creating HasProperty records.              # Loop through the features, creating HasProperty records.
1015              for my $fid (@features) {              for my $fid (@features) {
1016                  # 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
1017                  # to insure we do not get any genome attributes.                  # to insure we do not get any genome attributes.
1018                  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, ''];  
                 }  
1019                  if (scalar @attributeList) {                  if (scalar @attributeList) {
1020                      $featureCount++;                      $featureCount++;
1021                  }                  }
# Line 2032  Line 2031 
2031      # Return the load statistics.      # Return the load statistics.
2032      return $retVal;      return $retVal;
2033  }  }
2034    =head3 GetGenomeAttributes
2035    
2036    C<< my $aHashRef = GetGenomeAttributes($fig, $genomeID, \@fids); >>
2037    
2038    Return a hash of attributes keyed on feature ID. This method gets all the attributes
2039    for all the features of a genome in a single call, then organizes them into a hash.
2040    
2041    =over 4
2042    
2043    =item fig
2044    
2045    FIG-like object for accessing attributes.
2046    
2047    =item genomeID
2048    
2049    ID of the genome who's attributes are desired.
2050    
2051    =item fids
2052    
2053    Reference to a list of the feature IDs whose attributes are to be kept.
2054    
2055    =item RETURN
2056    
2057    Returns a reference to a hash. The key of the hash is the feature ID. The value is the
2058    reference to a list of the feature's attribute tuples. Each tuple contains the feature ID,
2059    the attribute key, and one or more attribute values.
2060    
2061    =back
2062    
2063    =cut
2064    
2065    sub GetGenomeAttributes {
2066        # Get the parameters.
2067        my ($fig, $genomeID, $fids) = @_;
2068        # Declare the return variable.
2069        my $retVal = {};
2070        # Get the attributes.
2071        my @aList = $fig->get_attributes("fig|$genomeID%");
2072        # Initialize the hash. This not only enables us to easily determine which FIDs to
2073        # keep, it insures that the caller sees a list reference for every known fid,
2074        # simplifying the logic.
2075        for my $fid (@{$fids}) {
2076            $retVal->{$fid} = [];
2077        }
2078        # Populate the hash.
2079        for my $aListEntry (@aList) {
2080            my $fid = $aListEntry->[0];
2081            if (exists $retVal->{$fid}) {
2082                push @{$retVal->{$fid}}, $aListEntry;
2083            }
2084        }
2085        # Return the result.
2086        return $retVal;
2087    }
2088    
2089  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3