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