| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Phylo::Unparsers::Nexus; |
|
2
|
2
|
|
|
2
|
|
16
|
use strict; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
71
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use base 'Bio::Phylo::Unparsers::Abstract'; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
744
|
|
|
4
|
2
|
|
|
2
|
|
14
|
use Bio::Phylo::Util::CONSTANT ':objecttypes'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
574
|
|
|
5
|
2
|
|
|
2
|
|
16
|
use Bio::Phylo::Util::Exceptions 'throw'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1159
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Bio::Phylo::Unparsers::Nexus - Serializer used by Bio::Phylo::IO, no serviceable parts inside |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module turns a L object into a nexus |
|
14
|
|
|
|
|
|
|
formatted matrix. It is called by the L facade, don't call it |
|
15
|
|
|
|
|
|
|
directly. You can pass the following additional arguments to the unparse call: |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# an array reference of matrix, forest and taxa objects: |
|
18
|
|
|
|
|
|
|
-phylo => [ $block1, $block2 ] |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# the arguments that can be passed for matrix objects, |
|
21
|
|
|
|
|
|
|
# refer to Bio::Phylo::Matrices::Matrix::to_nexus: |
|
22
|
|
|
|
|
|
|
-matrix_args => {} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# the arguments that can be passed for forest objects, |
|
25
|
|
|
|
|
|
|
# refer to Bio::Phylo::Forest::to_nexus: |
|
26
|
|
|
|
|
|
|
-forest_args => {} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# the arguments that can be passed for taxa objects, |
|
29
|
|
|
|
|
|
|
# refer to Bio::Phylo::Taxa::to_nexus: |
|
30
|
|
|
|
|
|
|
-taxa_args => {} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
OR: |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# for backward compatibility: |
|
35
|
|
|
|
|
|
|
-phylo => $matrix |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=begin comment |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Type : Wrapper |
|
40
|
|
|
|
|
|
|
Title : _to_string($matrix) |
|
41
|
|
|
|
|
|
|
Usage : $nexus->_to_string($matrix); |
|
42
|
|
|
|
|
|
|
Function: Stringifies a matrix object into |
|
43
|
|
|
|
|
|
|
a nexus formatted table. |
|
44
|
|
|
|
|
|
|
Alias : |
|
45
|
|
|
|
|
|
|
Returns : SCALAR |
|
46
|
|
|
|
|
|
|
Args : Bio::Phylo::Matrices::Matrix; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=end comment |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _to_string { |
|
53
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
|
54
|
2
|
|
|
|
|
14
|
my $blocks = $self->{'PHYLO'}; |
|
55
|
2
|
|
|
|
|
6
|
my $nexus = "#NEXUS\n"; |
|
56
|
2
|
|
|
|
|
5
|
my $type; |
|
57
|
2
|
|
|
|
|
7
|
eval { $type = $blocks->_type }; |
|
|
2
|
|
|
|
|
13
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# array? |
|
60
|
2
|
50
|
33
|
|
|
68
|
if ($@) { |
|
|
|
50
|
33
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
for my $block (@$blocks) { |
|
62
|
0
|
|
|
|
|
0
|
eval { $type = $block->_type }; |
|
|
0
|
|
|
|
|
0
|
|
|
63
|
0
|
|
|
|
|
0
|
my %args; |
|
64
|
0
|
0
|
|
|
|
0
|
if ( $type == _FOREST_ ) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'FOREST_ARGS'} ) { |
|
66
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'FOREST_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
elsif ( $type == _TAXA_ ) { |
|
70
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'TAXA_ARGS'} ) { |
|
71
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'TAXA_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
elsif ( $type == _MATRIX_ ) { |
|
75
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'MATRIX_ARGS'} ) { |
|
76
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'MATRIX_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
elsif ($@) { |
|
80
|
0
|
|
|
|
|
0
|
throw 'ObjectMismatch' => "Can't unparse this object: $blocks"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
0
|
|
|
|
|
0
|
$nexus .= $block->to_nexus(%args); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# taxa? |
|
87
|
|
|
|
|
|
|
elsif ( defined $type and $type == _TAXA_ ) { |
|
88
|
0
|
|
|
|
|
0
|
my %args; |
|
89
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'TAXA_ARGS'} ) { |
|
90
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'TAXA_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
0
|
$nexus .= $blocks->to_nexus(%args); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# matrix? |
|
96
|
|
|
|
|
|
|
elsif ( defined $type and $type == _MATRIX_ ) { |
|
97
|
0
|
|
|
|
|
0
|
my %args; |
|
98
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'MATRIX_ARGS'} ) { |
|
99
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'MATRIX_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
0
|
$nexus .= $blocks->to_nexus(%args); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# forest? |
|
105
|
|
|
|
|
|
|
elsif ( defined $type and $type == _FOREST_ ) { |
|
106
|
0
|
|
|
|
|
0
|
my %args; |
|
107
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{'FOREST_ARGS'} ) { |
|
108
|
0
|
|
|
|
|
0
|
%args = %{ $self->{'FOREST_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
0
|
|
|
|
|
0
|
$nexus .= $blocks->to_nexus(%args); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# project? |
|
114
|
|
|
|
|
|
|
elsif ( defined $type and $type == _PROJECT_ ) { |
|
115
|
2
|
|
|
|
|
8
|
my ( %farg, %marg, %targ ); |
|
116
|
2
|
50
|
|
|
|
9
|
if ( exists $self->{'TAXA_ARGS'} ) { |
|
117
|
0
|
|
|
|
|
0
|
%targ = %{ $self->{'TAXA_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
2
|
50
|
|
|
|
9
|
if ( exists $self->{'MATRIX_ARGS'} ) { |
|
120
|
0
|
|
|
|
|
0
|
%marg = %{ $self->{'MATRIX_ARGS'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
121
|
|
|
|
|
|
|
} |
|
122
|
2
|
100
|
|
|
|
41
|
if ( exists $self->{'FOREST_ARGS'} ) { |
|
123
|
1
|
|
|
|
|
4
|
%farg = %{ $self->{'FOREST_ARGS'} }; |
|
|
1
|
|
|
|
|
7
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
2
|
|
|
|
|
17
|
$nexus = $blocks->to_nexus( %farg, %marg, %targ ); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# wrong! |
|
129
|
|
|
|
|
|
|
else { |
|
130
|
0
|
|
|
|
|
0
|
throw 'ObjectMismatch' => "Can't unparse this object: $blocks"; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
2
|
|
|
|
|
8
|
return $nexus; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# podinherit_insert_token |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
There is a mailing list at L |
|
140
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item L |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The nexus serializer is called by the L object. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item L |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Also see the manual: L and L. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 CITATION |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
B, B, B, B |
|
159
|
|
|
|
|
|
|
and B, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
|
160
|
|
|
|
|
|
|
I B<12>:63. |
|
161
|
|
|
|
|
|
|
L |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |