Use /usr/bin/perl instead of env even on examples
[bioperl-live.git] / lib / Bio / Factory / SequenceProcessorI.pm
blobc6cdeb733b91d6e06d787655581c059e3a677ff4
2 # BioPerl module for Bio::Factory::SequenceProcessorI
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Hilmar Lapp <hlapp at gmx.net>
8 # Copyright Hilmar Lapp
10 # You may distribute this module under the same terms as perl itself
13 # (c) Hilmar Lapp, hlapp at gmx.net, 2002.
14 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
16 # You may distribute this module under the same terms as perl itself.
17 # Refer to the Perl Artistic License (see the license accompanying this
18 # software package, or see http://www.perl.com/language/misc/Artistic.html)
19 # for the terms under which you may use, modify, and redistribute this module.
21 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
22 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
23 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 # POD documentation - main docs before the code
28 =head1 NAME
30 Bio::Factory::SequenceProcessorI - Interface for chained sequence
31 processing algorithms
33 =head1 SYNOPSIS
35 use Bio::SeqIO;
36 use MySeqProcessor; # is-a Bio::Factory::SequenceProcessorI
38 # obtain your source stream, e.g., an EMBL file
39 my $seqin = Bio::SeqIO->new(-fh => \*STDIN, -format => 'embl');
40 # create your processor (it must implement this interface)
41 my $seqalgo = MySeqProcessor->new();
42 # chain together
43 $seqalgo->source_stream($seqin);
44 # you could create more processors and chain them one after another
45 # ...
46 # finally, the last link in the chain is your SeqIO stream
47 my $seqpipe = $seqalgo;
49 # once you've established the pipeline, proceed as if you had a
50 # single SeqIO stream
51 while(my $seq = $seqpipe->next_seq()) {
52 # ... do something ...
55 =head1 DESCRIPTION
57 This defines an interface that allows seamless chaining of sequence
58 processing algorithms encapsulated in modules while retaining the
59 overall Bio::SeqIO interface at the end of the pipeline.
61 This is especially useful if you want an easily configurable
62 processing pipeline of re-usable algorithms as building blocks instead
63 of (hard-)coding the whole algorithm in a single script.
65 There are literally no restrictions as to what an individual module
66 can do with a sequence object it obtains from the source stream before
67 it makes it available through its own next_seq() method. It can
68 manipulate the sequence object, but otherwise keep it intact, but it
69 can also create any number of new sequence objects from it, or it can
70 discard some, or any combination thereof. The only requirement is that
71 its next_seq() method return Bio::PrimarySeqI compliant objects. In
72 order to play nice, if a processor creates new objects it should try
73 to use the same sequence factory that the source stream uses, but this
74 is not strongly mandated.
76 =head1 FEEDBACK
78 =head2 Mailing Lists
80 User feedback is an integral part of the evolution of this and other
81 Bioperl modules. Send your comments and suggestions preferably to
82 the Bioperl mailing list. Your participation is much appreciated.
84 bioperl-l@bioperl.org - General discussion
85 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
87 =head2 Support
89 Please direct usage questions or support issues to the mailing list:
91 I<bioperl-l@bioperl.org>
93 rather than to the module maintainer directly. Many experienced and
94 reponsive experts will be able look at the problem and quickly
95 address it. Please include a thorough description of the problem
96 with code and data examples if at all possible.
98 =head2 Reporting Bugs
100 Report bugs to the Bioperl bug tracking system to help us keep track
101 of the bugs and their resolution. Bug reports can be submitted via the
102 web:
104 https://github.com/bioperl/bioperl-live/issues
106 =head1 AUTHOR - Hilmar Lapp
108 Email hlapp at gmx.net
110 =head1 APPENDIX
112 The rest of the documentation details each of the object methods.
113 Internal methods are usually preceded with a _
115 =cut
118 # Let the code begin...
121 package Bio::Factory::SequenceProcessorI;
122 use strict;
123 use Bio::Root::RootI;
125 use base qw(Bio::Factory::SequenceStreamI);
127 =head2 source_stream
129 Title : source_stream
130 Usage : $obj->source_stream($newval)
131 Function: Get/set the source sequence stream for this sequence
132 processor.
134 An implementation is not required to allow set, but will
135 usually do so.
137 Example :
138 Returns : A Bio::Factory::SequenceStreamI compliant object
139 Args : on set, new value (a Bio::Factory::SequenceStreamI compliant
140 object)
143 =cut
145 sub source_stream{
146 shift->throw_not_implemented();
149 =head1 Bio::Factory::SequenceStreamI methods
151 The requirement to implement these methods is inherited from
152 L<Bio::Factory::SequenceStreamI>. An implementation may not
153 necessarily have to implement all methods in a meaningful way. Which
154 methods will be necessary very much depends on the context in which
155 an implementation of this interface is used. E.g., if it is only used
156 for post-processing sequences read from a SeqIO stream, write_seq()
157 will not be used and hence does not need to be implemented in a
158 meaningful way (it may in fact even throw an exception).
160 Also, since an implementor will already receive built objects from a
161 sequence stream, sequence_factory() may or may not be relevant,
162 depending on whether the processing method does or does not involve
163 creating new objects.
165 =cut
167 =head2 next_seq
169 Title : next_seq
170 Usage : $seq = stream->next_seq
171 Function: Reads the next sequence object from the stream and returns it.
173 In the case of a non-recoverable situation an exception
174 will be thrown. Do not assume that you can resume parsing
175 the same stream after catching the exception. Note that you
176 can always turn recoverable errors into exceptions by
177 calling $stream->verbose(2).
179 Returns : a Bio::Seq sequence object
180 Args : none
182 See L<Bio::Root::RootI>
184 =cut
186 =head2 write_seq
188 Title : write_seq
189 Usage : $stream->write_seq($seq)
190 Function: writes the $seq object into the stream
191 Returns : 1 for success and 0 for error
192 Args : Bio::Seq object
194 =cut
196 =head2 sequence_factory
198 Title : sequence_factory
199 Usage : $seqio->sequence_factory($seqfactory)
200 Function: Get the Bio::Factory::SequenceFactoryI
201 Returns : Bio::Factory::SequenceFactoryI
202 Args : none
205 =cut