2 # BioPerl module for Bio::SeqIO::MultiFile
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 # Copyright Ewan Birney
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::SeqIO::MultiFile - Treating a set of files as a single input stream
20 $seqin = Bio::SeqIO::MultiFile( '-format' => 'Fasta',
21 '-files' => ['file1','file2'] );
22 while((my $seq = $seqin->next_seq)) {
23 # do something with $seq
28 Bio::SeqIO::MultiFile provides a simple way of bundling a whole
29 set of identically formatted sequence input files as a single stream.
35 User feedback is an integral part of the evolution of this and other
36 Bioperl modules. Send your comments and suggestions preferably to one
37 of the Bioperl mailing lists. Your participation is much appreciated.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 Please direct usage questions or support issues to the mailing list:
46 I<bioperl-l@bioperl.org>
48 rather than to the module maintainer directly. Many experienced and
49 reponsive experts will be able look at the problem and quickly
50 address it. Please include a thorough description of the problem
51 with code and data examples if at all possible.
55 Report bugs to the Bioperl bug tracking system to help us keep track
56 the bugs and their resolution.
57 Bug reports can be submitted via the web:
59 https://redmine.open-bio.org/projects/bioperl/
61 =head1 AUTHOR - Ewan Birney
63 Email birney@ebi.ac.uk
67 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
72 # Let the code begin...
75 package Bio
::SeqIO
::MultiFile
;
78 use base
qw(Bio::SeqIO);
81 # _initialize is where the heavy stuff will happen when new is called
86 $self->SUPER::_initialize
(@args);
88 my ($file_array,$format) = $self->_rearrange([qw(
94 if( !defined $file_array || ! ref $file_array ) {
95 $self->throw("Must have an array files for MultiFile");
98 if( !defined $format ) {
99 $self->throw("Must have a format for MultiFile");
102 $self->{'_file_array'} = [];
104 $self->_set_file(@
$file_array);
105 $self->_format($format);
106 if( $self->_load_file() == 0 ) {
107 $self->throw("Unable even to initialise the first file");
124 my ($self,@args) = @_;
126 my $seq = $self->_current_seqio->next_seq();
127 if( !defined $seq ) {
128 if( $self->_load_file() == 0) {
131 return $self->next_seq();
139 =head2 next_primary_seq
141 Title : next_primary_seq
151 sub next_primary_seq
{
152 my ($self,@args) = @_;
154 my $seq = $self->_current_seqio->next_primary_seq();
155 if( !defined $seq ) {
156 if( $self->_load_file() == 0) {
159 return $self->next_primary_seq();
180 my ($self,@args) = @_;
182 my $file = shift(@
{$self->{'_file_array'}});
183 if( !defined $file ) {
186 my $seqio = Bio
::SeqIO
->new( '-format' => $self->_format(), -file
=> $file);
187 # should throw an exception - but if not...
188 if( !defined $seqio) {
189 $self->throw("no seqio built for $file!");
192 $self->_current_seqio($seqio);
209 my ($self,@files) = @_;
211 push(@
{$self->{'_file_array'}},@files);
215 =head2 _current_seqio
217 Title : _current_seqio
218 Usage : $obj->_current_seqio($newval)
221 Returns : value of _current_seqio
222 Args : newvalue (optional)
228 my ($obj,$value) = @_;
229 if( defined $value) {
230 $obj->{'_current_seqio'} = $value;
232 return $obj->{'_current_seqio'};
239 Usage : $obj->_format($newval)
242 Returns : value of _format
243 Args : newvalue (optional)
249 my ($obj,$value) = @_;
250 if( defined $value) {
251 $obj->{'_format'} = $value;
253 return $obj->{'_format'};