| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# BioPerl module for Bio::SeqIO::MultiFile |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Cared for by Ewan Birney |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Copyright Ewan Birney |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Bio::SeqIO::MultiFile - Treating a set of files as a single input stream |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $seqin = Bio::SeqIO::MultiFile->new( -format => 'Fasta', |
|
21
|
|
|
|
|
|
|
-files => ['file1','file2'] ); |
|
22
|
|
|
|
|
|
|
while (my $seq = $seqin->next_seq) { |
|
23
|
|
|
|
|
|
|
# do something with $seq |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Bio::SeqIO::MultiFile provides a simple way of bundling a whole |
|
29
|
|
|
|
|
|
|
set of identically formatted sequence input files as a single stream. |
|
30
|
|
|
|
|
|
|
File format is automatically determined by C. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 FEEDBACK |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 Mailing Lists |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
|
37
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to one |
|
38
|
|
|
|
|
|
|
of the Bioperl mailing lists. Your participation is much appreciated. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
|
41
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Support |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
I |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
|
50
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
|
51
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
|
52
|
|
|
|
|
|
|
with code and data examples if at all possible. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 Reporting Bugs |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
|
57
|
|
|
|
|
|
|
the bugs and their resolution. |
|
58
|
|
|
|
|
|
|
Bug reports can be submitted via the web: |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
https://github.com/bioperl/bioperl-live/issues |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR - Ewan Birney |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Email birney@ebi.ac.uk |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 APPENDIX |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Let the code begin... |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
package Bio::SeqIO::MultiFile; |
|
77
|
1
|
|
|
1
|
|
600
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
|
6
|
use base qw(Bio::SeqIO); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
467
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# _initialize is where the heavy stuff will happen when new is called |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _initialize { |
|
85
|
2
|
|
|
2
|
|
6
|
my($self, @args) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
9
|
$self->SUPER::_initialize(@args); |
|
88
|
|
|
|
|
|
|
|
|
89
|
2
|
|
|
|
|
6
|
my ($file_array, $format) = $self->_rearrange([qw(FILES FORMAT)], @args); |
|
90
|
2
|
50
|
33
|
|
|
9
|
if( !defined $file_array || ! ref $file_array ) { |
|
91
|
0
|
|
|
|
|
0
|
$self->throw("Must have an array files for MultiFile"); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
3
|
$self->{'_file_array'} = []; |
|
95
|
2
|
|
|
|
|
6
|
$self->_set_file(@$file_array); |
|
96
|
|
|
|
|
|
|
|
|
97
|
2
|
100
|
|
|
|
6
|
$self->format($format) if defined $format; |
|
98
|
|
|
|
|
|
|
|
|
99
|
2
|
50
|
|
|
|
4
|
if( $self->_load_file() == 0 ) { |
|
100
|
0
|
|
|
|
|
0
|
$self->throw("Unable to initialise the first file"); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 next_seq |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Title : next_seq |
|
108
|
|
|
|
|
|
|
Usage : |
|
109
|
|
|
|
|
|
|
Function: |
|
110
|
|
|
|
|
|
|
Example : |
|
111
|
|
|
|
|
|
|
Returns : |
|
112
|
|
|
|
|
|
|
Args : |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub next_seq{ |
|
117
|
14
|
|
|
14
|
1
|
11
|
my ($self, @args) = @_; |
|
118
|
14
|
|
|
|
|
16
|
my $seq = $self->_current_seqio->next_seq(); |
|
119
|
14
|
100
|
|
|
|
19
|
if( !defined $seq ) { |
|
120
|
2
|
100
|
|
|
|
5
|
if( $self->_load_file() == 0) { |
|
121
|
1
|
|
|
|
|
2
|
return; |
|
122
|
|
|
|
|
|
|
} else { |
|
123
|
1
|
|
|
|
|
4
|
return $self->next_seq(); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} else { |
|
126
|
12
|
|
|
|
|
16
|
return $seq; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 next_primary_seq |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Title : next_primary_seq |
|
134
|
|
|
|
|
|
|
Usage : |
|
135
|
|
|
|
|
|
|
Function: |
|
136
|
|
|
|
|
|
|
Example : |
|
137
|
|
|
|
|
|
|
Returns : |
|
138
|
|
|
|
|
|
|
Args : |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub next_primary_seq{ |
|
143
|
0
|
|
|
0
|
1
|
0
|
my ($self, @args) = @_; |
|
144
|
0
|
|
|
|
|
0
|
my $seq = $self->_current_seqio->next_primary_seq(); |
|
145
|
0
|
0
|
|
|
|
0
|
if( !defined $seq ) { |
|
146
|
0
|
0
|
|
|
|
0
|
if( $self->_load_file() == 0) { |
|
147
|
0
|
|
|
|
|
0
|
return; |
|
148
|
|
|
|
|
|
|
} else { |
|
149
|
0
|
|
|
|
|
0
|
return $self->next_primary_seq(); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
} else { |
|
152
|
0
|
|
|
|
|
0
|
return $seq; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 _load_file |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Title : _load_file |
|
160
|
|
|
|
|
|
|
Usage : |
|
161
|
|
|
|
|
|
|
Function: |
|
162
|
|
|
|
|
|
|
Example : |
|
163
|
|
|
|
|
|
|
Returns : |
|
164
|
|
|
|
|
|
|
Args : |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _load_file{ |
|
169
|
4
|
|
|
4
|
|
4
|
my ($self, @args) = @_; |
|
170
|
4
|
|
|
|
|
2
|
my $file = shift @{$self->{'_file_array'}}; |
|
|
4
|
|
|
|
|
8
|
|
|
171
|
4
|
100
|
|
|
|
6
|
if( !defined $file ) { |
|
172
|
1
|
|
|
|
|
2
|
return 0; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
3
|
|
|
|
|
3
|
my $seqio; |
|
175
|
3
|
|
|
|
|
5
|
my $format = $self->format; |
|
176
|
3
|
100
|
|
|
|
6
|
if ($format) { |
|
177
|
2
|
|
|
|
|
10
|
$seqio = Bio::SeqIO->new( -file => $file, -format => $format ); |
|
178
|
|
|
|
|
|
|
} else { |
|
179
|
1
|
|
|
|
|
4
|
$seqio = Bio::SeqIO->new( -file => $file ); |
|
180
|
1
|
50
|
|
|
|
16
|
$self->format($seqio->format) if not $format; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# should throw an exception - but if not... |
|
184
|
3
|
50
|
|
|
|
8
|
if( !defined $seqio) { |
|
185
|
0
|
|
|
|
|
0
|
$self->throw("Could not build SeqIO object for $file!"); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
3
|
|
|
|
|
7
|
$self->_current_seqio($seqio); |
|
188
|
3
|
|
|
|
|
10
|
return 1; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 _set_file |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Title : _set_file |
|
195
|
|
|
|
|
|
|
Usage : |
|
196
|
|
|
|
|
|
|
Function: |
|
197
|
|
|
|
|
|
|
Example : |
|
198
|
|
|
|
|
|
|
Returns : |
|
199
|
|
|
|
|
|
|
Args : |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub _set_file{ |
|
204
|
2
|
|
|
2
|
|
3
|
my ($self, @files) = @_; |
|
205
|
2
|
|
|
|
|
2
|
push @{$self->{'_file_array'}}, @files; |
|
|
2
|
|
|
|
|
4
|
|
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 _current_seqio |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Title : _current_seqio |
|
212
|
|
|
|
|
|
|
Usage : $obj->_current_seqio($newval) |
|
213
|
|
|
|
|
|
|
Function: |
|
214
|
|
|
|
|
|
|
Example : |
|
215
|
|
|
|
|
|
|
Returns : value of _current_seqio |
|
216
|
|
|
|
|
|
|
Args : newvalue (optional) |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub _current_seqio{ |
|
221
|
17
|
|
|
17
|
|
16
|
my ($obj, $value) = @_; |
|
222
|
17
|
100
|
|
|
|
32
|
if( defined $value) { |
|
223
|
3
|
|
|
|
|
6
|
$obj->{'_current_seqio'} = $value; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
17
|
|
|
|
|
33
|
return $obj->{'_current_seqio'}; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# We overload the format() method of Bio::Root::IO by a simple get/set |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub format{ |
|
232
|
6
|
|
|
6
|
1
|
5
|
my ($obj, $value) = @_; |
|
233
|
6
|
100
|
|
|
|
10
|
if( defined $value) { |
|
234
|
2
|
|
|
|
|
3
|
$obj->{'_format'} = $value; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
6
|
|
|
|
|
9
|
return $obj->{'_format'}; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
1; |