[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.76, Fri Nov 3 00:43:22 2006 UTC revision 1.77, Thu Nov 9 21:23:43 2006 UTC
# Line 610  Line 610 
610                                           $fig->get_attributes($featureID);                                           $fig->get_attributes($featureID);
611                      # Now we process each of the special attributes.                      # Now we process each of the special attributes.
612                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
613                                           1, 2, '^(essential|potential_essential)$',                                           1, [0,2], '^(essential|potential_essential)$',
614                                           $loadFeatureEssential)) {                                           $loadFeatureEssential)) {
615                          push @keywords, 'essential';                          push @keywords, 'essential';
616                          $loadFeature->Add('essential');                          $loadFeature->Add('essential');
617                      }                      }
618                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
619                                           0, 2, '^virulen',                                           0, [2], '^virulen',
620                                           $loadFeatureVirulent)) {                                           $loadFeatureVirulent)) {
621                          push @keywords, 'virulent';                          push @keywords, 'virulent';
622                          $loadFeature->Add('virulent');                          $loadFeature->Add('virulent');
623                      }                      }
624                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
625                                           0, 2, '^iedb_',                                           0, [0,2], '^iedb_',
626                                           $loadFeatureIEDB)) {                                           $loadFeatureIEDB)) {
627                          push @keywords, 'iedb';                          push @keywords, 'iedb';
628                          $loadFeature->Add('iedb');                          $loadFeature->Add('iedb');
# Line 1003  Line 1003 
1003              for my $fid (@features) {              for my $fid (@features) {
1004                  # 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
1005                  # to insure we do not get any genome attributes.                  # to insure we do not get any genome attributes.
1006                  my @attributeList = $fig->get_attributes($fid, '', '', '');                  my @attributeList = $fig->get_attributes($fid);
1007                  # Add essentiality and virulence attributes.                  # Add essentiality and virulence attributes.
1008                  if ($fig->essential($fid)) {                  if ($fig->essential($fid)) {
1009                      push @attributeList, [$fid, 'essential', 1, ''];                      push @attributeList, [$fid, 'essential', 1, ''];
# Line 1801  Line 1801 
1801    
1802  =head3 SpecialAttribute  =head3 SpecialAttribute
1803    
1804  C<< my $count = SproutLoad::SpecialAttribute($id, \@attributes, $idxMatch, $idxValue, $pattern, $loader); >>  C<< my $count = SproutLoad::SpecialAttribute($id, \@attributes, $idxMatch, \@idxValues, $pattern, $loader); >>
1805    
1806  Look for special attributes of a given type. A special attribute is found by comparing one of  Look for special attributes of a given type. A special attribute is found by comparing one of
1807  the columns of the incoming attribute list to a search pattern. If a match is found, then  the columns of the incoming attribute list to a search pattern. If a match is found, then
1808  another column is put into an output table connected to the specified ID.  a set of columns is put into an output table connected to the specified ID.
1809    
1810  For example, when processing features, the attribute list we look at has three columns: attribute  For example, when processing features, the attribute list we look at has three columns: attribute
1811  name, attribute value, and attribute value HTML. The IEDB attribute exists if the attribute name  name, attribute value, and attribute value HTML. The IEDB attribute exists if the attribute name
1812  begins with C<iedb_>. The call signature is therefore  begins with C<iedb_>. The call signature is therefore
1813    
1814      my $found = SpecialAttribute($fid, \@attributeList, 0, 2, '^iedb_', $loadFeatureIEDB);      my $found = SpecialAttribute($fid, \@attributeList, 0, [0,2], '^iedb_', $loadFeatureIEDB);
1815    
1816  The pattern is matched against column 0, and if we have a match, then column 2's value is put  The pattern is matched against column 0, and if we have a match, then column 2's value is put
1817  to the output along with the specified feature ID.  to the output along with the specified feature ID.
# Line 1832  Line 1832 
1832  Index in each tuple of the column to be matched against the pattern. If the match is  Index in each tuple of the column to be matched against the pattern. If the match is
1833  successful, an output record will be generated.  successful, an output record will be generated.
1834    
1835  =item idxValue  =item idxValues
1836    
1837  Index in each tuple of the column to be put as the second column of the output.  Reference to a list containing the indexes in each tuple of the columns to be put as
1838    the second column of the output.
1839    
1840  =item pattern  =item pattern
1841    
# Line 1857  Line 1858 
1858    
1859  sub SpecialAttribute {  sub SpecialAttribute {
1860      # Get the parameters.      # Get the parameters.
1861      my ($id, $attributes, $idxMatch, $idxValue, $pattern, $loader) = @_;      my ($id, $attributes, $idxMatch, $idxValues, $pattern, $loader) = @_;
1862      # Declare the return variable.      # Declare the return variable.
1863      my $retVal = 0;      my $retVal = 0;
1864      # Loop through the attribute rows.      # Loop through the attribute rows.
1865      for my $row (@{$attributes}) {      for my $row (@{$attributes}) {
1866          # Check for a match.          # Check for a match.
1867          if ($row->[$idxMatch] =~ m/$pattern/i) {          if ($row->[$idxMatch] =~ m/$pattern/i) {
1868              # We have a match, so output a row.              # We have a match, so output a row. This is a bit tricky, since we may
1869              $loader->Put($id, $row->[$idxValue]);              # be putting out multiple columns of data from the input.
1870                my $value = join(" ", map { $row->[$_] } @{$idxValues});
1871                $loader->Put($id, $value);
1872              $retVal++;              $retVal++;
1873          }          }
1874      }      }

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3