BioMart Root
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Package variables
No package variables defined.
Included modules
Data::Dumper
Log::Log4perl qw ( get_logger :levels )
Inherit
BioMart::RootI
Synopsis
Description
Methods
_equals
No description
Code
_getParams
No description
Code
_hashCode
No description
Code
_init
No description
Code
_new
No description
Code
_toString
No description
Code
addParams
No description
Code
attr
No description
Code
checkRequiredParams
No description
Code
get
No description
Code
getParam
No description
Code
loadModuleDescriptionCode
set
No description
Code
setParam
No description
Code
Methods description
loadModulecode    nextTop
  Usage        :  $self->loadModule($module); my $obj = "$module"->new(@param);
Description : Sets up $module (eg BioMart::X::Y::Z) from @INC in the
perl symbol table.
Caller can then construct an object of type $module.
Returntype : none
Exceptions : Problems finding module in @INC
Caller : caller
Methods code
_equalsdescriptionprevnextTop
sub _equals {
    my $self = shift;
    my $object = shift;

    return (($object == $self) ||
		(ref $object && $object->isa(ref $self) &&
		 $object->hashCode() eq $self->hashCode()))
}
_getParamsdescriptionprevnextTop
sub _getParams {
  my $self = shift;
  return $self->get('params');
}
_hashCodedescriptionprevnextTop
sub _hashCode {
    my $self = shift;
    return "$self";
}
_initdescriptionprevnextTop
sub _init {
  my ($self, $proto) = @_;

  # Subclasses should all do this before doing anything else
# $self->SUPER::_init(@_);
my $paramCopy = {}; my $protoParams = $proto->_getParams; foreach my $key (keys %{$protoParams}) { #TODO: some params are objects. Really need to instantiate new copies
# here, but for now just take the references, as _init is not implemented
# in many objects yet
$paramCopy->{$key} = $protoParams->{$key}; } $self->attr('params', $paramCopy );
}
_newdescriptionprevnextTop
sub _new {
    my $self = shift;

    # Subclasses should all do this before doing anything else.
# $self->SUPER::_new(@_);
$self->attr('params', {}); Log::Log4perl->init(\ qq{ log4perl.logger = FATAL, Screen log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Screen.layout.ConversionPattern = %c:%L:%p> %m%n log4perl.appender.Screen.stderr = 1 }) unless Log::Log4perl->initialized();
}
_toStringdescriptionprevnextTop
sub _toString {
    my $self = shift;
    return Dumper($self);
}

# Non-interface
}
addParamsdescriptionprevnextTop
sub addParams {
  my ($self, $titleRef, @param) = @_;

  local($^W) = 0;  # prevent "odd number of elements" warning with -w.
my(%param) = @param; foreach my $title (@{$titleRef}) { $self->setParam($title, $param{$title}); }
}
attrdescriptionprevnextTop
sub attr {
    my $self = shift;
    my $attr = shift;
    my $value = shift;

    if (exists $self->{$attr}) {
	BioMart::Exception->throw(sprintf("Attribute '%s' already exists", $attr));
    }

    $self->{$attr} = $value;
    $self->{'_hashDirty'} = 1;
}
checkRequiredParamsdescriptionprevnextTop
sub checkRequiredParams {
  my ($self, $paramref) = @_;
  foreach my $reqParam (@{$paramref}) {
    # removed apparently nonsensical == 0 check 
unless (defined $self->getParam($reqParam)){ BioMart::Exception->throw("Missing Required Parameter ${reqParam}\n"); } }
}
getdescriptionprevnextTop
sub get {
    my $self = shift;
    my $attr = shift;

    my $class = ref $self;

    if (!exists $self->{$attr}) {
	  BioMart::Exception->throw(sprintf("Attribute '%s' does not exist", $attr));
    }

    return $self->{$attr};
}
getParamdescriptionprevnextTop
sub getParam {
  my ($self, $key) = @_;

  #may return an undefined value
return $self->get('params')->{$key};
}
loadModuledescriptionprevnextTop
sub loadModule {
  my ($self, $moduleName) = @_;

  eval "require $moduleName" or BioMart::Exception->throw("could not load module $moduleName: $@");

  return;
}

1;
}
setdescriptionprevnextTop
sub set {
    my $self = shift;
    my $attr = shift;
    my $value = shift;

    if (!exists $self->{$attr}) {
	  BioMart::Exception->throw(sprintf("Attribute '%s' does not exist", $attr));
    }

    $self->{$attr} = $value;
    $self->{'_hashDirty'} = 1;
}
setParamdescriptionprevnextTop
sub setParam {
  my $self = shift;
  my $key = shift;
  my $value = shift;

  my $params = $self->get('params');
  $params->{$key} = $value;
  $self->set('params', $params);
}
General documentation
AUTHOR - Arek Kasprzyk, Syed Haider, 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