Bio-Polloc
view release on metacpan or search on metacpan
lib/Bio/Polloc/RuleI.pm view on Meta::CPAN
=over
=item
Gets/sets the type of rule
=item Arguments
Value (str). Can be: pattern, profile, repeat, tandemrepeat, similarity, coding,
boolean, composition, crispr. See the corresponding C<Bio::Polloc::Rule::*> objects
for further details.
Some variations can be introduced, like case variations or short versions like
B<patt> or B<rep>.
=item Return
Value (str). The type of the rule, or C<undef> if undefined. The value returned
is undef or a string from the above list, regardless of the input variations.
=item Throws
L<Bio::Polloc::Polloc::Error> if an unsupported type is received.
=back
=cut
sub type {
my($self,$value) = @_;
if($value){
my $v = $self->_qualify_type($value);
$self->throw("Attempting to set an invalid type of rule",$value) unless $v;
$self->{'_type'} = $v;
}
return $self->{'_type'};
}
=head2 context
=over
=item
Gets/sets the context of the rule.
The context is a reference to an array of two elements (I<int> or I<str>),
the first being:
1 => with respect to the start of the sequence
0 => somewhere within the sequence (ignores the second)
-1 => with respect to the end of the sequence
And the second being the number of residues from the reference point. The second
value can be positive, negative, or zero.
=item Arguments
Three integers, or one integer equal to zero. Please note that this function is
extremely tolerant, and tries to guess the context regardless of the input.
=item Returns
A reference to the array described above.
=back
=cut
sub context {
my($self,@args) = @_;
if($#args>=0){
$self->{'_context'} = [$args[0]+0, $args[1]+0, $args[2]+0];
}
$self->{'_context'} ||= [0,0,0];
if($self->{'_context'}->[0] < 0) {$self->{'_context'}->[0] = -1;}
elsif($self->{'_context'}->[0] > 0) {$self->{'_context'}->[0] = 1;}
else {$self->{'_context'}->[0] = 0;}
$self->{'_context'}->[1]+=0;
return $self->{'_context'};
}
=head2 value
=over
=item
Gets/sets the value of the rule
=item Arguments
Value (mix)
=item Returns
Value (mix)
=item Note
This function relies on C<_qualify_value>
=item Throws
L<Bio::Polloc::Polloc:Error> if unsupported value is received
=back
=cut
sub value {
my($self,$value) = @_;
if(defined $value){
my $v = $self->_qualify_value($value);
defined $v or $self->throw("Bad rule value", $value);
$self->{'_value'} = $v;
}
return $self->{'_value'};
}
( run in 2.320 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )