| Bio-Phylo documentation | Contained in the Bio-Phylo distribution. |
Bio::Phylo::Matrices::Datatype::Continuous - Validator subclass, no serviceable parts inside
The Bio::Phylo::Matrices::Datatype::* classes are used to validated data contained by Bio::Phylo::Matrices::Matrix and Bio::Phylo::Matrices::Datum objects.
Sets the lookup table (no-op for continuous data!).
Type : Mutator
Title : set_lookup
Usage : $obj->set_gap($hashref);
Function: Sets the symbol for gaps
Returns : Modified object.
Args : Argument must be a hash
reference that maps allowed
single character symbols
(including ambiguity symbols)
onto the equivalent set of
non-ambiguous symbols
Gets the lookup table (no-op for continuous data!).
Type : Accessor Title : get_lookup Usage : my $lookup = $obj->get_lookup; Function: Returns the object's lookup hash Returns : A hash reference Args : None
Validates arguments for data validity.
Type : Test
Title : is_valid
Usage : if ( $obj->is_valid($datum) ) {
# do something
}
Function: Returns true if $datum only contains valid characters
Returns : BOOLEAN
Args : A list of Bio::Phylo::Matrices::Datum object, and/or
character array references, and/or character strings,
and/or single characters
Splits string of characters on whitespaces.
Type : Utility method Title : split Usage : $obj->split($string) Function: Splits $string into characters Returns : An array reference of characters Args : A string
Joins array ref of characters to a space-separated string.
Type : Utility method Title : join Usage : $obj->join($arrayref) Function: Joins $arrayref into a string Returns : A string Args : An array reference
This object inherits from Bio::Phylo::Matrices::Datatype, so the methods defined therein are also applicable to Bio::Phylo::Matrices::Datatype::Continuous objects.
Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.
If you use Bio::Phylo in published research, please cite it:
Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. http://dx.doi.org/10.1186/1471-2105-12-63
$Id: Continuous.pm 1660 2011-04-02 18:29:40Z rvos $
| Bio-Phylo documentation | Contained in the Bio-Phylo distribution. |
# $Id: Continuous.pm 1660 2011-04-02 18:29:40Z rvos $ package Bio::Phylo::Matrices::Datatype::Continuous; use strict; use base 'Bio::Phylo::Matrices::Datatype'; use Bio::Phylo::Util::CONSTANT qw(looks_like_number looks_like_implementor looks_like_instance); our ( $LOOKUP, $MISSING, $GAP ); { my $logger = __PACKAGE__->get_logger;
sub set_lookup {
$logger->info("Can't set lookup table for continuous characters");
return;
}
sub get_lookup {
$logger->info("Can't get lookup table for continuous characters");
return;
}
sub is_valid {
my $self = shift;
my @data;
for my $arg (@_) {
if ( looks_like_implementor $arg, 'get_char' ) {
push @data, $arg->get_char;
}
elsif ( looks_like_instance $arg, 'ARRAY' ) {
push @data, @{$arg};
}
else {
push @data, @{ $self->split($arg) };
}
}
my $missing = $self->get_missing;
CHAR_CHECK: for my $char (@data) {
if ( looks_like_number $char || $char eq $missing ) {
next CHAR_CHECK;
}
else {
return 0;
}
}
return 1;
}
sub split {
my ( $self, $string ) = @_;
my @array = CORE::split( /\s+/, $string );
return \@array;
}
sub join {
my ( $self, $array ) = @_;
return CORE::join ' ', @{$array};
}
$MISSING = '?';
# podinherit_insert_token
} 1;