Bio ClusterIO
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::ClusterIO - Handler for Cluster Formats
Package variables
Privates (from "my" definitions)
$entry = 0
Included modules
Bio::Root::IO
Bio::Root::Root
Inherit
Bio::Root::IO Bio::Root::Root
Synopsis
  #NB: This example is unigene specific
use Bio::ClusterIO; $stream = Bio::ClusterIO->new('-file' => "Hs.data", '-format' => "unigene"); # note: we quote -format to keep older perl's from complaining. while ( my $in = $stream->next_cluster() ) { print $in->unigene_id() . "\n"; while ( my $sequence = $in->next_seq() ) { print $sequence->accession_number() . "\n"; } } # Parsing errors are printed to STDERR.
Description
The ClusterIO module works with the ClusterIO format module to read
various cluster formats such as NCBI UniGene.
Methods
DESTROY
No description
Code
PRINT
No description
Code
READLINE
No description
Code
TIEHANDLEDescriptionCode
_guess_formatDescriptionCode
_initialize
No description
Code
_load_format_moduleDescriptionCode
cluster_factoryDescriptionCode
newDescriptionCode
next_clusterDescriptionCode
object_factoryDescriptionCode
Methods description
TIEHANDLE(), READLINE(), PRINT()code    nextTop
These I've left in here because they were in the SeqIO
module. Feedback appreciated. There they provide the tie interface.
See perltie for more details.
_guess_formatcodeprevnextTop
 Title   : _guess_format
Usage : $obj->_guess_format($filename)
Function: guess format based on file suffix
Example :
Returns : guessed format of filename (lower case)
Args :
Notes : formats that _filehandle() will guess include unigene and dbsnp
_load_format_modulecodeprevnextTop
 Title   : _load_format_module
Usage : *INTERNAL ClusterIO stuff*
Function: Loads up (like use) a module at run time on demand
Example :
Returns :
Args :
cluster_factorycodeprevnextTop
 Title   : cluster_factory
Usage : $obj->cluster_factory($newval)
Function: Get/set the object factory to use for creating the cluster
objects.
Example :
Returns : a Bio::Factory::ObjectFactoryI compliant object
Args : on set, new value (a Bio::Factory::ObjectFactoryI
compliant object or undef, optional)
newcodeprevnextTop
 Title   : new
Usage : Bio::ClusterIO->new(-file => $filename, -format => 'format')
Function: Returns a new cluster stream
Returns : A Bio::ClusterIO::Handler initialised with the appropriate format
Args : -file => $filename
-format => format
next_clustercodeprevnextTop
 Title   : next_cluster
Usage : $cluster = $stream->next_cluster()
Function: Reads the next cluster object from the stream and returns it.
Returns : a Bio::ClusterI compliant object
Args : none
object_factorycodeprevnextTop
 Title   : object_factory
Usage : $obj->object_factory($newval)
Function: This is an alias to cluster_factory with a more generic name.
Example :
Returns : a Bio::Factory::ObjectFactoryI compliant object
Args : on set, new value (a Bio::Factory::ObjectFactoryI
compliant object or undef, optional)
Methods code
DESTROYdescriptionprevnextTop
sub DESTROY {
    my $self = shift;

    $self->close();
}

# I need some direction on these!! The module works so I haven't fiddled with them!
}
PRINTdescriptionprevnextTop
sub PRINT {
  my $self = shift;
  $self->{'seqio'}->write_seq(@_);
}

1;
}
READLINEdescriptionprevnextTop
sub READLINE {
  my $self = shift;
  return $self->{'seqio'}->next_seq() unless wantarray;
  my (@list, $obj);
  push @list, $obj while $obj = $self->{'seqio'}->next_seq();
  return @list;
}
TIEHANDLEdescriptionprevnextTop
sub TIEHANDLE {
    my ($class,$val) = @_;
    return bless {'seqio' => $val}, $class;
}
_guess_formatdescriptionprevnextTop
sub _guess_format {
   my $class = shift;
   return unless $_ = shift;
   return 'unigene'   if /\.(data)$/i;
   return 'dbsnp'     if /\.(xml)$/i;
}
_initializedescriptionprevnextTop
sub _initialize {
    my($self, @args) = @_;
    # initialize the IO part
$self->_initialize_io(@args);
}
_load_format_moduledescriptionprevnextTop
sub _load_format_module {
  my ($self,$format) = @_;
  my $module = "Bio::ClusterIO::" . $format;
  my $ok;
  
  eval {
      $ok = $self->_load_module($module);
  };
  if ( $@ ) {
    print STDERR <<END;
$self: could not load $format - for more details on supported formats please see the ClusterIO docs
Exception $@
END
; } return $ok;
}
cluster_factorydescriptionprevnextTop
sub cluster_factory {
    my $self = shift;

    return $self->{'cluster_factory'} = shift if @_;
    return $self->{'cluster_factory'};
}
newdescriptionprevnextTop
sub new {
    my ($caller,@args) = @_;
    my $class = ref($caller) || $caller;
    
    # or do we want to call SUPER on an object if $caller is an
# object?
if( $class =~ /Bio::ClusterIO::(\S+)/ ) { my ($self) = $class->SUPER::new(@args); $self->_initialize(@args); return $self; } else { my %param = @args; @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
my $format = $param{'-format'} || $class->_guess_format( $param{-file} || $ARGV[0] ); $format = "\L$format"; # normalize capitalization to lower case
return undef unless( $class->_load_format_module($format) ); return "Bio::ClusterIO::$format"->new(@args); } } # _initialize is chained for all ClusterIO classes
}
next_clusterdescriptionprevnextTop
sub next_cluster {
   my ($self, $seq) = @_;
   $self->throw("Sorry, you cannot read from a generic Bio::ClusterIO object.");
}
object_factorydescriptionprevnextTop
sub object_factory {
    return shift->cluster_factory(@_);
}
General documentation
CONSTRUCTORSTop
Bio::ClusterIO->new()Top
   $str = Bio::ClusterIO->new(-file => 'filename',
-format=>$format);
The new() class method constructs a new Bio::ClusterIO object. The
returned object can be used to retrieve or print cluster
objects. new() accepts the following parameters:
    -file
    A file path to be opened for reading.
    -format
    Specify the format of the file. Supported formats include:
   unigene		*.data	UniGene build files.
dbsnp *.xml dbSNP XML files
    If no format is specified and a filename is given, then the module
will attempt to deduce it from the filename. If this is unsuccessful,
the main UniGene build format is assumed.
    The format name is case insensitive. 'UNIGENE', 'UniGene' and
'unigene' are all supported, as are dbSNP, dbsnp, and DBSNP
OBJECT METHODSTop
See below for more detailed summaries. The main methods are:
$cluster = $str->next_cluster()Top
Fetch the next cluster from the stream.
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 one of the Bioperl mailing lists.
Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/MailList.shtml - 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@bioperl.org
http://bugzilla.bioperl.org/
AUTHOR - Andrew MacgregorTop
Email andrew@anatomy.otago.ac.nz
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _