3 # BioPerl module for Bio::Restriction::IO
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Rob Edwards <redwards@utmem.edu>
9 # Copyright Rob Edwards
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Restriction::IO - Handler for sequence variation IO Formats
21 use Bio::Restriction::IO;
23 $in = Bio::Restriction::IO->new(-file => "inputfilename" ,
24 -format => 'withrefm');
25 my $res = $in->read; # a Bio::Restriction::EnzymeCollection
29 L<Bio::Restriction::IO> is a handler module for the formats in the
30 Restriction IO set, e.g. C<Bio::Restriction::IO::xxx>. It is the
31 officially sanctioned way of getting at the format objects, which most
34 The structure, conventions and most of the code is inherited from
35 L<Bio::SeqIO>. The main difference is that instead of using methods
36 C<next_seq>, you drop C<_seq> from the method name.
38 Also, instead of dealing only with individual L<Bio::Restriction::Enzyme>
39 objects, C<read()> will slurp in all enzymes into a
40 L<Bio::Restriction::EnzymeCollection> object.
42 For more details, see documentation in L<Bio::SeqIO>.
46 At the moment, these can be use mainly to get a custom set if enzymes in
47 C<withrefm> or C<itype2> formats into L<Bio::Restriction::Enzyme> or
48 L<Bio::Restriction::EnzymeCollection> objects. Using C<bairoch> format is
49 highly experimental and is not recommmended at this time.
51 This class inherits from L<Bio::SeqIO> for convenience sake, though this should
52 inherit from L<Bio::Root::Root>. Get rid of L<Bio::SeqIO> inheritance by
53 copying relevant methods in.
55 C<write()> methods are currently not implemented for any format except C<base>.
56 Using C<write()> even with C<base> format is not recommended as it does not
57 support multicut/multisite enzyme output.
59 Should additional formats be supported (such as XML)?
64 L<Bio::Restriction::Enzyme>,
65 L<Bio::Restriction::EnzymeCollection>
71 User feedback is an integral part of the evolution of this and other
72 Bioperl modules. Send your comments and suggestions preferably to the
73 Bioperl mailing lists Your participation is much appreciated.
75 bioperl-l@bioperl.org - General discussion
76 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
80 Please direct usage questions or support issues to the mailing list:
82 I<bioperl-l@bioperl.org>
84 rather than to the module maintainer directly. Many experienced and
85 reponsive experts will be able look at the problem and quickly
86 address it. Please include a thorough description of the problem
87 with code and data examples if at all possible.
91 report bugs to the Bioperl bug tracking system to help us keep track
92 the bugs and their resolution. Bug reports can be submitted via the
95 http://bugzilla.open-bio.org/
99 Rob Edwards, redwards@utmem.edu
103 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
107 The rest of the documentation details each of the object
108 methods. Internal methods are usually preceded with a _
112 # Let the code begin...
114 package Bio
::Restriction
::IO
;
117 use vars
qw(%FORMAT);
118 use base qw(Bio::SeqIO);
121 'itype2' => 'itype2',
123 'withrefm' => 'withrefm',
127 'bairoch' => 'bairoch',
129 'macvector' => 'bairoch',
130 'vectorNTI' => 'bairoch',
131 'neo' => 'prototype',
132 'prototype' => 'prototype'
138 Usage : $stream = Bio::Restriction::IO->new(-file => $filename,
140 Function: Returns a new seqstream
141 Returns : A Bio::Restriction::IO::Handler initialised with
142 the appropriate format
143 Args : -file => $filename
145 -fh => filehandle to attach to
150 my ($class, %param) = @_;
153 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
154 $format = $FORMAT{$param{'-format'}} if defined $param{'-format'};
155 $format ||= $class->_guess_format( $param{-file
} || $ARGV[0] )
157 $format = "\L$format"; # normalize capitalization to lower case
159 return unless $class->_load_format_module($format);
160 return "Bio::Restriction::IO::$format"->new(%param);
164 sub _load_format_module
{
165 my ($class, $format) = @_;
166 my $module = "Bio::Restriction::IO::" . $format;
169 $ok = $class->_load_module($module);
173 $class: $format cannot be found
175 For more information about the IO system please see the IO docs.
176 This includes ways of checking for formats at compile time, not run time
186 Usage : $renzs = $stream->read
187 Function: reads all the restrction enzymes from the stream
188 Returns : a Bio::Restriction::EnzymeCollection object
194 my ($self, $seq) = @_;
195 $self->throw_not_implemented();
199 my ($self, $seq) = @_;
200 $self->throw_not_implemented();
204 my ($self, $seq) = @_;
205 $self->throw_not_implemented();
211 Usage : $stream->write($seq)
212 Function: writes the $seq object into the stream
213 Returns : 1 for success and 0 for error
214 Args : Bio::Restriction::EnzymeCollection object
219 my ($self, $seq) = @_;
220 $self->throw("Sorry, you cannot write to a generic ".
221 "Bio::Restricion::IO object.");
225 my ($self, $seq) = @_;
226 $self->warn("These are not sequence objects. ".
227 "Use method 'write' instead of 'write_seq'.");
233 Title : _guess_format
234 Usage : $obj->_guess_format($filename)
237 Returns : guessed format of filename (lower case)
244 return unless $_ = shift;
245 return 'flat' if /\.dat$/i;
246 return 'xml' if /\.xml$/i;