Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Factory/SequenceProcessorI.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 # $Id: SequenceProcessorI.pm,v 1.1 2002/10/24 18:35:46 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Factory::SequenceProcessorI | |
| 4 # | |
| 5 # Cared for by Hilmar Lapp <hlapp at gmx.net> | |
| 6 # | |
| 7 # Copyright Hilmar Lapp | |
| 8 # | |
| 9 # You may distribute this module under the same terms as perl itself | |
| 10 | |
| 11 # | |
| 12 # (c) Hilmar Lapp, hlapp at gmx.net, 2002. | |
| 13 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002. | |
| 14 # | |
| 15 # You may distribute this module under the same terms as perl itself. | |
| 16 # Refer to the Perl Artistic License (see the license accompanying this | |
| 17 # software package, or see http://www.perl.com/language/misc/Artistic.html) | |
| 18 # for the terms under which you may use, modify, and redistribute this module. | |
| 19 # | |
| 20 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | |
| 21 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
| 22 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| 23 # | |
| 24 | |
| 25 # POD documentation - main docs before the code | |
| 26 | |
| 27 =head1 NAME | |
| 28 | |
| 29 Bio::Factory::SequenceProcessorI - Interface for chained sequence | |
| 30 processing algorithms | |
| 31 | |
| 32 =head1 SYNOPSIS | |
| 33 | |
| 34 use Bio::SeqIO; | |
| 35 use MySeqProcessor; # is-a Bio::Factory::SequenceProcessorI | |
| 36 | |
| 37 # obtain your source stream, e.g., an EMBL file | |
| 38 my $seqin = Bio::SeqIO->new(-fh => \*STDIN, -format => 'embl'); | |
| 39 # create your processor (it must implement this interface) | |
| 40 my $seqalgo = MySeqProcessor->new(); | |
| 41 # chain together | |
| 42 $seqalgo->source_stream($seqin); | |
| 43 # you could create more processors and chain them one after another | |
| 44 # ... | |
| 45 # finally, the last link in the chain is your SeqIO stream | |
| 46 my $seqpipe = $seqalgo; | |
| 47 | |
| 48 # once you've established the pipeline, proceed as if you had a | |
| 49 # single SeqIO stream | |
| 50 while(my $seq = $seqpipe->next_seq()) { | |
| 51 # ... do something ... | |
| 52 } | |
| 53 | |
| 54 =head1 DESCRIPTION | |
| 55 | |
| 56 This defines an interface that allows seamless chaining of sequence | |
| 57 processing algorithms encapsulated in modules while retaining the | |
| 58 overall Bio::SeqIO interface at the end of the pipeline. | |
| 59 | |
| 60 This is especially useful if you want an easily configurable | |
| 61 processing pipeline of re-usable algorithms as building blocks instead | |
| 62 of (hard-)coding the whole algorithm in a single script. | |
| 63 | |
| 64 There are literally no restrictions as to what an individual module | |
| 65 can do with a sequence object it obtains from the source stream before | |
| 66 it makes it available through its own next_seq() method. It can | |
| 67 manipulate the sequence object, but otherwise keep it intact, but it | |
| 68 can also create any number of new sequence objects from it, or it can | |
| 69 discard some, or any combination thereof. The only requirement is that | |
| 70 its next_seq() method return Bio::PrimarySeqI compliant objects. In | |
| 71 order to play nice, if a processor creates new objects it should try | |
| 72 to use the same sequence factory that the source stream uses, but this | |
| 73 is not strongly mandated. | |
| 74 | |
| 75 =head1 FEEDBACK | |
| 76 | |
| 77 =head2 Mailing Lists | |
| 78 | |
| 79 User feedback is an integral part of the evolution of this and other | |
| 80 Bioperl modules. Send your comments and suggestions preferably to | |
| 81 the Bioperl mailing list. Your participation is much appreciated. | |
| 82 | |
| 83 bioperl-l@bioperl.org - General discussion | |
| 84 http://bioperl.org/MailList.shtml - About the mailing lists | |
| 85 | |
| 86 =head2 Reporting Bugs | |
| 87 | |
| 88 Report bugs to the Bioperl bug tracking system to help us keep track | |
| 89 of the bugs and their resolution. Bug reports can be submitted via | |
| 90 email or the web: | |
| 91 | |
| 92 bioperl-bugs@bioperl.org | |
| 93 http://bioperl.org/bioperl-bugs/ | |
| 94 | |
| 95 =head1 AUTHOR - Hilmar Lapp | |
| 96 | |
| 97 Email hlapp at gmx.net | |
| 98 | |
| 99 Describe contact details here | |
| 100 | |
| 101 =head1 CONTRIBUTORS | |
| 102 | |
| 103 Additional contributors names and emails here | |
| 104 | |
| 105 =head1 APPENDIX | |
| 106 | |
| 107 The rest of the documentation details each of the object methods. | |
| 108 Internal methods are usually preceded with a _ | |
| 109 | |
| 110 =cut | |
| 111 | |
| 112 | |
| 113 # Let the code begin... | |
| 114 | |
| 115 | |
| 116 package Bio::Factory::SequenceProcessorI; | |
| 117 use vars qw(@ISA); | |
| 118 use strict; | |
| 119 use Carp; | |
| 120 use Bio::Root::RootI; | |
| 121 use Bio::Factory::SequenceStreamI; | |
| 122 | |
| 123 @ISA = qw( Bio::Factory::SequenceStreamI ); | |
| 124 | |
| 125 =head2 source_stream | |
| 126 | |
| 127 Title : source_stream | |
| 128 Usage : $obj->source_stream($newval) | |
| 129 Function: Get/set the source sequence stream for this sequence | |
| 130 processor. | |
| 131 | |
| 132 An implementation is not required to allow set, but will | |
| 133 usually do so. | |
| 134 | |
| 135 Example : | |
| 136 Returns : A Bio::Factory::SequenceStreamI compliant object | |
| 137 Args : on set, new value (a Bio::Factory::SequenceStreamI compliant | |
| 138 object) | |
| 139 | |
| 140 | |
| 141 =cut | |
| 142 | |
| 143 sub source_stream{ | |
| 144 shift->throw_not_implemented(); | |
| 145 } | |
| 146 | |
| 147 =head1 Bio::Factory::SequenceStreamI methods | |
| 148 | |
| 149 The requirement to implement these methods is inherited from | |
| 150 L<Bio::Factory::SequenceStreamI>. An implementation may not | |
| 151 necessarily have to implement all methods in a meaningful way. Which | |
| 152 methods will be necessary very much depends on the context in which | |
| 153 an implementation of this interface is used. E.g., if it is only used | |
| 154 for post-processing sequences read from a SeqIO stream, write_seq() | |
| 155 will not be used and hence does not need to be implemented in a | |
| 156 meaningful way (it may in fact even throw an exception). | |
| 157 | |
| 158 Also, since an implementor will already receive built objects from a | |
| 159 sequence stream, sequence_factory() may or may not be relevant, | |
| 160 depending on whether the processing method does or does not involve | |
| 161 creating new objects. | |
| 162 | |
| 163 =cut | |
| 164 | |
| 165 =head2 next_seq | |
| 166 | |
| 167 Title : next_seq | |
| 168 Usage : $seq = stream->next_seq | |
| 169 Function: Reads the next sequence object from the stream and returns it. | |
| 170 | |
| 171 In the case of a non-recoverable situation an exception | |
| 172 will be thrown. Do not assume that you can resume parsing | |
| 173 the same stream after catching the exception. Note that you | |
| 174 can always turn recoverable errors into exceptions by | |
| 175 calling $stream->verbose(2). | |
| 176 | |
| 177 Returns : a Bio::Seq sequence object | |
| 178 Args : none | |
| 179 | |
| 180 See L<Bio::Root::RootI> | |
| 181 | |
| 182 =cut | |
| 183 | |
| 184 =head2 write_seq | |
| 185 | |
| 186 Title : write_seq | |
| 187 Usage : $stream->write_seq($seq) | |
| 188 Function: writes the $seq object into the stream | |
| 189 Returns : 1 for success and 0 for error | |
| 190 Args : Bio::Seq object | |
| 191 | |
| 192 =cut | |
| 193 | |
| 194 =head2 sequence_factory | |
| 195 | |
| 196 Title : sequence_factory | |
| 197 Usage : $seqio->sequence_factory($seqfactory) | |
| 198 Function: Get the Bio::Factory::SequenceFactoryI | |
| 199 Returns : Bio::Factory::SequenceFactoryI | |
| 200 Args : none | |
| 201 | |
| 202 | |
| 203 =cut | |
| 204 | |
| 205 1; |
