line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::IO; |
2
|
55
|
|
|
55
|
|
1875634
|
use strict; |
|
55
|
|
|
|
|
356
|
|
|
55
|
|
|
|
|
1685
|
|
3
|
55
|
|
|
55
|
|
285
|
use base 'Exporter'; |
|
55
|
|
|
|
|
98
|
|
|
55
|
|
|
|
|
6004
|
|
4
|
55
|
|
|
55
|
|
10134
|
use Bio::Phylo; |
|
55
|
|
|
|
|
120
|
|
|
55
|
|
|
|
|
277
|
|
5
|
55
|
|
|
55
|
|
277
|
use Bio::Phylo::Util::CONSTANT qw'/looks_like/ :objecttypes'; |
|
55
|
|
|
|
|
86
|
|
|
55
|
|
|
|
|
12235
|
|
6
|
55
|
|
|
55
|
|
331
|
use Bio::Phylo::Util::Exceptions 'throw'; |
|
55
|
|
|
|
|
95
|
|
|
55
|
|
|
|
|
1948
|
|
7
|
55
|
|
|
55
|
|
15202
|
use IO::File; |
|
55
|
|
|
|
|
331114
|
|
|
55
|
|
|
|
|
40175
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw'parse unparse parse_matrix parse_tree'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Bio::Phylo::IO - Front end for parsers and serializers |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Bio::Phylo::IO qw(parse unparse); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# returns an unblessed array reference of block objects, |
19
|
|
|
|
|
|
|
# i.e. taxa, matrix or forest objects |
20
|
|
|
|
|
|
|
my $blocks = parse( |
21
|
|
|
|
|
|
|
'-file' => $file, |
22
|
|
|
|
|
|
|
'-format' => 'nexus', |
23
|
|
|
|
|
|
|
'-encoding' => ':encoding(UTF-8)', # optional, default is system-dependent |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for my $block ( @{ $blocks } ) { |
27
|
|
|
|
|
|
|
if ( $block->isa('Bio::Phylo::Taxa') ) { |
28
|
|
|
|
|
|
|
my $taxa = $block; |
29
|
|
|
|
|
|
|
# do something with the taxa |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# returns a Bio::Phylo::Project object |
34
|
|
|
|
|
|
|
my $project = parse( |
35
|
|
|
|
|
|
|
'-file' => $file, |
36
|
|
|
|
|
|
|
'-format' => 'nexus', |
37
|
|
|
|
|
|
|
'-as_project' => 1 |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
my ($taxa) = @{ $project->get_taxa }; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# parsing a tree from a newick string |
42
|
|
|
|
|
|
|
my $tree_string = '(((A,B),C),D);'; |
43
|
|
|
|
|
|
|
my $tree = Bio::Phylo::IO->parse( |
44
|
|
|
|
|
|
|
'-string' => $tree_string, |
45
|
|
|
|
|
|
|
'-format' => 'newick', |
46
|
|
|
|
|
|
|
)->first; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# note: newick parsers return |
49
|
|
|
|
|
|
|
# 'Bio::Phylo::Forest'! Call |
50
|
|
|
|
|
|
|
# ->first to retrieve the first |
51
|
|
|
|
|
|
|
# tree of the forest. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# prints 'Bio::Phylo::Forest::Tree' |
54
|
|
|
|
|
|
|
print ref $tree, "\n"; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# if the tree is very large and you need only some terminal nodes from it |
57
|
|
|
|
|
|
|
$simplified_tree = Bio::Phylo::IO->parse( |
58
|
|
|
|
|
|
|
'-string' => $tree_string, |
59
|
|
|
|
|
|
|
'-format' => 'newick', |
60
|
|
|
|
|
|
|
'-keep' => ['A', 'D'], # nodes to keep |
61
|
|
|
|
|
|
|
'-ignore_comments' => 1, # treats [] symbols as part of taxon name |
62
|
|
|
|
|
|
|
)->first; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# parsing a table |
65
|
|
|
|
|
|
|
my $table_string = qq(A,1,2|B,1,2|C,2,2|D,2,1); |
66
|
|
|
|
|
|
|
my $matrix = Bio::Phylo::IO->parse( |
67
|
|
|
|
|
|
|
'-string' => $table_string, |
68
|
|
|
|
|
|
|
'-format' => 'table', |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Data type, see Bio::Phylo::Parsers::Table |
71
|
|
|
|
|
|
|
'-type' => 'STANDARD', |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# field separator |
74
|
|
|
|
|
|
|
'-fieldsep' => ',', |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# line separator |
77
|
|
|
|
|
|
|
'-linesep' => '|' |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# prints 'Bio::Phylo::Matrices::Matrix' |
81
|
|
|
|
|
|
|
print ref $matrix, "\n"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# parsing a list of taxa |
84
|
|
|
|
|
|
|
my $taxa_string = 'A:B:C:D'; |
85
|
|
|
|
|
|
|
my $taxa = Bio::Phylo::IO->parse( |
86
|
|
|
|
|
|
|
'-string' => $taxa_string, |
87
|
|
|
|
|
|
|
'-format' => 'taxlist', |
88
|
|
|
|
|
|
|
'-fieldsep' => ':' |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# prints 'Bio::Phylo::Taxa' |
92
|
|
|
|
|
|
|
print ref $taxa, "\n"; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# matches taxon names in tree to $taxa object |
95
|
|
|
|
|
|
|
$tree->cross_reference($taxa); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# likewise for matrix |
98
|
|
|
|
|
|
|
$matrix->cross_reference($taxa); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
print unparse( |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# pass the tree object, |
103
|
|
|
|
|
|
|
# crossreferenced to taxa, which |
104
|
|
|
|
|
|
|
# are crossreferenced to the matrix |
105
|
|
|
|
|
|
|
'-phylo' => $tree, |
106
|
|
|
|
|
|
|
'-format' => 'pagel' |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# prints a pagel data file: |
110
|
|
|
|
|
|
|
#4 2 |
111
|
|
|
|
|
|
|
#A,n1,0.000000,1,2 |
112
|
|
|
|
|
|
|
#B,n1,0.000000,1,2 |
113
|
|
|
|
|
|
|
#n1,n2,0.000000 |
114
|
|
|
|
|
|
|
#C,n2,0.000000,2,2 |
115
|
|
|
|
|
|
|
#n2,n3,0.000000 |
116
|
|
|
|
|
|
|
#D,n3,0.000000,2,1 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The IO module is the front end for parsing and serializing phylogenetic |
121
|
|
|
|
|
|
|
data objects. It is a non-OO module that optionally exports the 'parse' and |
122
|
|
|
|
|
|
|
'unparse' subroutines into the caller's namespace, using the |
123
|
|
|
|
|
|
|
C<< use Bio::Phylo::IO qw(parse unparse); >> directive. Alternatively, you can |
124
|
|
|
|
|
|
|
call the subroutines as class methods. The C<< parse >> and |
125
|
|
|
|
|
|
|
C<< unparse >> subroutines load and dispatch the appropriate sub-modules at |
126
|
|
|
|
|
|
|
runtime, depending on the '-format' argument. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 CLASS METHODS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item parse() |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Parses a file or string. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Type : Class method |
137
|
|
|
|
|
|
|
Title : parse |
138
|
|
|
|
|
|
|
Usage : my $obj = Bio::Phylo::IO->parse(%options); |
139
|
|
|
|
|
|
|
Function: Creates (file) handle, |
140
|
|
|
|
|
|
|
instantiates appropriate parser. |
141
|
|
|
|
|
|
|
Returns : A Bio::Phylo::* object |
142
|
|
|
|
|
|
|
Args : -file => (path), |
143
|
|
|
|
|
|
|
or |
144
|
|
|
|
|
|
|
-string => (scalar), |
145
|
|
|
|
|
|
|
or |
146
|
|
|
|
|
|
|
-handle => (IO::Handle object) |
147
|
|
|
|
|
|
|
or |
148
|
|
|
|
|
|
|
-url => (url string) |
149
|
|
|
|
|
|
|
-format => (description format), |
150
|
|
|
|
|
|
|
-(other) => (parser specific options) |
151
|
|
|
|
|
|
|
Comments: The parse method makes assumptions about |
152
|
|
|
|
|
|
|
the capabilities of Bio::Phylo::Parsers::* |
153
|
|
|
|
|
|
|
modules: i) their names match those of the |
154
|
|
|
|
|
|
|
-format => (blah) arguments, insofar that |
155
|
|
|
|
|
|
|
ucfirst(blah) . '.pm' is an existing module; |
156
|
|
|
|
|
|
|
ii) the modules implement a _from_handle, |
157
|
|
|
|
|
|
|
or a _from_string method. Exceptions are |
158
|
|
|
|
|
|
|
thrown if either assumption is violated. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
If @ARGV contains even key/value pairs such |
161
|
|
|
|
|
|
|
as "format newick file <filename>" (note: no |
162
|
|
|
|
|
|
|
dashes) these will be prepended to @_, for |
163
|
|
|
|
|
|
|
one-liners. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub parse { |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# first argument could be the package name or an object reference |
170
|
|
|
|
|
|
|
# if called as Bio::Phylo::IO->parse or as $io->parse, respectively |
171
|
118
|
100
|
100
|
118
|
1
|
6703
|
shift if $_[0] and $_[0] eq __PACKAGE__ or ref $_[0] eq __PACKAGE__; |
|
|
|
66
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# arguments were provided on the command line, in @ARGV |
174
|
118
|
50
|
|
|
|
356
|
if (@ARGV) { |
175
|
0
|
|
|
|
|
0
|
my $i = 0; |
176
|
0
|
|
|
|
|
0
|
while ( $i < @ARGV ) { |
177
|
0
|
|
|
|
|
0
|
my ( $key, $value ) = ( $ARGV[$i], $ARGV[ $i + 1 ] ); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# shell words have no -dash prefix, so we |
180
|
|
|
|
|
|
|
# add it here |
181
|
0
|
0
|
|
|
|
0
|
$key = "-$key" if $key !~ /^-/; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# we put @ARGV key/value pairs at the |
184
|
|
|
|
|
|
|
# front of the @_ array |
185
|
0
|
|
|
|
|
0
|
unshift @_, $key, $value; |
186
|
0
|
|
|
|
|
0
|
$i += 2; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# turn merged @ARGV and @_ arguments into a hash |
191
|
118
|
|
|
|
|
462
|
my %opts = looks_like_hash @_; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# there must be at least one of these args as a data source |
194
|
117
|
|
|
|
|
423
|
my @sources = qw(-file -string -handle -url); |
195
|
117
|
|
|
|
|
518
|
my ($source) = grep { defined $_ } @opts{@sources}; |
|
468
|
|
|
|
|
882
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# check provided arguments |
198
|
117
|
100
|
|
|
|
365
|
throw 'OddHash' => 'Odd number of elements in hash assignment' if !@_; |
199
|
116
|
100
|
|
|
|
306
|
throw 'BadArgs' => 'No parseable data source specified' unless $source; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# instantiate parser subclass and process data |
202
|
115
|
100
|
|
|
|
522
|
my $class = $opts{'-format'} ? ucfirst $opts{'-format'} : 'Abstract'; |
203
|
115
|
|
|
|
|
288
|
my $lib = 'Bio::Phylo::Parsers::' . $class; |
204
|
115
|
|
|
|
|
387
|
return looks_like_class($lib)->_new(@_)->_process; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item parse_matrix() |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Parses a file or string. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Type : Class method |
212
|
|
|
|
|
|
|
Title : parse_matrix |
213
|
|
|
|
|
|
|
Usage : my $matrix = Bio::Phylo::IO->parse_matrix(%options); |
214
|
|
|
|
|
|
|
Function: Creates (file) handle, |
215
|
|
|
|
|
|
|
instantiates appropriate parser. |
216
|
|
|
|
|
|
|
Returns : A Bio::Phylo::Matrices::Matrix object |
217
|
|
|
|
|
|
|
Args : Same as parse() |
218
|
|
|
|
|
|
|
Comments: This method is syntactical sugar to get the first matrix |
219
|
|
|
|
|
|
|
out of a file/handle/string |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub parse_matrix { |
224
|
|
|
|
|
|
|
my ($matrix) = @{ |
225
|
0
|
|
|
0
|
1
|
0
|
parse( |
|
0
|
|
|
|
|
0
|
|
226
|
|
|
|
|
|
|
@_, |
227
|
|
|
|
|
|
|
'-as_project' => 1, |
228
|
|
|
|
|
|
|
)->get_items(_MATRIX_) |
229
|
|
|
|
|
|
|
}; |
230
|
0
|
|
|
|
|
0
|
return $matrix; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item parse_tree() |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Parses a file or string. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Type : Class method |
238
|
|
|
|
|
|
|
Title : parse_tree |
239
|
|
|
|
|
|
|
Usage : my $tree = Bio::Phylo::IO->parse_tree(%options); |
240
|
|
|
|
|
|
|
Function: Creates (file) handle, |
241
|
|
|
|
|
|
|
instantiates appropriate parser. |
242
|
|
|
|
|
|
|
Returns : A Bio::Phylo::Forest::Tree object |
243
|
|
|
|
|
|
|
Args : Same as parse() |
244
|
|
|
|
|
|
|
Comments: This method is syntactical sugar to get the first tree |
245
|
|
|
|
|
|
|
out of a file/handle/string |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub parse_tree { |
250
|
|
|
|
|
|
|
my ($tree) = @{ |
251
|
11
|
|
|
11
|
1
|
656
|
parse( |
|
11
|
|
|
|
|
45
|
|
252
|
|
|
|
|
|
|
@_, |
253
|
|
|
|
|
|
|
'-as_project' => 1, |
254
|
|
|
|
|
|
|
)->get_items(_TREE_) |
255
|
|
|
|
|
|
|
}; |
256
|
11
|
|
|
|
|
51
|
return $tree; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item unparse() |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Unparses object(s) to a string. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Type : Class method |
264
|
|
|
|
|
|
|
Title : unparse |
265
|
|
|
|
|
|
|
Usage : my $string = Bio::Phylo::IO->unparse( |
266
|
|
|
|
|
|
|
%options |
267
|
|
|
|
|
|
|
); |
268
|
|
|
|
|
|
|
Function: Turns Bio::Phylo object into a |
269
|
|
|
|
|
|
|
string according to specified format. If an |
270
|
|
|
|
|
|
|
optional -file or -handle argument is provided |
271
|
|
|
|
|
|
|
the string is also written to that. |
272
|
|
|
|
|
|
|
Returns : SCALAR |
273
|
|
|
|
|
|
|
Args : -phylo => (Bio::Phylo object), |
274
|
|
|
|
|
|
|
-format => (description format), |
275
|
|
|
|
|
|
|
-(other) => (parser specific options) |
276
|
|
|
|
|
|
|
-file => (optional: a file path to open and write to) |
277
|
|
|
|
|
|
|
or |
278
|
|
|
|
|
|
|
-handle => (optional: a handle to write to) |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub unparse { |
283
|
41
|
50
|
66
|
41
|
1
|
801
|
if ( $_[0] and $_[0] eq __PACKAGE__ or ref $_[0] eq __PACKAGE__ ) { |
|
|
|
33
|
|
|
|
|
284
|
0
|
|
|
|
|
0
|
shift; |
285
|
|
|
|
|
|
|
} |
286
|
41
|
|
|
|
|
76
|
my %opts; |
287
|
41
|
100
|
100
|
|
|
224
|
if ( !@_ || scalar @_ % 2 ) { |
288
|
2
|
|
|
|
|
7
|
throw 'OddHash' => 'Odd number of elements in hash assignment'; |
289
|
|
|
|
|
|
|
} |
290
|
39
|
|
|
|
|
166
|
%opts = looks_like_hash @_; |
291
|
39
|
100
|
|
|
|
139
|
if ( !$opts{-format} ) { |
292
|
1
|
|
|
|
|
4
|
throw 'BadFormat' => 'no format specified.'; |
293
|
|
|
|
|
|
|
} |
294
|
38
|
50
|
|
|
|
112
|
if ( !$opts{-phylo} ) { |
295
|
0
|
|
|
|
|
0
|
throw 'BadArgs' => 'no object to unparse specified.'; |
296
|
|
|
|
|
|
|
} |
297
|
38
|
|
|
|
|
164
|
my $lib = 'Bio::Phylo::Unparsers::' . ucfirst $opts{-format}; |
298
|
38
|
|
|
|
|
128
|
my $unparser = looks_like_class($lib)->_new(%opts); |
299
|
37
|
50
|
|
|
|
219
|
if ( $unparser->can('_to_string') ) { |
300
|
37
|
|
|
|
|
126
|
my $string = $unparser->_to_string; |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# as per @fangly's request, make it possible to provide a -file |
303
|
|
|
|
|
|
|
# or -handle argument |
304
|
37
|
50
|
|
|
|
134
|
if ( $opts{'-file'} ) { |
305
|
0
|
0
|
|
|
|
0
|
open my $fh, '>', $opts{'-file'} or throw 'FileError' => $!; |
306
|
0
|
|
|
|
|
0
|
print $fh $string; |
307
|
|
|
|
|
|
|
} |
308
|
37
|
100
|
|
|
|
100
|
if ( $opts{'-handle'} ) { |
309
|
1
|
|
|
|
|
2
|
my $fh = $opts{'-handle'}; |
310
|
1
|
|
|
|
|
1
|
eval { $fh->print($string) }; |
|
1
|
|
|
|
|
10
|
|
311
|
1
|
50
|
|
|
|
777
|
if ( $@ ) { |
312
|
0
|
|
|
|
|
0
|
throw 'BadArgs' => "No valid, open handle provided: $@"; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
} |
315
|
37
|
|
|
|
|
231
|
return $string; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
else { |
318
|
0
|
|
|
|
|
0
|
throw 'ObjectMismatch' => 'the unparser can\'t convert to strings.'; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=item can_read() |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Tests whether L<Bio::Phylo::IO> can read provided syntax format. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Type : Class method |
327
|
|
|
|
|
|
|
Title : can_read |
328
|
|
|
|
|
|
|
Usage : &do_something if Bio::Phylo::IO->can_read('foo'); |
329
|
|
|
|
|
|
|
Function: Tests whether Bio::Phylo::IO can read provided syntax format. |
330
|
|
|
|
|
|
|
Returns : Boolean |
331
|
|
|
|
|
|
|
Args : A syntax format name, like "nexml" |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=cut |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub can_read { |
336
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $format ) = @_; |
337
|
0
|
|
|
|
|
0
|
my $package = 'Bio::Phylo::Parsers::' . ucfirst($format); |
338
|
0
|
|
|
|
|
0
|
eval { looks_like_class $package }; |
|
0
|
|
|
|
|
0
|
|
339
|
0
|
|
|
|
|
0
|
return ! $@; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=item can_write() |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
Tests whether L<Bio::Phylo::IO> can write provided syntax format. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
Type : Class method |
347
|
|
|
|
|
|
|
Title : can_write |
348
|
|
|
|
|
|
|
Usage : &do_something if Bio::Phylo::IO->can_write('foo'); |
349
|
|
|
|
|
|
|
Function: Tests whether Bio::Phylo::IO can write provided syntax format. |
350
|
|
|
|
|
|
|
Returns : Boolean |
351
|
|
|
|
|
|
|
Args : A syntax format name, like "nexml" |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=cut |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub can_write { |
356
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $format ) = @_; |
357
|
0
|
|
|
|
|
0
|
my $package = 'Bio::Phylo::Unparsers::' . ucfirst($format); |
358
|
0
|
|
|
|
|
0
|
eval { looks_like_class $package }; |
|
0
|
|
|
|
|
0
|
|
359
|
0
|
|
|
|
|
0
|
return ! $@; |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
# this just to prevent from calling __PACKAGE__->SUPER::DESTROY |
363
|
|
|
|
|
|
|
sub DESTROY { |
364
|
150
|
|
|
150
|
|
3183
|
return 1; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=back |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=head1 SEE ALSO |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
372
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=over |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Fasta> |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Newick> |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Nexml> |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Nexus> |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Phylip> |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Phyloxml> |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Table> |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Taxlist> |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=item L<Bio::Phylo::Parsers::Tolweb> |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Mrp> |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Newick> |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Nexml> |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Nexus> |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Pagel> |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Phylip> |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=item L<Bio::Phylo::Unparsers::Phyloxml> |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com> |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=back |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
=head1 CITATION |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
419
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
420
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
421
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=cut |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
1; |