| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Phylo::Matrices::Character; |
|
2
|
10
|
|
|
10
|
|
65
|
use strict; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
329
|
|
|
3
|
10
|
|
|
10
|
|
49
|
use base 'Bio::Phylo::Matrices::TypeSafeData'; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
1270
|
|
|
4
|
10
|
|
|
10
|
|
66
|
use Bio::Phylo::Factory; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
73
|
|
|
5
|
10
|
|
|
10
|
|
50
|
use Bio::Phylo::Util::CONSTANT qw'_CHARACTER_ _CHARACTERS_ _NS_BIOPHYLO_ /looks_like/'; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
2037
|
|
|
6
|
10
|
|
|
10
|
|
95
|
use Bio::Phylo::Util::Exceptions 'throw'; |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
2148
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $fac = Bio::Phylo::Factory->new; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Bio::Phylo::Matrices::Character - A character (column) in a matrix |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# No direct usage |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Objects of this type represent a single character in a matrix. By default, a |
|
21
|
|
|
|
|
|
|
matrix will adjust the number of such objects it requires automatically as its |
|
22
|
|
|
|
|
|
|
contents grow or shrink. The main function, at present, for objects of this |
|
23
|
|
|
|
|
|
|
type is to facilitate NeXML serialization of characters and their annotations. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 MUTATORS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item set_weight() |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Type : Mutator |
|
34
|
|
|
|
|
|
|
Title : set_weight |
|
35
|
|
|
|
|
|
|
Usage : $character->set_weight(2); |
|
36
|
|
|
|
|
|
|
Function: Sets character weight |
|
37
|
|
|
|
|
|
|
Returns : $self |
|
38
|
|
|
|
|
|
|
Args : A number |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub set_weight : Clonable { |
|
43
|
22
|
|
|
22
|
1
|
44
|
my ( $self, $weight ) = @_; |
|
44
|
22
|
50
|
|
|
|
66
|
if ( looks_like_number $weight ) { |
|
|
|
50
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
0
|
if ( my ($meta) = @{ $self->get_meta('bp:charWeight') } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
46
|
0
|
|
|
|
|
0
|
$meta->set_triple( 'bp:charWeight' => $weight ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
else { |
|
49
|
0
|
|
|
|
|
0
|
$self->add_meta( |
|
50
|
|
|
|
|
|
|
$fac->create_meta( |
|
51
|
|
|
|
|
|
|
'-namespaces' => { 'bp' => _NS_BIOPHYLO_ }, |
|
52
|
|
|
|
|
|
|
'-triple' => { 'bp:charWeight' => $weight }, |
|
53
|
|
|
|
|
|
|
) |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ( defined $weight ) { |
|
58
|
0
|
|
|
|
|
0
|
throw 'BadNumber' => "'$weight' is not a number"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
22
|
|
|
|
|
58
|
return $self; |
|
61
|
10
|
|
|
10
|
|
73
|
} |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
70
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item set_codonpos() |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Type : Mutator |
|
66
|
|
|
|
|
|
|
Title : set_codonpos |
|
67
|
|
|
|
|
|
|
Usage : $character->set_codonpos(2); |
|
68
|
|
|
|
|
|
|
Function: Sets codon position for the column |
|
69
|
|
|
|
|
|
|
Returns : $self |
|
70
|
|
|
|
|
|
|
Args : A number |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub set_codonpos : Clonable { |
|
75
|
22
|
|
|
22
|
1
|
51
|
my ( $self, $codonpos ) = @_; |
|
76
|
22
|
50
|
|
|
|
55
|
if ( $codonpos ) { |
|
77
|
0
|
0
|
0
|
|
|
0
|
if ( $codonpos == 1 || $codonpos == 2 || $codonpos == 3 ) { |
|
|
|
0
|
0
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
0
|
if ( my ($meta) = @{ $self->get_meta('bp:codonPos') } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
79
|
0
|
|
|
|
|
0
|
$meta->set_triple( 'bp:codonPos' => $codonpos ); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
else { |
|
82
|
0
|
|
|
|
|
0
|
$self->add_meta( |
|
83
|
|
|
|
|
|
|
$fac->create_meta( |
|
84
|
|
|
|
|
|
|
'-namespaces' => { 'bp' => _NS_BIOPHYLO_ }, |
|
85
|
|
|
|
|
|
|
'-triple' => { 'bp:codonPos' => $codonpos }, |
|
86
|
|
|
|
|
|
|
) |
|
87
|
|
|
|
|
|
|
); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
elsif ( defined $codonpos ) { |
|
91
|
0
|
|
|
|
|
0
|
throw 'BadNumber' => "'$codonpos' is not a valid 1-based codon position"; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
22
|
|
|
|
|
54
|
return $self; |
|
95
|
10
|
|
|
10
|
|
3298
|
} |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
37
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 ACCESSORS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item get_weight() |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Type : Accessor |
|
106
|
|
|
|
|
|
|
Title : get_weight |
|
107
|
|
|
|
|
|
|
Usage : my $weight = $character->get_weight(); |
|
108
|
|
|
|
|
|
|
Function: Gets character weight |
|
109
|
|
|
|
|
|
|
Returns : A number (default is 1) |
|
110
|
|
|
|
|
|
|
Args : NONE |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub get_weight { |
|
115
|
22
|
|
|
22
|
1
|
65
|
shift->get_meta_object('bp:charWeight'); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item get_codonpos() |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Type : Mutator |
|
121
|
|
|
|
|
|
|
Title : get_codonpos |
|
122
|
|
|
|
|
|
|
Usage : my $pos = $character->get_codonpos; |
|
123
|
|
|
|
|
|
|
Function: Gets codon position for the column |
|
124
|
|
|
|
|
|
|
Returns : 1, 2, 3 or undef |
|
125
|
|
|
|
|
|
|
Args : None |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub get_codonpos { |
|
130
|
22
|
|
|
22
|
1
|
76
|
shift->get_meta_object('bp:codonPos'); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 SERIALIZERS |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item to_xml() |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Serializes characters to nexml format. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Type : Format convertor |
|
144
|
|
|
|
|
|
|
Title : to_xml |
|
145
|
|
|
|
|
|
|
Usage : my $xml = $characters->to_xml; |
|
146
|
|
|
|
|
|
|
Function: Converts characters object into a nexml element structure. |
|
147
|
|
|
|
|
|
|
Returns : Nexml block (SCALAR). |
|
148
|
|
|
|
|
|
|
Args : NONE |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub to_xml { |
|
153
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
154
|
0
|
0
|
|
|
|
0
|
if ( my $to = $self->get_type_object ) { |
|
155
|
0
|
0
|
|
|
|
0
|
if ( $to->get_type !~ m/continuous/i ) { |
|
156
|
0
|
|
|
|
|
0
|
$self->set_attributes( 'states' => $to->get_xml_id ); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
0
|
|
|
|
|
0
|
return $self->SUPER::to_xml; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
205
|
|
|
205
|
|
376
|
sub _validate { 1 } |
|
162
|
322
|
|
|
322
|
|
537
|
sub _container { _CHARACTERS_ } |
|
163
|
231
|
|
|
231
|
|
474
|
sub _type { _CHARACTER_ } |
|
164
|
22
|
|
|
22
|
|
56
|
sub _tag { 'char' } |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# podinherit_insert_token |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
There is a mailing list at L |
|
175
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item L |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This object inherits from L, so the |
|
182
|
|
|
|
|
|
|
methods defined therein are also applicable to characters objects |
|
183
|
|
|
|
|
|
|
objects. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item L |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Also see the manual: L and L. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 CITATION |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
B, B, B, B |
|
196
|
|
|
|
|
|
|
and B, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
|
197
|
|
|
|
|
|
|
I B<12>:63. |
|
198
|
|
|
|
|
|
|
L |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1; |