| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Phylo::Unparsers::Pagel; |
|
2
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
48
|
|
|
3
|
1
|
|
|
1
|
|
10
|
use base 'Bio::Phylo::Unparsers::Abstract'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
182
|
|
|
4
|
1
|
|
|
1
|
|
10
|
use Bio::Phylo::Forest::Tree; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Bio::Phylo::Unparsers::Pagel - Serializer used by Bio::Phylo::IO, no serviceable parts inside |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This module unparses a Bio::Phylo data structure into an input file for |
|
13
|
|
|
|
|
|
|
Discrete/Continuous/Multistate. The pagel file format (as it is interpreted |
|
14
|
|
|
|
|
|
|
here) consists of: |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=over |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=item first line |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
the number of tips, the number of characters |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item subsequent lines |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
offspring name, parent name, branch length, character state(s). |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=back |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Here is an example of what the output might look like: |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
4 2 |
|
31
|
|
|
|
|
|
|
A,n1,0.000000,1,2 |
|
32
|
|
|
|
|
|
|
B,n1,0.000000,1,2 |
|
33
|
|
|
|
|
|
|
n1,n2,0.000000 |
|
34
|
|
|
|
|
|
|
C,n2,0.000000,2,2 |
|
35
|
|
|
|
|
|
|
n2,n3,0.000000 |
|
36
|
|
|
|
|
|
|
D,n3,0.000000,2,1 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
To the unparse() function pass a tree object as value of the '-phylo' |
|
39
|
|
|
|
|
|
|
argument. The tips in this tree must be linked to taxon objects, and |
|
40
|
|
|
|
|
|
|
the taxon objects must be linked to datum objects whose character |
|
41
|
|
|
|
|
|
|
state sequences are to be serialized. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
During unparsing, the tree is randomly resolved, and branch lengths are |
|
44
|
|
|
|
|
|
|
formatted to %f floats (i.e. integers, decimal point, integers). |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The pagel module is called by the L object, so |
|
47
|
|
|
|
|
|
|
look there to learn about parsing and serializing in general. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=begin comment |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Type : Unparser |
|
52
|
|
|
|
|
|
|
Title : to_string($tree) |
|
53
|
|
|
|
|
|
|
Usage : $pagel->to_string($tree); |
|
54
|
|
|
|
|
|
|
Function: Unparses a Bio::Phylo::Tree object into a pagel formatted string. |
|
55
|
|
|
|
|
|
|
Returns : SCALAR |
|
56
|
|
|
|
|
|
|
Args : Bio::Phylo::Tree |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=end comment |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _to_string { |
|
63
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
|
64
|
2
|
|
|
|
|
16
|
my $tree = $self->{'PHYLO'}; |
|
65
|
2
|
|
|
|
|
24
|
$tree->resolve; |
|
66
|
2
|
|
|
|
|
9
|
my ( $charcounter, $string ) = 0; |
|
67
|
2
|
|
|
|
|
6
|
foreach my $node ( @{ $tree->get_entities } ) { |
|
|
2
|
|
|
|
|
9
|
|
|
68
|
34
|
100
|
|
|
|
128
|
if ( $node->get_parent ) { |
|
69
|
32
|
|
|
|
|
160
|
$string .= $node->get_internal_name . ',' |
|
70
|
|
|
|
|
|
|
. $node->get_parent->get_internal_name . ','; |
|
71
|
32
|
100
|
|
|
|
138
|
if ( $node->get_branch_length ) { |
|
72
|
14
|
|
|
|
|
51
|
$string .= sprintf( "%f", $node->get_branch_length ); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else { |
|
75
|
18
|
|
|
|
|
60
|
$string .= sprintf( "%f", 0 ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
32
|
50
|
|
|
|
150
|
if ( $node->get_taxon ) { |
|
78
|
0
|
|
|
|
|
0
|
my $taxon = $node->get_taxon; |
|
79
|
0
|
|
|
|
|
0
|
foreach ( @{ $taxon->get_data } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
80
|
0
|
|
|
|
|
0
|
$string .= ',' . $_->get_char; |
|
81
|
0
|
|
|
|
|
0
|
$charcounter++; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
32
|
|
|
|
|
114
|
$string .= "\n"; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
else { |
|
87
|
2
|
|
|
|
|
7
|
next; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
2
|
|
|
|
|
19
|
my $header = $tree->calc_number_of_terminals . " "; |
|
91
|
2
|
|
|
|
|
12
|
$header .= $charcounter / $tree->calc_number_of_terminals; |
|
92
|
2
|
|
|
|
|
16
|
$string = $header . "\n" . $string; |
|
93
|
2
|
|
|
|
|
15
|
return $string; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# podinherit_insert_token |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
There is a mailing list at L |
|
101
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item L |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The pagel unparser is called by the L object. |
|
108
|
|
|
|
|
|
|
Look there to learn how to create pagel formatted files. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item L |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Also see the manual: L and L. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 CITATION |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
B, B, B, B |
|
121
|
|
|
|
|
|
|
and B, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
|
122
|
|
|
|
|
|
|
I B<12>:63. |
|
123
|
|
|
|
|
|
|
L |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |