1 #-----------------------------------------------------------------
4 # BioPerl module Bio::SearchIO::SearchWriterI
6 # Cared for by Steve Chervitz <sac@bioperl.org>
8 # You may distribute this module under the same terms as perl itself
9 #-----------------------------------------------------------------
13 Bio::SearchIO::SearchWriterI - Interface for outputting parsed Search results
17 Bio::SearchIO::SearchWriterI objects cannot be instantiated since this
18 module defines a pure interface.
20 Given an object that implements the Bio::SearchIO::SearchWriterI interface,
21 you can do the following things with it:
23 print $writer->to_string( $result_obj, @args );
27 This module defines abstract methods that all subclasses must implement
28 to be used for outputting results from L<Bio::Search::Result::ResultI>
33 Steve Chervitz E<lt>sac-at-bioperl.orgE<gt>
37 This software is provided "as is" without warranty of any kind.
41 The rest of the documentation details each of the object methods.
45 package Bio
::SearchIO
::SearchWriterI
;
48 use base
qw(Bio::Root::RootI);
52 Purpose : Produces data for each Search::Result::ResultI in a string.
53 : This is an abstract method. For some useful implementations,
54 : see ResultTableWriter.pm, HitTableWriter.pm,
55 : and HSPTableWriter.pm.
56 Usage : print $writer->to_string( $result_obj, @args );
57 Argument : $result_obj = A Bio::Search::Result::ResultI object
58 : @args = any additional arguments used by your implementation.
59 Returns : String containing data for each search Result or any of its
60 : sub-objects (Hits and HSPs).
66 my ($self, $result, @args) = @_;
67 $self->throw_not_implemented;
73 Usage : $self->start_report()
74 Function: The method to call when starting a report. You can override it
75 to make a custom header
81 sub start_report
{ return '' }
86 Usage : $self->end_report()
87 Function: The method to call when ending a report, this is
88 mostly for cleanup for formats which require you to
89 have something at the end of the document (</BODY></HTML>)
97 sub end_report
{ return '' }
102 Usage : $writer->filter('hsp', \&hsp_filter);
103 Function: Filter out either at HSP,Hit,or Result level
105 Args : string => data type,
111 # yes this is an implementation in the interface,
112 # yes it assumes that the underlying class is hash-based
113 # yes that might not be a good idea, but until people
114 # start extending the SearchWriterI interface I think
115 # this is an okay way to go
118 my ($self,$method,$code) = @_;
119 return unless $method;
120 $method = uc($method);
121 if( $method ne 'HSP' &&
123 $method ne 'RESULT' ) {
124 $self->warn("Unknown method $method");
128 $self->throw("Must provide a valid code reference") unless ref($code) =~ /CODE/;
129 $self->{$method} = $code;
131 return $self->{$method};