BioMart::Configuration
ValueFilter
Toolbar
Summary
BioMart::Configuration::ValueFilter
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
A Filter which represents one or more 'x op value' clauses in a
where clause, eg x = y, chr > 3, etc.
Description
A BioMart::Filter implementation that links represents one or more
'name' 'operation' 'value' where clauses connected by OR, where
value is taken from a particular row in the Table. The Table
for a ValueFilter should consist of only one column.
Methods
Methods description
Usage : see Usage for BioMart::Configuration::BaseFilter. Description: creates a new ValueFilter object which becomes associated with a single Attribute and AttributeTable (or ResultTable) object and an operation specifier. The Table is assumed to consist of only one column of data. Returntype : BioMart::Configuration::ValueFilter Exceptions : none Caller : general |
Usage : my $att = $filt->attribute; $filt->attribute($att); Description: get/set method for the BioMart::Configuration::Attribute object for this BooleanFilter This object represents the implementation specific location of a data point on which to apply the filter. Returntype : BioMart::Configuration::Attribute object Exceptions : none Caller : caller |
Usage : my $def = $filt->defaultValue; $filt->defaultValue($op); Description: get/set the defaultValue to associate with the value filter Returntype : scalar $defaultValue Exceptions : none Caller : caller |
Usage : my $table = $vfilt->getTable; Description : get the BioMart::AttributeTable or BioMart::ResultTable object holding the data for this FilterList. Returntype : may be either a BioMart::AttributeTable, or a BioMart::ResultTable. ResultTable objects can be manipulated as read-only AttributeTable objects. This is intended to be used by a BioMart::DatasetI implementation to override the default toSQL method. Exceptions : none Caller : caller |
Usage : my $operation = $filt->operation; $filt->operation($op); Description: get/set the operation to associate with the value filter Returntype : scalar $op Exceptions : none Caller : caller |
Usage : my $otherFilters = $filt->otherFilters; $filt->otherFilters($op); Description: get/set the other filters to associate with the value filter Returntype : scalar $otherFilters Exceptions : none Caller : caller |
Usage : my $regexp = $filt->regexp; $filt->regexp($op); Description: get/set the regexp to associate with the value filter Returntype : scalar $regexp Exceptions : none Caller : caller |
Usage : set a BioMart::AttributeTable as the table $vfilt->setTable($attTable);
set a BioMart::ResultTable as the table
$vfilt->setTable($rTable);
Description: stores a BioMart::AttributeTable or BioMart::ResultTable
object as the table to manipulate for toSQL.
Returntype : none
Exceptions : none
Caller : caller |
Usage : Description: returns the table name associated with this filter; Returntype : String table name Exceptions : none Caller : caller |
Methods code
sub _hashCode
{ my $self = shift;
my $digest = Digest::MD5->new;
$digest->add($self->SUPER::_hashCode);
$digest->add($self->get('attribute')->hashCode) if ($self->get('attribute'));
$digest->add($self->get('attribute_table')->hashCode)
if ($self->get('attribute_table'));
$digest->add($self->get('operation')) if ($self->get('operation'));
return $digest->hexdigest;
}
1; } |
sub _init
{ my ($self, @param) = @_;
$self->SUPER::_init(@param);
my $proto = shift @param;
$self->attr('attribute_table', $proto->getTable);
$self->attr('attribute', $proto->attribute);
$self->attr('operation', $proto->operation);
$self->attr('otherFilters', $proto->otherFilters);
$self->attr('regexp', $proto->regexp);
$self->attr('defaultValue', $proto->defaultValue);
$self->attr('sql', undef);
}
} |
sub _new
{ my ($self, @param) = @_;
$self->SUPER::_new(@param);
$self->attr('attribute', undef);
$self->attr('attribute_table', undef);
$self->attr('operation', undef);
$self->attr('otherFilters', undef);
$self->attr('regexp', undef);
$self->attr('defaultValue', undef);
$self->attr('sql', undef); } |
sub _toSQL
{ my ($self,$oracle) = @_;
my $sql = $self->get('sql');
if ($sql){
return $sql;
}
else{
$sql = '';
}
my $or = '';
my @values;
my $attribute_table = $self->get('attribute_table');
my $attribute = $self->get('attribute');
my $operation = $self->get('operation');
my $temp;
my $rows = $attribute_table->getRows();
foreach my $row (@{$rows}){
next unless (defined($$row[0]));
$temp = $$row[0];
$temp =~ s/'/''/;
if ($operation eq '='){
push @values, $temp;
}
else{
$sql .= $or.$attribute->toSQL.' '.$operation.'\' '.$temp.'\'';
$or = ' OR ';
}
}
if (!$sql && @values > 0){ if (@values > 1){
if ($oracle){
my @in_lists;
my %saw;
my @values = grep (!$saw{$_}++, @values);
@values = map{ "'".$_."'" } @values;
while (@values) {
my @sublist = grep{ $_ } splice (@values, 0, 999);
push @in_lists, join(",",@sublist);
}
@in_lists = map { " IN(".$_.")\n" } @in_lists;
$sql = $attribute->toSQL.join( "OR ".$attribute->toSQL,
@in_lists );
}
else{
$sql = $attribute->toSQL." IN('";
$sql .= join("','", grep { $_ } @values);
$sql .= "')";
}
}
else{
$sql .= $attribute->toSQL.' '.$operation.'\' '.$values[0].'\'';
}
}
$sql = '('.$sql.')' if ($sql); $self->set('sql',$sql);
return $sql;
}
} |
sub attribute
{ my ($self, $attribute) = @_;
if ($attribute){
$self->set('attribute', $attribute);
$self->set('sql',undef);
}
return $self->get('attribute'); } |
sub defaultValue
{ my ($self,$defaultValue) = @_;
if ($defaultValue) {
$self->set('defaultValue',$defaultValue);
}
return $self->get('defaultValue'); } |
sub getTable
{ my $self = shift;
return $self->get('attribute_table'); } |
sub operation
{ my ($self,$operation) = @_;
if ($operation) {
$self->set('operation',$operation);
$self->set('sql',undef);
}
return $self->get('operation'); } |
sub otherFilters
{ my ($self,$otherFilters) = @_;
if ($otherFilters) {
$self->set('otherFilters',$otherFilters);
}
return $self->get('otherFilters'); } |
sub regexp
{ my ($self,$regexp) = @_;
if ($regexp) {
$self->set('regexp',$regexp);
}
return $self->get('regexp'); } |
sub setTable
{ my ($self,$attribute_table) = @_;
$self->set('attribute_table',$attribute_table);
$self->set('sql',undef); } |
sub table
{ my $self = shift;
my $attribute = $self->get('attribute');
return $attribute->table; } |
General documentation
AUTHOR - Arek Kasprzyk, Syed Haider, Darin London, Damian Smedley | Top |