BioMart AttributeTable
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
BioMart::AttributeTable
Package variables
No package variables defined.
Included modules
Digest::MD5
Inherit
BioMart::Root
Synopsis
AttributeTables provide access to one or more rows of attribute values, each
containing one or more columns. They are used as placeholders for filters,
and BioMart::ResultTable objects inherit their functionality, and extend them.
Description
An AttributeTable object contains a table of data in rows and columns (the
minimal table being 1 X 1). It can be used in a variety of contexts within
the BioMart system.
It can be set as the value in a BioMart::Configuration::ValueFilter or
BioMart::Configuration::FilterList object to be used in a Query against a
dataset. BioMart::ResultTable objects inherit all functionality from
BioMart::AttributeTable, and extends it.
It basically presents a FIFO stack of array_ref objects. Adding a row pushes
this onto the stack, increasing its size by 1. Getting a row shifts an
array_ref from the stack, decreasing its size by 1. Thus, it is possible for
an AttributeTable to be exhausted, whereby the next call to getRow will return
null. This can be avoided by prefacing each call to next_row with a call to
hasMoreRows.
Methods
_hashCode
No description
Code
_newDescriptionCode
addRowDescriptionCode
addRows
No description
Code
getRows
No description
Code
hasMoreRowsDescriptionCode
hashedResults
No description
Code
nextRowDescriptionCode
setRows
No description
Code
Methods description
_newcode    nextTop
  Usage      : my $attTable = BioMart::AttributeTable->new();
Description: creates a new AttributeTable object.
Returntype : BioMart::Configuration::AttributeTable
Exceptions : none
Caller : general
addRowcodeprevnextTop
  Usage      : $attTable->addRow($row);
Description: adds a row (array_ref) of data to the AttributeTable.
Note, values from array_ref are harvested to avoid
unintended reference operations.
Returntype : none
Exceptions : none
Caller : caller
hasMoreRowscodeprevnextTop
  Usage      : if ($table->hasMoreRows) { ... }
Descripton : Determine if an AttributeTable has rows remaining to be
processed.
Note that the return for this method is currently the number of
rows remaining, but this may change in the future.
Returntype : boolean, >1 (true) if there are more rows, 0 (false) otherwise
Exceptions : none
Caller : caller
nextRowcodeprevnextTop
  
Usage : my $row = $attTable->nextRow; foreach my $col (@{$row}) { ... }
Description: returns a reference to the next row of data.
Returntype : array_ref. This returns null if the table is exhausted
Problems associated with this can be avoided by prefacing
each call to nextRow with a test of hasMoreRows.
Exceptions : none
Caller : caller
Methods code
_hashCodedescriptionprevnextTop
sub _hashCode {
  my $self = shift;

  return $self->get('hc');
}

1;
}
_newdescriptionprevnextTop
sub _new {
  my ($self, @param) = @_;

  $self->SUPER::_new(@param);
  $self->attr('columns', []);
  $self->attr('hashedResults', undef);
  #the hashCode for an AttributeTable is
#the digest of its creation time.
my $digest = Digest::MD5->new; $digest->add(scalar localtime); $self->attr('hc', $digest->hexdigest);
}
addRowdescriptionprevnextTop
sub addRow {
  my ($self,$row) = @_;

  my $columns = $self->get('columns');
  push @{$columns}, [ @{ $row } ];
  $self->set('columns',$columns);#so hash code updated
}
addRowsdescriptionprevnextTop
sub addRows {
  my ($self,$rows) = @_;

  my $columns = $self->get('columns');
  push @{$columns}, @{ $rows };
  $self->set('columns',$columns);#so hash code updated
}
getRowsdescriptionprevnextTop
sub getRows {
  my $self = shift;
  return $self->get('columns');
}
hasMoreRowsdescriptionprevnextTop
sub hasMoreRows {
  my $self = shift;

  my $columns = $self->get('columns');

  my $ret = @{$columns};
  return $ret;
}
hashedResultsdescriptionprevnextTop
sub hashedResults {
    my ($self,$value) = @_;

    if ($value){
	$self->set('hashedResults',$value);
    }
    return $self->get('hashedResults');
}
nextRowdescriptionprevnextTop
sub nextRow {
  my $self = shift;

  if ($self->hasMoreRows) {
    my $columns = $self->get('columns');
    my $rowref = shift @{$columns};
    $self->set('columns', $columns);
    return $rowref;
  }
  return undef;
}


#this is set at creation and never changed
}
setRowsdescriptionprevnextTop
sub setRows {
  my ($self,$rows) = @_;

  $self->set('columns',$rows);
}
General documentation
AUTHOR - Arek Kasprzyk, Syed Haider, Darin London, Damian SmedleyTop
CONTACTTop
This module is part of the BioMart project http://www.biomart.org
Questions can be posted to the mart-dev mailing list: mart-dev@ebi.ac.uk