2 # BioPerl module for Bio::Restriction::IO
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Rob Edwards <redwards@utmem.edu>
8 # Copyright Rob Edwards
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Restriction::IO - Handler for sequence variation IO Formats
20 use Bio::Restriction::IO;
22 $in = Bio::Restriction::IO->new(-file => "inputfilename" ,
23 -format => 'withrefm');
24 my $res = $in->read; # a Bio::Restriction::EnzymeCollection
28 L<Bio::Restriction::IO> is a handler module for the formats in the
29 Restriction IO set, e.g. C<Bio::Restriction::IO::xxx>. It is the
30 officially sanctioned way of getting at the format objects, which most
33 The structure, conventions and most of the code is inherited from
34 L<Bio::SeqIO>. The main difference is that instead of using methods
35 C<next_seq>, you drop C<_seq> from the method name.
37 Also, instead of dealing only with individual L<Bio::Restriction::Enzyme>
38 objects, C<read()> will slurp in all enzymes into a
39 L<Bio::Restriction::EnzymeCollection> object.
41 For more details, see documentation in L<Bio::SeqIO>.
45 At the moment, these can be use mainly to get a custom set if enzymes in
46 C<withrefm> or C<itype2> formats into L<Bio::Restriction::Enzyme> or
47 L<Bio::Restriction::EnzymeCollection> objects. Using C<bairoch> format is
48 highly experimental and is not recommmended at this time.
50 This class inherits from L<Bio::SeqIO> for convenience sake, though this should
51 inherit from L<Bio::Root::Root>. Get rid of L<Bio::SeqIO> inheritance by
52 copying relevant methods in.
54 C<write()> methods are currently not implemented for any format except C<base>.
55 Using C<write()> even with C<base> format is not recommended as it does not
56 support multicut/multisite enzyme output.
58 Should additional formats be supported (such as XML)?
63 L<Bio::Restriction::Enzyme>,
64 L<Bio::Restriction::EnzymeCollection>
70 User feedback is an integral part of the evolution of this and other
71 Bioperl modules. Send your comments and suggestions preferably to the
72 Bioperl mailing lists Your participation is much appreciated.
74 bioperl-l@bioperl.org - General discussion
75 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
79 Please direct usage questions or support issues to the mailing list:
81 I<bioperl-l@bioperl.org>
83 rather than to the module maintainer directly. Many experienced and
84 reponsive experts will be able look at the problem and quickly
85 address it. Please include a thorough description of the problem
86 with code and data examples if at all possible.
90 report bugs to the Bioperl bug tracking system to help us keep track
91 the bugs and their resolution. Bug reports can be submitted via the
94 https://redmine.open-bio.org/projects/bioperl/
98 Rob Edwards, redwards@utmem.edu
102 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
106 The rest of the documentation details each of the object
107 methods. Internal methods are usually preceded with a _
111 # Let the code begin...
113 package Bio
::Restriction
::IO
;
116 use vars
qw(%FORMAT);
117 use base qw(Bio::SeqIO);
120 'itype2' => 'itype2',
122 'withrefm' => 'withrefm',
126 'bairoch' => 'bairoch',
128 'macvector' => 'bairoch',
129 'vectorNTI' => 'bairoch',
130 'neo' => 'prototype',
131 'prototype' => 'prototype'
137 Usage : $stream = Bio::Restriction::IO->new(-file => $filename,
139 Function: Returns a new seqstream
140 Returns : A Bio::Restriction::IO::Handler initialised with
141 the appropriate format
142 Args : -file => $filename
144 -fh => filehandle to attach to
149 my ($class, %param) = @_;
152 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
153 $format = $FORMAT{$param{'-format'}} if defined $param{'-format'};
154 $format ||= $class->_guess_format( $param{-file
} || $ARGV[0] )
156 $format = "\L$format"; # normalize capitalization to lower case
158 return unless $class->_load_format_module($format);
159 return "Bio::Restriction::IO::$format"->new(%param);
163 sub _load_format_module
{
164 my ($class, $format) = @_;
165 my $module = "Bio::Restriction::IO::" . $format;
168 $ok = $class->_load_module($module);
172 $class: $format cannot be found
174 For more information about the IO system please see the IO docs.
175 This includes ways of checking for formats at compile time, not run time
185 Usage : $renzs = $stream->read
186 Function: reads all the restrction enzymes from the stream
187 Returns : a Bio::Restriction::EnzymeCollection object
193 my ($self, $seq) = @_;
194 $self->throw_not_implemented();
198 my ($self, $seq) = @_;
199 $self->throw_not_implemented();
203 my ($self, $seq) = @_;
204 $self->throw_not_implemented();
210 Usage : $stream->write($seq)
211 Function: writes the $seq object into the stream
212 Returns : 1 for success and 0 for error
213 Args : Bio::Restriction::EnzymeCollection object
218 my ($self, $seq) = @_;
219 $self->throw("Sorry, you cannot write to a generic ".
220 "Bio::Restricion::IO object.");
224 my ($self, $seq) = @_;
225 $self->warn("These are not sequence objects. ".
226 "Use method 'write' instead of 'write_seq'.");
232 Title : _guess_format
233 Usage : $obj->_guess_format($filename)
236 Returns : guessed format of filename (lower case)
243 return unless $_ = shift;
244 return 'flat' if /\.dat$/i;
245 return 'xml' if /\.xml$/i;