comparison variant_effect_predictor/Bio/SearchIO/SearchWriterI.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 #-----------------------------------------------------------------
2 # $Id: SearchWriterI.pm,v 1.7 2002/12/01 00:05:01 jason Exp $
3 #
4 # BioPerl module Bio::SearchIO::SearchWriterI
5 #
6 # Cared for by Steve Chervitz <sac@bioperl.org>
7 #
8 # You may distribute this module under the same terms as perl itself
9 #-----------------------------------------------------------------
10
11 =head1 NAME
12
13 Bio::SearchIO::SearchWriterI - Interface for outputting parsed Search results
14
15 =head1 SYNOPSIS
16
17 Bio::SearchIO::SearchWriterI objects cannot be instantiated since this
18 module defines a pure interface.
19
20 Given an object that implements the Bio::SearchIO::SearchWriterI interface,
21 you can do the following things with it:
22
23 print $writer->to_string( $result_obj, @args );
24
25 =head1 DESCRIPTION
26
27 This module defines abstract methods that all subclasses must implement
28 to be used for outputting results from B<Bio::Search::Result::ResultI>
29 objects.
30
31 =head1 AUTHOR
32
33 Steve Chervitz E<lt>sac@bioperl.orgE<gt>
34
35 =head1 DISCLAIMER
36
37 This software is provided "as is" without warranty of any kind.
38
39 =head1 APPENDIX
40
41 The rest of the documentation details each of the object methods.
42
43 =cut
44
45 package Bio::SearchIO::SearchWriterI;
46
47 use Bio::Root::RootI;
48
49 @ISA = qw( Bio::Root::RootI );
50
51 =head2 to_string
52
53 Purpose : Produces data for each Search::Result::ResultI in a string.
54 : This is an abstract method. For some useful implementations,
55 : see ResultTableWriter.pm, HitTableWriter.pm,
56 : and HSPTableWriter.pm.
57 Usage : print $writer->to_string( $result_obj, @args );
58 Argument : $result_obj = A Bio::Search::Result::ResultI object
59 : @args = any additional arguments used by your implementation.
60 Returns : String containing data for each search Result or any of its
61 : sub-objects (Hits and HSPs).
62 Throws : n/a
63
64 =cut
65
66 sub to_string {
67 my ($self, $result, @args) = @_;
68 $self->throw_not_implemented;
69 }
70
71 =head2 end_report
72
73 Title : end_report
74 Usage : $self->end_report()
75 Function: The method to call when ending a report, this is
76 mostly for cleanup for formats which require you to
77 have something at the end of the document (</BODY></HTML>)
78 for HTML
79 Returns : string
80 Args : none
81
82
83 =cut
84
85 sub end_report {
86 my $self = shift;
87 return '';
88 }
89
90 =head2 filter
91
92 Title : filter
93 Usage : $writer->filter('hsp', \&hsp_filter);
94 Function: Filter out either at HSP,Hit,or Result level
95 Returns : none
96 Args : string => data type,
97 CODE reference
98
99
100 =cut
101
102 # yes this is an implementation in the interface,
103 # yes it assumes that the underlying class is hash-based
104 # yes that might not be a good idea, but until people
105 # start extending the SearchWriterI interface I think
106 # this is an okay way to go
107
108 sub filter {
109 my ($self,$method,$code) = @_;
110 return undef unless $method;
111 $method = uc($method);
112 if( $method ne 'HSP' &&
113 $method ne 'HIT' &&
114 $method ne 'RESULT' ) {
115 $self->warn("Unknown method $method");
116 return undef;
117 }
118 if( $code ) {
119 $self->throw("Must provide a valid code reference") unless ref($code) =~ /CODE/;
120 $self->{$method} = $code;
121 }
122 return $self->{$method};
123 }
124
125 1;
126
127