[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.79, Sat Nov 18 20:38:45 2006 UTC
# Line 536  Line 536 
536                      # Count this feature.                      # Count this feature.
537                      $loadFeature->Add("featureIn");                      $loadFeature->Add("featureIn");
538                      # Begin building the keywords. We start with the genome ID, the                      # Begin building the keywords. We start with the genome ID, the
539                      # feature ID, and the organism name.                      # feature ID, the taxonomy, and the organism name.
540                      my @keywords = ($genomeID, $featureID, $fig->genus_species($genomeID));                      my @keywords = ($genomeID, $featureID, $fig->genus_species($genomeID),
541                                        $fig->taxonomy_of($genomeID));
542                      # Get the functional assignment and aliases. This                      # Get the functional assignment and aliases. This
543                      # depends on the feature type.                      # depends on the feature type.
544                      my $assignment;                      my $assignment;
# Line 610  Line 611 
611                                           $fig->get_attributes($featureID);                                           $fig->get_attributes($featureID);
612                      # Now we process each of the special attributes.                      # Now we process each of the special attributes.
613                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
614                                           1, 2, '^(essential|potential_essential)$',                                           1, [0,2], '^(essential|potential_essential)$',
615                                           $loadFeatureEssential)) {                                           $loadFeatureEssential)) {
616                          push @keywords, 'essential';                          push @keywords, 'essential';
617                          $loadFeature->Add('essential');                          $loadFeature->Add('essential');
618                      }                      }
619                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
620                                           0, 2, '^virulen',                                           0, [2], '^virulen',
621                                           $loadFeatureVirulent)) {                                           $loadFeatureVirulent)) {
622                          push @keywords, 'virulent';                          push @keywords, 'virulent';
623                          $loadFeature->Add('virulent');                          $loadFeature->Add('virulent');
624                      }                      }
625                      if (SpecialAttribute($featureID, \@attributes,                      if (SpecialAttribute($featureID, \@attributes,
626                                           0, 2, '^iedb_',                                           0, [0,2], '^iedb_',
627                                           $loadFeatureIEDB)) {                                           $loadFeatureIEDB)) {
628                          push @keywords, 'iedb';                          push @keywords, 'iedb';
629                          $loadFeature->Add('iedb');                          $loadFeature->Add('iedb');
630                      }                      }
631                      # Now we need to bust up hyphenated words in the keyword                      # Now we need to bust up hyphenated words in the keyword
632                      # list.                      # list. We keep them separate and put them at the end so
633                        # the original word order is available.
634                      my $keywordString = "";                      my $keywordString = "";
635                        my $bustedString = "";
636                      for my $keyword (@keywords) {                      for my $keyword (@keywords) {
637                          if (length $keyword >= 4) {                          if (length $keyword >= 4) {
638                              $keywordString .= " $keyword";                              $keywordString .= " $keyword";
639                              if ($keyword =~ /-/) {                              if ($keyword =~ /-/) {
640                                  my @words = grep { length($_) >= 4 } split /-/, $keyword;                                  my @words = grep { length($_) >= 4 } split /-/, $keyword;
641                                  $keywordString .= join(" ", "", @words);                                  $bustedString .= join(" ", "", @words);
642                              }                              }
643                          }                          }
644                      }                      }
645                        $keywordString .= $bustedString;
646                        # Get rid of annoying punctuation.
647                        $keywordString =~ s/[();]//g;
648                      # Clean the keyword list.                      # Clean the keyword list.
649                      my $cleanWords = $sprout->CleanKeywords($keywordString);                      my $cleanWords = $sprout->CleanKeywords($keywordString);
650                      Trace("Keyword string for $featureID: $cleanWords") if T(4);                      Trace("Keyword string for $featureID: $cleanWords") if T(4);
# Line 786  Line 792 
792                  # Now for the classification string. This comes back as a list                  # Now for the classification string. This comes back as a list
793                  # reference and we convert it to a space-delimited string.                  # reference and we convert it to a space-delimited string.
794                  my $classList = $fig->subsystem_classification($subsysID);                  my $classList = $fig->subsystem_classification($subsysID);
795                  my $classString = join(" : ", grep { $_ } @$classList);                  my $classString = join($FIG_Config::splitter, grep { $_ } @$classList);
796                  $loadSubsystemClass->Put($subsysID, $classString);                  $loadSubsystemClass->Put($subsysID, $classString);
797                  # Connect it to its roles. Each role is a column in the subsystem spreadsheet.                  # Connect it to its roles. Each role is a column in the subsystem spreadsheet.
798                  for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {                  for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {
# Line 1003  Line 1009 
1009              for my $fid (@features) {              for my $fid (@features) {
1010                  # 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
1011                  # to insure we do not get any genome attributes.                  # to insure we do not get any genome attributes.
1012                  my @attributeList = $fig->get_attributes($fid, '', '', '');                  my @attributeList = $fig->get_attributes($fid);
1013                  # Add essentiality and virulence attributes.                  # Add essentiality and virulence attributes.
1014                  if ($fig->essential($fid)) {                  if ($fig->essential($fid)) {
1015                      push @attributeList, [$fid, 'essential', 1, ''];                      push @attributeList, [$fid, 'essential', 1, ''];
# Line 1801  Line 1807 
1807    
1808  =head3 SpecialAttribute  =head3 SpecialAttribute
1809    
1810  C<< my $count = SproutLoad::SpecialAttribute($id, \@attributes, $idxMatch, $idxValue, $pattern, $loader); >>  C<< my $count = SproutLoad::SpecialAttribute($id, \@attributes, $idxMatch, \@idxValues, $pattern, $loader); >>
1811    
1812  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
1813  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
1814  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.
1815    
1816  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
1817  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
1818  begins with C<iedb_>. The call signature is therefore  begins with C<iedb_>. The call signature is therefore
1819    
1820      my $found = SpecialAttribute($fid, \@attributeList, 0, 2, '^iedb_', $loadFeatureIEDB);      my $found = SpecialAttribute($fid, \@attributeList, 0, [0,2], '^iedb_', $loadFeatureIEDB);
1821    
1822  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
1823  to the output along with the specified feature ID.  to the output along with the specified feature ID.
# Line 1832  Line 1838 
1838  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
1839  successful, an output record will be generated.  successful, an output record will be generated.
1840    
1841  =item idxValue  =item idxValues
1842    
1843  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
1844    the second column of the output.
1845    
1846  =item pattern  =item pattern
1847    
# Line 1857  Line 1864 
1864    
1865  sub SpecialAttribute {  sub SpecialAttribute {
1866      # Get the parameters.      # Get the parameters.
1867      my ($id, $attributes, $idxMatch, $idxValue, $pattern, $loader) = @_;      my ($id, $attributes, $idxMatch, $idxValues, $pattern, $loader) = @_;
1868      # Declare the return variable.      # Declare the return variable.
1869      my $retVal = 0;      my $retVal = 0;
1870      # Loop through the attribute rows.      # Loop through the attribute rows.
1871      for my $row (@{$attributes}) {      for my $row (@{$attributes}) {
1872          # Check for a match.          # Check for a match.
1873          if ($row->[$idxMatch] =~ m/$pattern/i) {          if ($row->[$idxMatch] =~ m/$pattern/i) {
1874              # We have a match, so output a row.              # We have a match, so output a row. This is a bit tricky, since we may
1875              $loader->Put($id, $row->[$idxValue]);              # be putting out multiple columns of data from the input.
1876                my $value = join(" ", map { $row->[$_] } @{$idxValues});
1877                $loader->Put($id, $value);
1878              $retVal++;              $retVal++;
1879          }          }
1880      }      }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3