| 1 | package Bio::Phylo::Matrices::TypeSafeData; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use base 'Bio::Phylo::Listable'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use Bio::Phylo::Util::Exceptions 'throw'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Bio::Phylo::Util::CONSTANT qw'_MATRIX_ /looks_like/'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Bio::Phylo::Matrices::Datatype; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | { | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | my $logger = __PACKAGE__->get_logger; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | my %type; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | my $MATRIX_CONSTANT = _MATRIX_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | Bio::Phylo::Matrices::TypeSafeData - Superclass for objects that contain | ||||||||||||||||||||||||||||||||||||||||||
| 16 | character data | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # No direct usage | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | This is a superclass for objects holding character data. Objects that inherit | ||||||||||||||||||||||||||||||||||||||||||
| 25 | from this class (typically matrices and datum objects) yield functionality to | ||||||||||||||||||||||||||||||||||||||||||
| 26 | handle datatype objects and use them to validate data such as DNA sequences, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | continuous data etc. | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =head2 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =item new() | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | TypeSafeData constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Type : Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 40 | Title : new | ||||||||||||||||||||||||||||||||||||||||||
| 41 | Usage : No direct usage, is called by child class; | ||||||||||||||||||||||||||||||||||||||||||
| 42 | Function: Instantiates a Bio::Phylo::Matrices::TypeSafeData | ||||||||||||||||||||||||||||||||||||||||||
| 43 | Returns : a Bio::Phylo::Matrices::TypeSafeData child class | ||||||||||||||||||||||||||||||||||||||||||
| 44 | Args : -type => (data type - required) | ||||||||||||||||||||||||||||||||||||||||||
| 45 | Optional: | ||||||||||||||||||||||||||||||||||||||||||
| 46 | -missing => (the symbol for missing data) | ||||||||||||||||||||||||||||||||||||||||||
| 47 | -gap => (the symbol for gaps) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | -lookup => (a character state lookup hash) | ||||||||||||||||||||||||||||||||||||||||||
| 49 | -type_object => (a datatype object) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 988 | ▶ | sub new : Constructor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # is child class | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 988 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # process args | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 988 | my %args = looks_like_hash @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # notify user | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 988 | ▶ | if ( not $args{'-type'} and not $args{'-type_object'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args{"-type"} or $args{"-type_object"}
MC/DC100%2/2
$args{"-type"} or $args{"-type_object"}
$args{"-type"}
$args{"-type_object"}
Truth table100%3/3
A or B
A= $args{"-type"}B= $args{"-type_object"}
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 112 | $logger->info("No data type provided, will use 'standard'"); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 112 | unshift @_, '-type', 'standard'; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 988 | ▶ | if ( $args{'-characters'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 38 | ▶ | if ( $args{'-type'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 20 | $args{'-characters'}->set_type( $args{'-type'} ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | elsif ( $args{'-type_object'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $args{'-characters'}->set_type_object( $args{'-type_object'} ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | # notify user | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 988 | $logger->debug("constructor called for '$class'"); | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | # go up inheritance tree, eventually get an ID | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 988 | return $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 16 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | =head2 MUTATORS | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | =item set_type() | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | Set data type. | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 93 | Title : set_type | ||||||||||||||||||||||||||||||||||||||||||
| 94 | Usage : $obj->set_type($type); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | Function: Sets the object's datatype. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | Args : Argument must be a string, one of | ||||||||||||||||||||||||||||||||||||||||||
| 98 | continuous, custom, dna, mixed, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | protein, restriction, rna, standard | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 786 | ▶ | sub set_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_type: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 786 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 786 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 786 | my ( $type, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 786 | ▶ | if ( looks_like_instance( $arg, 'ARRAY' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | @args = @{$arg}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $type = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 786 | @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 786 | $type = $arg; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 786 | $logger->info("setting type '$type'"); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 786 | my $obj = Bio::Phylo::Matrices::Datatype->new( $type, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 785 | $self->set_type_object($obj); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 785 | ▶ | if ( UNIVERSAL::can($self,'_type') and $self->_type == $MATRIX_CONSTANT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::can($self, "_type") and $self->_type == $MATRIX_CONSTANT
MC/DC50%1/2
UNIVERSAL::can($self, "_type") and $self->_type == $MATRIX_CONSTANT
UNIVERSAL::can($self, "_type")
$self->_type == $MATRIX_CONSTANT
Truth table66%2/3
A and B
A= UNIVERSAL::can($self, "_type")B= $self->_type == $MATRIX_CONSTANT
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 47 | for my $row ( @{ $self->get_entities } ) { | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $row->set_type_object($obj); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 785 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | =item set_missing() | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | Set missing data symbol. | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 131 | Title : set_missing | ||||||||||||||||||||||||||||||||||||||||||
| 132 | Usage : $obj->set_missing('?'); | ||||||||||||||||||||||||||||||||||||||||||
| 133 | Function: Sets the symbol for missing data | ||||||||||||||||||||||||||||||||||||||||||
| 134 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 135 | Args : Argument must be a single | ||||||||||||||||||||||||||||||||||||||||||
| 136 | character, default is '?' | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 9 | ▶ | sub set_missing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_missing: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 9 | my ( $self, $missing ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 9 | ▶ | if ( $self->can('get_matchchar') and $self->get_matchchar and $missing eq $self->get_matchchar ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->can("get_matchchar") and $self->get_matchchar and $missing eq $self->get_matchchar
$self->can("get_matchchar") and $self->get_matchchar
MC/DC0%0/3
$self->can("get_matchchar") and $self->get_matchchar and $missing eq $self->get_matchchar
$self->can("get_matchchar")
$self->get_matchchar
$missing eq $self->get_matchchar
Truth table25%1/4
A and B and C
A= $self->can("get_matchchar")B= $self->get_matchcharC= $missing eq $self->get_matchchar
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | throw 'BadArgs' => | |||||||||||||||||||||||||||||||||||||||||
| 145 | "Missing character '$missing' already in use as match character"; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 9 | $logger->info("setting missing '$missing'"); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 9 | $self->get_type_object->set_missing($missing); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 9 | $self->validate; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | =item set_gap() | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | Set gap data symbol. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 158 | Title : set_gap | ||||||||||||||||||||||||||||||||||||||||||
| 159 | Usage : $obj->set_gap('-'); | ||||||||||||||||||||||||||||||||||||||||||
| 160 | Function: Sets the symbol for gaps | ||||||||||||||||||||||||||||||||||||||||||
| 161 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | Args : Argument must be a single | ||||||||||||||||||||||||||||||||||||||||||
| 163 | character, default is '-' | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 9 | ▶ | sub set_gap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_gap: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 9 | my ( $self, $gap ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | ▶ | if ( $self->can('get_matchchar') and $self->get_matchchar and $self->get_matchchar eq $gap ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->can("get_matchchar") and $self->get_matchchar and $self->get_matchchar eq $gap
$self->can("get_matchchar") and $self->get_matchchar
MC/DC0%0/3
$self->can("get_matchchar") and $self->get_matchchar and $self->get_matchchar eq $gap
$self->can("get_matchchar")
$self->get_matchchar
$self->get_matchchar eq $gap
Truth table25%1/4
A and B and C
A= $self->can("get_matchchar")B= $self->get_matchcharC= $self->get_matchchar eq $gap
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | throw 'BadArgs' => | |||||||||||||||||||||||||||||||||||||||||
| 171 | "Gap character '$gap' already in use as match character"; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | $logger->info("setting gap '$gap'"); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | $self->get_type_object->set_gap($gap); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 9 | $self->validate; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =item set_lookup() | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | Set ambiguity lookup table. | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 184 | Title : set_lookup | ||||||||||||||||||||||||||||||||||||||||||
| 185 | Usage : $obj->set_gap($hashref); | ||||||||||||||||||||||||||||||||||||||||||
| 186 | Function: Sets the symbol for gaps | ||||||||||||||||||||||||||||||||||||||||||
| 187 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | Args : Argument must be a hash | ||||||||||||||||||||||||||||||||||||||||||
| 189 | reference that maps allowed | ||||||||||||||||||||||||||||||||||||||||||
| 190 | single character symbols | ||||||||||||||||||||||||||||||||||||||||||
| 191 | (including ambiguity symbols) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | onto the equivalent set of | ||||||||||||||||||||||||||||||||||||||||||
| 193 | non-ambiguous symbols | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | sub set_lookup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_lookup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my ( $self, $lookup ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | $logger->info("setting character state lookup hash"); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | $self->get_type_object->set_lookup($lookup); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | $self->validate; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | =item set_type_object() | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | Set data type object. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 210 | Title : set_type_object | ||||||||||||||||||||||||||||||||||||||||||
| 211 | Usage : $obj->set_gap($obj); | ||||||||||||||||||||||||||||||||||||||||||
| 212 | Function: Sets the datatype object | ||||||||||||||||||||||||||||||||||||||||||
| 213 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | Args : Argument must be a subclass | ||||||||||||||||||||||||||||||||||||||||||
| 215 | of Bio::Phylo::Matrices::Datatype | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 1078 | ▶ | sub set_type_object : Clonable DeepClonable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_type_object: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1078 | my ( $self, $obj ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 1078 | $logger->info("setting character type object"); | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1078 | $type{ $self->get_id } = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 1078 | eval { $self->validate }; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 1078 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 3 | undef($@); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | if ( my @char = $self->get_char ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | $logger->warn( | |||||||||||||||||||||||||||||||||||||||||
| 229 | "Data contents of $self were invalidated by new type object." | ||||||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 1078 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 16 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =head2 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | =item get_type() | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | Get data type. | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 247 | Title : get_type | ||||||||||||||||||||||||||||||||||||||||||
| 248 | Usage : my $type = $obj->get_type; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | Function: Returns the object's datatype | ||||||||||||||||||||||||||||||||||||||||||
| 250 | Returns : A string | ||||||||||||||||||||||||||||||||||||||||||
| 251 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 34 | ▶ | sub get_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 34 | my $to = shift->get_type_object; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 34 | ▶ | if ($to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 34 | return $to->get_type; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | throw 'API' => "Missing data type object!"; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | =item get_missing() | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | Get missing data symbol. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 270 | Title : get_missing | ||||||||||||||||||||||||||||||||||||||||||
| 271 | Usage : my $missing = $obj->get_missing; | ||||||||||||||||||||||||||||||||||||||||||
| 272 | Function: Returns the object's missing data symbol | ||||||||||||||||||||||||||||||||||||||||||
| 273 | Returns : A string | ||||||||||||||||||||||||||||||||||||||||||
| 274 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 724 | ▶ | sub get_missing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_missing: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 724 | my $to = shift->get_type_object; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 724 | ▶ | if ($to) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 724 | return $to->get_missing; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | throw 'API' => "Missing data type object!"; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =item get_gap() | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | Get gap symbol. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 293 | Title : get_gap | ||||||||||||||||||||||||||||||||||||||||||
| 294 | Usage : my $gap = $obj->get_gap; | ||||||||||||||||||||||||||||||||||||||||||
| 295 | Function: Returns the object's gap symbol | ||||||||||||||||||||||||||||||||||||||||||
| 296 | Returns : A string | ||||||||||||||||||||||||||||||||||||||||||
| 297 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 11 | ▶ | sub get_gap { shift->get_type_object->get_gap } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_gap: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | =item get_lookup() | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | Get ambiguity lookup table. | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 308 | Title : get_lookup | ||||||||||||||||||||||||||||||||||||||||||
| 309 | Usage : my $lookup = $obj->get_lookup; | ||||||||||||||||||||||||||||||||||||||||||
| 310 | Function: Returns the object's lookup hash | ||||||||||||||||||||||||||||||||||||||||||
| 311 | Returns : A hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 312 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub get_lookup { shift->get_type_object->get_lookup } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_lookup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =item get_type_object() | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | Get data type object. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 323 | Title : get_type_object | ||||||||||||||||||||||||||||||||||||||||||
| 324 | Usage : my $obj = $obj->get_type_object; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | Function: Returns the object's linked datatype object | ||||||||||||||||||||||||||||||||||||||||||
| 326 | Returns : A subclass of Bio::Phylo::Matrices::Datatype | ||||||||||||||||||||||||||||||||||||||||||
| 327 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 3497 | ▶ | sub get_type_object { $type{ $_[0]->get_id } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type_object: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | =head2 INTERFACE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | =item validate() | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | Validates the object's contents | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | Type : Interface method | ||||||||||||||||||||||||||||||||||||||||||
| 344 | Title : validate | ||||||||||||||||||||||||||||||||||||||||||
| 345 | Usage : $obj->validate | ||||||||||||||||||||||||||||||||||||||||||
| 346 | Function: Validates the object's contents | ||||||||||||||||||||||||||||||||||||||||||
| 347 | Returns : True or throws Bio::Phylo::Util::Exceptions::InvalidData | ||||||||||||||||||||||||||||||||||||||||||
| 348 | Args : None | ||||||||||||||||||||||||||||||||||||||||||
| 349 | Comments: This is an abstract method, i.e. this class doesn't | ||||||||||||||||||||||||||||||||||||||||||
| 350 | implement the method, child classes have to | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 1098 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 1098 | shift->_validate; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub _validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | throw 'NotImplemented' => 'Not implemented!'; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1978 | ▶ | sub _cleanup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 1978 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 1978 | ▶ | if ( $self and defined( my $id = $self->get_id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self and defined(my $id = $self->get_id)
MC/DC0%0/2
$self and defined(my $id = $self->get_id)
$self
defined(my $id = $self->get_id)
Truth table33%1/3
A and B
A= $selfB= defined(my $id = $self->get_id)
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 1978 | delete $type{ $self->get_id }; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | # podinherit_insert_token | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||||||||||||||||||||||||||||||||||||||||||
| 379 | for any user or developer questions and discussions. | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | =item L<Bio::Phylo::Listable> | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | This object inherits from L<Bio::Phylo::Listable>, so the methods defined | ||||||||||||||||||||||||||||||||||||||||||
| 386 | therein are also applicable to L<Bio::Phylo::Matrices::TypeSafeData> objects. | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | =item L<Bio::Phylo::Manual> | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =head1 CITATION | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | If you use Bio::Phylo in published research, please cite it: | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||||||||||||||||||||||||||||||||||||||||||
| 399 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||||||||||||||||||||||||||||||||||||||||||
| 400 | I<BMC Bioinformatics> B<12>:63. | ||||||||||||||||||||||||||||||||||||||||||
| 401 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||