line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::Matrices::Character; |
2
|
10
|
|
|
10
|
|
56
|
use strict; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
281
|
|
3
|
10
|
|
|
10
|
|
43
|
use base 'Bio::Phylo::Matrices::TypeSafeData'; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
999
|
|
4
|
10
|
|
|
10
|
|
54
|
use Bio::Phylo::Factory; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
52
|
|
5
|
10
|
|
|
10
|
|
51
|
use Bio::Phylo::Util::CONSTANT qw'_CHARACTER_ _CHARACTERS_ _NS_BIOPHYLO_ /looks_like/'; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
1702
|
|
6
|
10
|
|
|
10
|
|
59
|
use Bio::Phylo::Util::Exceptions 'throw'; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
1728
|
|
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
|
51
|
my ( $self, $weight ) = @_; |
44
|
22
|
50
|
|
|
|
64
|
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
|
|
|
|
|
56
|
return $self; |
61
|
10
|
|
|
10
|
|
65
|
} |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
64
|
|
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
|
56
|
my ( $self, $codonpos ) = @_; |
76
|
22
|
50
|
|
|
|
56
|
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
|
|
|
|
|
46
|
return $self; |
95
|
10
|
|
|
10
|
|
2981
|
} |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
34
|
|
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
|
74
|
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
|
62
|
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
|
|
335
|
sub _validate { 1 } |
162
|
322
|
|
|
322
|
|
502
|
sub _container { _CHARACTERS_ } |
163
|
231
|
|
|
231
|
|
431
|
sub _type { _CHARACTER_ } |
164
|
22
|
|
|
22
|
|
62
|
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<https://groups.google.com/forum/#!forum/bio-phylo> |
175
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item L<Bio::Phylo::Matrices::TypeSafeData> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This object inherits from L<Bio::Phylo::Matrices::TypeSafeData>, so the |
182
|
|
|
|
|
|
|
methods defined therein are also applicable to characters objects |
183
|
|
|
|
|
|
|
objects. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 CITATION |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
196
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
197
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
198
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1; |