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

Diff of /Sprout/ERDB.pm

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

revision 1.47, Sun Jun 18 05:14:56 2006 UTC revision 1.48, Wed Jun 21 03:12:20 2006 UTC
# Line 2072  Line 2072 
2072      return $objectData->{Fields};      return $objectData->{Fields};
2073  }  }
2074    
2075    =head2 Data Mining Methods
2076    
2077  =head3 GetUsefulCrossValues  =head3 GetUsefulCrossValues
2078    
2079  C<< my @attrNames = $sprout->GetUsefulCrossValues($sourceEntity, $relationship); >>  C<< my @attrNames = $sprout->GetUsefulCrossValues($sourceEntity, $relationship); >>
# Line 2133  Line 2135 
2135      return @retVal;      return @retVal;
2136  }  }
2137    
2138    =head3 FindColumn
2139    
2140    C<< my $colIndex = ERDB::FindColumn($headerLine, $columnIdentifier); >>
2141    
2142    Return the location a desired column in a data mining header line. The data
2143    mining header line is a tab-separated list of column names. The column
2144    identifier is either the numerical index of a column or the actual column
2145    name.
2146    
2147    =over 4
2148    
2149    =item headerLine
2150    
2151    The header line from a data mining command, which consists of a tab-separated
2152    list of column names.
2153    
2154    =item columnIdentifier
2155    
2156    Either the ordinal number of the desired column (1-based), or the name of the
2157    desired column.
2158    
2159    =item RETURN
2160    
2161    Returns the array index (0-based) of the desired column.
2162    
2163    =back
2164    
2165    =cut
2166    
2167    sub FindColumn {
2168        # Get the parameters.
2169        my ($headerLine, $columnIdentifier) = @_;
2170        # Declare the return variable.
2171        my $retVal;
2172        # Split the header line into column names.
2173        my @headers = ParseColumns($headerLine);
2174        # Determine whether we have a number or a name.
2175        if ($columnIdentifier =~ /^\d+$/) {
2176            # Here we have a number. Subtract 1 and validate the result.
2177            $retVal = $columnIdentifier - 1;
2178            if ($retVal < 0 || $retVal > $#headers) {
2179                Confess("Invalid column identifer \"$columnIdentifier\": value out of range.");
2180            }
2181        } else {
2182            # Here we have a name. We need to find it in the list.
2183            for (my $i = 0; $i <= $#headers && ! defined($retVal); $i++) {
2184                if ($headers[$i] eq $columnIdentifier) {
2185                    $retVal = $i;
2186                }
2187            }
2188            if (! defined($retVal)) {
2189                Confess("Invalid column identifier \"$columnIdentifier\": value not found.");
2190            }
2191        }
2192        # Return the result.
2193        return $retVal;
2194    }
2195    
2196    =head3 ParseColumns
2197    
2198    C<< my @columns = ERDB->ParseColumns($line); >>
2199    
2200    Convert the specified data line to a list of columns.
2201    
2202    =over 4
2203    
2204    =item line
2205    
2206    A data mining input, consisting of a tab-separated list of columns terminated by a
2207    new-line.
2208    
2209    =item RETURN
2210    
2211    Returns a list consisting of the column values.
2212    
2213    =back
2214    
2215    =cut
2216    
2217    sub ParseColumns {
2218        # Get the parameters.
2219        my ($self, $line) = @_;
2220        # Chop off the line-end.
2221        chomp $line;
2222        # Split it into a list.
2223        my @retVal = split(/\t/, $line);
2224        # Return the result.
2225        return @retVal;
2226    }
2227    
2228  =head2 Internal Utility Methods  =head2 Internal Utility Methods
2229    
2230  =head3 SetupSQL  =head3 SetupSQL

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3