Bio-FeatureIO
view release on metacpan or search on metacpan
lib/Bio/FeatureIO.pm view on Meta::CPAN
Title : fh
Usage : $obj->fh
Function:
Example : $fh = $obj->fh; # make a tied filehandle
$feature = <$fh>; # read a feature object
print $fh $feature; # write a feature object
Returns : filehandle tied to Bio::FeatureIO class
Args : none
=cut
sub fh {
my $self = shift;
my $class = ref($self) || $self;
my $s = Symbol::gensym;
tie $$s,$class,$self;
return $s;
}
# _initialize is chained for all FeatureIO classes
sub _initialize {
my($self, %arg) = @_;
# flush is initialized by the Root::IO init
# initialize the IO part
$self->seq($arg{-seq});
$self->_initialize_io(%arg);
}
=head2 next_feature
Title : next_feature
Usage : $feature = stream->next_feature
Function: Reads the next feature object from the stream and returns it.
Certain driver modules may encounter entries in the stream
that are either misformatted or that use syntax not yet
understood by the driver. If such an incident is
recoverable, e.g., by dismissing a feature of a feature
table or some other non-mandatory part of an entry, the
driver will issue a warning. In the case of a
non-recoverable situation an exception will be thrown. Do
not assume that you can resume parsing the same stream
after catching the exception. Note that you can always turn
recoverable errors into exceptions by calling
$stream->verbose(2).
Returns : a Bio::SeqFeatureI feature object
Args : none
See L<Bio::Root::RootI>, L<Bio::SeqFeatureI>
=cut
sub next_feature {
my ($self, $seq) = @_;
$self->throw_not_implemented;
}
=head2 write_feature
Title : write_feature
Usage : $stream->write_feature($feature)
Function: writes the $feature object into the stream
Returns : 1 for success and 0 for error
Args : Bio::SeqFeature object
=cut
sub write_feature {
my ($self, $seq) = @_;
$self->throw_not_implemented();
}
=head2 _load_format_module
Title : _load_format_module
Usage : *INTERNAL FeatureIO stuff*
Function: Loads up (like use) a module at run time on demand
Example :
Returns :
Args :
=cut
sub _load_format_module {
my ($self, $format) = @_;
my $class = ref($self) || $self;
my $module = $class."::$format";#"Bio::Feature::" . $format;
my $ok;
eval {
$ok = $self->_load_module($module);
};
if ( $@ ) {
print STDERR <<END;
$self: $format cannot be found
Exception $@
For more information about the FeatureIO system please see the FeatureIO docs.
This includes ways of checking for formats at compile time, not run time
END
;
}
return $ok;
}
=head2 seq
Title : seq
Usage : $obj->seq() OR $obj->seq($newSeq)
Example :
Returns : Bio::SeqI object
Args : newSeq (optional)
=cut
sub seq {
my $self = shift;
my $val = shift;
$self->{'seq'} = $val if defined($val);
return $self->{'seq'};
}
=head2 _filehandle
Title : _filehandle
Usage : $obj->_filehandle($newval)
Function: This method is deprecated. Call _fh() instead.
Example :
Returns : value of _filehandle
Args : newvalue (optional)
( run in 0.715 second using v1.01-cache-2.11-cpan-df04353d9ac )