Bio::Restriction
IO
Summary
Bio::Restriction::IO - Handler for sequence variation IO Formats
Package variables
No package variables defined.
Inherit
Synopsis
use Bio::Restriction::IO;
$in = Bio::Restriction::IO->new(-file => "inputfilename" ,
-format => 'withrefm');
my $res = $in->read; # a Bio::Restriction::EnzymeCollection
Description
Bio::Restriction::IO is a handler module for the formats in the
Restriction IO set, e.g. Bio::Restriction::IO::xxx. It is the
officially sanctioned way of getting at the format objects, which most
people should use.
The structure, conventions and most of the code is inherited from
Bio::SeqIO. The main difference is that instead of using methods
next_seq, you drop _seq from the method name.
Also, instead of dealing only with individual
Bio::Restriction::Enzymeobjects, read() will slurp in all enzymes into a
Bio::Restriction::EnzymeCollection object.
For more details, see documentation in
Bio::SeqIO.
Methods
Methods description
Title : new Usage : $stream = Bio::Restriction::IO->new(-file => $filename, -format => 'Format') Function: Returns a new seqstream Returns : A Bio::Restriction::IO::Handler initialised with the appropriate format Args : -file => $filename -format => format -fh => filehandle to attach to |
Title : read Usage : $renzs = $stream->read Function: reads all the restrction enzymes from the stream Returns : a Bio::Restriction::EnzymeCollection object Args : |
Title : write Usage : $stream->write($seq) Function: writes the $seq object into the stream Returns : 1 for success and 0 for error Args : Bio::Restriction::EnzymeCollection object |
Title : _guess_format Usage : $obj->_guess_format($filename) Function: Example : Returns : guessed format of filename (lower case) Args : |
Methods code
sub new
{ my ($class, %param) = @_;
my ($format);
@param{ map { lc $_ } keys %param } = values %param; $format = $FORMAT{$param{'-format'}} if defined $param{'-format'};
$format ||= $class->_guess_format( $param{-file} || $ARGV[0] )
|| 'base';
$format = "\L$format";
return unless $class->_load_format_module($format);
return "Bio::Restriction::IO::$format"->new(%param);} |
sub _load_format_module
{ my ($class, $format) = @_;
my $module = "Bio::Restriction::IO::" . $format;
my $ok;
eval {
$ok = $class->_load_module($module);
};
if ( $@ ) {
print STDERR <<END; $class: $format cannot be found Exception $@ For more information about the IO system please see the IO docs. This includes ways of checking for formats at compile time, not run time END ;
}
return $ok;} |
sub read
{ my ($self, $seq) = @_;
$self->throw_not_implemented(); } |
sub next
{ my ($self, $seq) = @_;
$self->throw_not_implemented(); } |
sub next_seq
{ my ($self, $seq) = @_;
$self->throw_not_implemented(); } |
sub write
{ my ($self, $seq) = @_;
$self->throw("Sorry, you cannot write to a generic ".
"Bio::Restricion::IO object.");} |
sub write_seq
{ my ($self, $seq) = @_;
$self->warn("These are not sequence objects. ".
"Use method 'write' instead of 'write_seq'.");
$self->write($seq);} |
sub _guess_format
{ my $class = shift;
return unless $_ = shift;
return 'flat' if /\.dat$/i;
return 'xml' if /\.xml$/i;
}
1; } |
General documentation
At the moment, these can be use mainly to get a custom set if enzymes in
withrefm or itype2 formats into
Bio::Restriction::Enzyme or
Bio::Restriction::EnzymeCollection objects. Using bairoch format is
highly experimental and is not recommmended at this time.
This class inherits from
Bio::SeqIO for convenience sake, though this should
inherit from
Bio::Root::Root. Get rid of
Bio::SeqIO inheritance by
copying relevant methods in.
write() methods are currently not implemented for any format except base.
Using write() even with base format is not recommended as it does not
support multicut/multisite enzyme output.
Should additional formats be supported (such as XML)?
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing lists Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the
web:
http://bugzilla.open-bio.org/
Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _