comment out FeatureIO, let Annotated tests fail until they are fixed
[bioperl-live.git] / Bio / SeqIO / MultiFile.pm
blob2ab2069a98bcf94d6d586dd19f0f98d6089ea429
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
14 =head1 NAME
16 Bio::SeqIO::MultiFile - Treating a set of files as a single input stream
18 =head1 SYNOPSIS
20 $seqin = Bio::SeqIO::MultiFile( '-format' => 'Fasta',
21 '-files' => ['file1','file2'] );
22 while((my $seq = $seqin->next_seq)) {
23 # do something with $seq
26 =head1 DESCRIPTION
28 Bio::SeqIO::MultiFile provides a simple way of bundling a whole
29 set of identically formatted sequence input files as a single stream.
31 =head1 FEEDBACK
33 =head2 Mailing Lists
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
42 =head2 Support
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.
53 =head2 Reporting Bugs
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
65 =head1 APPENDIX
67 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
69 =cut
72 # Let the code begin...
75 package Bio::SeqIO::MultiFile;
76 use strict;
78 use base qw(Bio::SeqIO);
81 # _initialize is where the heavy stuff will happen when new is called
83 sub _initialize {
84 my($self,@args) = @_;
86 $self->SUPER::_initialize(@args);
88 my ($file_array,$format) = $self->_rearrange([qw(
89 FILES
90 FORMAT
91 )],
92 @args,
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");
111 =head2 next_seq
113 Title : next_seq
114 Usage :
115 Function:
116 Example :
117 Returns :
118 Args :
121 =cut
123 sub next_seq{
124 my ($self,@args) = @_;
126 my $seq = $self->_current_seqio->next_seq();
127 if( !defined $seq ) {
128 if( $self->_load_file() == 0) {
129 return;
130 } else {
131 return $self->next_seq();
133 } else {
134 return $seq;
139 =head2 next_primary_seq
141 Title : next_primary_seq
142 Usage :
143 Function:
144 Example :
145 Returns :
146 Args :
149 =cut
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) {
157 return;
158 } else {
159 return $self->next_primary_seq();
161 } else {
162 return $seq;
167 =head2 _load_file
169 Title : _load_file
170 Usage :
171 Function:
172 Example :
173 Returns :
174 Args :
177 =cut
179 sub _load_file{
180 my ($self,@args) = @_;
182 my $file = shift(@{$self->{'_file_array'}});
183 if( !defined $file ) {
184 return 0;
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);
193 return 1;
196 =head2 _set_file
198 Title : _set_file
199 Usage :
200 Function:
201 Example :
202 Returns :
203 Args :
206 =cut
208 sub _set_file{
209 my ($self,@files) = @_;
211 push(@{$self->{'_file_array'}},@files);
215 =head2 _current_seqio
217 Title : _current_seqio
218 Usage : $obj->_current_seqio($newval)
219 Function:
220 Example :
221 Returns : value of _current_seqio
222 Args : newvalue (optional)
225 =cut
227 sub _current_seqio{
228 my ($obj,$value) = @_;
229 if( defined $value) {
230 $obj->{'_current_seqio'} = $value;
232 return $obj->{'_current_seqio'};
236 =head2 _format
238 Title : _format
239 Usage : $obj->_format($newval)
240 Function:
241 Example :
242 Returns : value of _format
243 Args : newvalue (optional)
246 =cut
248 sub _format{
249 my ($obj,$value) = @_;
250 if( defined $value) {
251 $obj->{'_format'} = $value;
253 return $obj->{'_format'};