Bio::Restriction IO
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Restriction::IO - Handler for sequence variation IO Formats
Package variables
No package variables defined.
Included modules
Bio::SeqIO
Inherit
Bio::SeqIO
Synopsis
    use Bio::Restriction::IO;

    $in  = Bio::Restriction::IO->new(-file => "inputfilename" ,
                                     -format => 'withrefm');
    $out = Bio::Restriction::IO->new(-file => ">outputfilename" ,
                                     -format => 'bairoch');
    my $res = $in->read; # a Bio::Restriction::EnzymeCollection
    $out->write($res);

  # or

  #    use Bio::Restriction::IO;
  #
  #    #input file format can be read from the file extension (dat|xml)
  #    $in  = Bio::Restriction::IO->newFh(-file => "inputfilename");
  #    $out = Bio::Restriction::IO->newFh('-format' => 'xml');
  #
  #    # World's shortest flat<->xml format converter:
  #    print $out $_ while <$in>;
Description
Bio::Restriction::IO is a handler module for the formats in the
Restriction IO set (eg, 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 module. The main difference is that instead of using
methods next_seq and write_seq, you drop '_seq' from the method names.
Also, instead of dealing only with individual Bio::Restriction::Enzyme
objects, write() will go through all enzymes from a
Bio::Restriction::EnzymeCollection objects and read() will slurp in all
enzymes into a Collection.
For more details, see documentation in Bio::SeqIO.
Methods
newDescriptionCode
_load_format_module
No description
Code
readDescriptionCode
next
No description
Code
next_seq
No description
Code
writeDescriptionCode
write_seq
No description
Code
_guess_formatDescriptionCode
Methods description
newcode    nextTop
 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
readcodeprevnextTop
 Title   : read
 Usage   : $renzs = $stream->read
 Function: reads all the restrction enzymes from the stream
 Returns : a Bio::Restriction::EnzymeCollection object
 Args    :
writecodeprevnextTop
 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
_guess_formatcodeprevnextTop
 Title   : _guess_format
 Usage   : $obj->_guess_format($filename)
 Function:
 Example :
 Returns : guessed format of filename (lower case)
 Args    :
Methods code
newdescriptionprevnextTop
sub new {
   my ($class, %param) = @_;
   my ($format);

   @param{ map { lc $_ } keys %param } = values %param;  # lowercase keys
$format = $FORMAT{$param{'-format'}} if defined $param{'-format'}; $format ||= $class->_guess_format( $param{-file} || $ARGV[0] ) || 'base'; $format = "\L$format"; # normalize capitalization to lower case
return undef unless $class->_load_format_module($format); return "Bio::Restriction::IO::$format"->new(%param);
}
_load_format_moduledescriptionprevnextTop
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;
}
readdescriptionprevnextTop
sub read {
   my ($self, $seq) = @_;
   $self->throw("Not implemented");
}
nextdescriptionprevnextTop
sub next {
   my ($self, $seq) = @_;
   $self->throw("Not implemented");
}
next_seqdescriptionprevnextTop
sub next_seq {
   my ($self, $seq) = @_;
   $self->throw("Not implemented");
}
writedescriptionprevnextTop
sub write {
    my ($self, $seq) = @_;
    $self->throw("Sorry, you cannot write to a generic ".
                 "Bio::Restricion::IO object.");
}
write_seqdescriptionprevnextTop
sub write_seq {
   my ($self, $seq) = @_;
   $self->warn("These are not sequence objects. ".
               "Use method 'write' instead of 'write_seq'.");
   $self->write($seq);
}
_guess_formatdescriptionprevnextTop
sub _guess_format {
   my $class = shift;
   return  unless $_ = shift;
   return 'flat'     if /\.dat$/i;
   return 'xml'     if /\.xml$/i;
}
General documentation
TO DOTop
This inherits from SeqIOfor convinience sake. Get rid of it by copying
relevant methods in. Bio::SeqIO has too many sequence IO specific
tweeks in it.
SEE ALSOTop
Bio::SeqIO,
Bio::Restriction::Enzyme,
Bio::Restriction::EnzymeCollection
FEEDBACKTop
Mailing ListsTop
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://bio.perl.org/MailList.html         - About the mailing lists
Reporting BugsTop
report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via
email or the web:
  bioperl-bugs@bio.perl.org
  http://bugzilla.bioperl.org/
AUTHORTop
Rob Edwards, redwards@utmem.edu
CONTRIBUTORSTop
Heikki Lehvaslaiho, heikki@ebi.ac.uk
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _