0
|
1 # $Id: SimilarityPair.pm,v 1.21 2002/12/24 15:15:32 jason Exp $
|
|
2 #
|
|
3 # BioPerl module for Bio::SeqFeature::SimilarityPair
|
|
4 #
|
|
5 # Cared for by Hilmar Lapp <hlapp@gmx.net>
|
|
6 #
|
|
7 # Copyright Hilmar Lapp
|
|
8 #
|
|
9 # You may distribute this module under the same terms as perl itself
|
|
10
|
|
11 # POD documentation - main docs before the code
|
|
12
|
|
13 =head1 NAME
|
|
14
|
|
15 Bio::SeqFeature::SimilarityPair - Sequence feature based on the similarity
|
|
16 of two sequences.
|
|
17
|
|
18 =head1 SYNOPSIS
|
|
19
|
|
20 $sim_pair = Bio::SeqFeature::SimilarityPair->from_searchResult($blastHit);
|
|
21
|
|
22 $sim = $sim_pair->query(); # a Bio::SeqFeature::Similarity object - the query
|
|
23 $sim = $sim_pair->hit(); # dto - the hit.
|
|
24
|
|
25 # some properties for the similarity pair
|
|
26 $expect = $sim_pair->significance();
|
|
27 $score = $sim_pair->score();
|
|
28 $bitscore = $sim_pair->bits();
|
|
29
|
|
30 # this will not write the description for the sequence (only its name)
|
|
31 print $sim_pair->query()->gff_string(), "\n";
|
|
32
|
|
33 =head1 DESCRIPTION
|
|
34
|
|
35 Lightweight similarity search result as a pair of Similarity
|
|
36 features. This class inherits off Bio::SeqFeature::FeaturePair and
|
|
37 therefore implements Bio::SeqFeatureI, whereas the two features of the
|
|
38 pair are descendants of Bio::SeqFeature::Generic, with better support
|
|
39 for representing similarity search results in a cleaner way.
|
|
40
|
|
41 =head1 FEEDBACK
|
|
42
|
|
43 =head2 Mailing Lists
|
|
44
|
|
45 User feedback is an integral part of the evolution of this and other
|
|
46 Bioperl modules. Send your comments and suggestions preferably to one
|
|
47 of the Bioperl mailing lists. Your participation is much appreciated.
|
|
48
|
|
49 bioperl-l@bioperl.org - General discussion
|
|
50 http://bio.perl.org/MailList.html - About the mailing lists
|
|
51
|
|
52 =head2 Reporting Bugs
|
|
53
|
|
54 Report bugs to the Bioperl bug tracking system to help us keep track
|
|
55 the bugs and their resolution. Bug reports can be submitted via
|
|
56 email or the web:
|
|
57
|
|
58 bioperl-bugs@bio.perl.org
|
|
59 http://bugzilla.bioperl.org/
|
|
60
|
|
61 =head1 AUTHOR - Hilmar Lapp
|
|
62
|
|
63 Email hlapp@gmx.net or hilmar.lapp@pharma.novartis.com
|
|
64
|
|
65 Describe contact details here
|
|
66
|
|
67 =head1 APPENDIX
|
|
68
|
|
69 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
|
|
70
|
|
71 =cut
|
|
72
|
|
73
|
|
74 # Let the code begin...
|
|
75
|
|
76
|
|
77 package Bio::SeqFeature::SimilarityPair;
|
|
78 use vars qw(@ISA);
|
|
79 use strict;
|
|
80
|
|
81 use Bio::SeqFeature::FeaturePair;
|
|
82 use Bio::SeqFeature::Similarity;
|
|
83 use Bio::SearchIO;
|
|
84
|
|
85 @ISA = qw(Bio::SeqFeature::FeaturePair);
|
|
86
|
|
87 =head2 new
|
|
88
|
|
89 Title : new
|
|
90 Usage : my $similarityPair = new Bio::SeqFeature::SimilarityPair
|
|
91 (-hit => $hit,
|
|
92 -query => $query,
|
|
93 -source => 'blastp');
|
|
94 Function: Initializes a new SimilarityPair object
|
|
95 Returns : Bio::SeqFeature::SimilarityPair
|
|
96 Args : -query => The query in a Feature pair
|
|
97 -hit => (formerly '-subject') the subject/hit in a Feature pair
|
|
98
|
|
99
|
|
100 =cut
|
|
101
|
|
102 sub new {
|
|
103 my($class,@args) = @_;
|
|
104
|
|
105 my $self = $class->SUPER::new(@args);
|
|
106
|
|
107 # Hack to deal with the fact that SimilarityPair calls strand()
|
|
108 # which will lead to an error in Bio::Search::HSP::BlastHSP
|
|
109 # because parsing hasn't yet occurred.
|
|
110 # TODO: Remove this when BlastHSP doesn't do lazy parsing.
|
|
111 $self->{'_initializing'} = 1;
|
|
112
|
|
113 my ($primary, $hit, $query, $fea1, $source,$sbjct) =
|
|
114 $self->_rearrange([qw(PRIMARY
|
|
115 HIT
|
|
116 QUERY
|
|
117 FEATURE1
|
|
118 SOURCE
|
|
119 SUBJECT
|
|
120 )],@args);
|
|
121
|
|
122 if( $sbjct ) {
|
|
123 # undeprecated by Jason before 1.1 release
|
|
124 # $self->deprecated("use of -subject deprecated: SimilarityPair now uses 'hit'");
|
|
125 if(! $hit) { $hit = $sbjct }
|
|
126 else {
|
|
127 $self->warn("-hit and -subject were specified, using -hit and ignoring -subject");
|
|
128 }
|
|
129 }
|
|
130
|
|
131 # make sure at least the query feature exists -- this refers to feature1
|
|
132 if($query && ! $fea1) { $self->query( $query); }
|
|
133 else { $self->query('null'); } # call with no args sets a default value for query
|
|
134
|
|
135 $hit && $self->hit($hit);
|
|
136 # the following refer to feature1, which has been ensured to exist
|
|
137 if( defined $primary || ! defined $self->primary_tag) {
|
|
138 $primary = 'similarity' unless defined $primary;
|
|
139 $self->primary_tag($primary);
|
|
140 }
|
|
141
|
|
142 $source && $self->source_tag($source);
|
|
143 $self->strand(0) unless( defined $self->strand() );
|
|
144
|
|
145 $self->{'_initializing'} = 0; # See "Hack" note above
|
|
146 return $self;
|
|
147 }
|
|
148
|
|
149 #
|
|
150 # Everything else is just inherited from SeqFeature::FeaturePair.
|
|
151 #
|
|
152
|
|
153 =head2 query
|
|
154
|
|
155 Title : query
|
|
156 Usage : $query_feature = $obj->query();
|
|
157 $obj->query($query_feature);
|
|
158 Function: The query object for this similarity pair
|
|
159 Returns : Bio::SeqFeature::Similarity
|
|
160 Args : [optional] Bio::SeqFeature::Similarity
|
|
161
|
|
162 See L<Bio::SeqFeature::Similarity>, L<Bio::SeqFeature::FeaturePair>
|
|
163
|
|
164 =cut
|
|
165
|
|
166 sub query {
|
|
167 my ($self, @args) = @_;
|
|
168 my $f = $self->feature1();
|
|
169 if( ! @args || ( !ref($args[0]) && $args[0] eq 'null') ) {
|
|
170 if( ! defined( $f) ) {
|
|
171 @args = Bio::SeqFeature::Similarity->new();
|
|
172 } elsif( ! $f->isa('Bio::SeqFeature::Similarity') &&
|
|
173 $f->isa('Bio::SeqFeatureI') ) {
|
|
174 # a Bio::SeqFeature::Generic was placeholder for feature1
|
|
175 my $newf = new
|
|
176 Bio::SeqFeature::Similarity( -start => $f->start(),
|
|
177 -end => $f->end(),
|
|
178 -strand => $f->strand(),
|
|
179 -primary => $f->primary_tag(),
|
|
180 -source => $f->source_tag(),
|
|
181 -seq_id => $f->seq_id(),
|
|
182 -score => $f->score(),
|
|
183 -frame => $f->frame(),
|
|
184 );
|
|
185 foreach my $tag ( $newf->all_tags ) {
|
|
186 $tag->add_tag($tag, $newf->each_tag($tag));
|
|
187 }
|
|
188 @args = $newf;
|
|
189 } else {
|
|
190 @args = ();
|
|
191 }
|
|
192 }
|
|
193 return $self->feature1(@args);
|
|
194 }
|
|
195
|
|
196
|
|
197
|
|
198
|
|
199 =head2 subject
|
|
200
|
|
201 Title : subject
|
|
202 Usage : $sbjct_feature = $obj->subject();
|
|
203 $obj->subject($sbjct_feature);
|
|
204 Function: Get/Set Subject for a SimilarityPair
|
|
205 Returns : Bio::SeqFeature::Similarity
|
|
206 Args : [optional] Bio::SeqFeature::Similarity
|
|
207 Notes : Deprecated. Use the method 'hit' instead
|
|
208
|
|
209 =cut
|
|
210
|
|
211 sub subject {
|
|
212 my $self = shift;
|
|
213 # $self->deprecated("Method subject deprecated: use hit() instead");
|
|
214 $self->hit(@_);
|
|
215 }
|
|
216
|
|
217 *sbjct = \&subject;
|
|
218
|
|
219 =head2 hit
|
|
220
|
|
221 Title : hit
|
|
222 Usage : $sbjct_feature = $obj->hit();
|
|
223 $obj->hit($sbjct_feature);
|
|
224 Function: Get/Set Hit for a SimilarityPair
|
|
225 Returns : Bio::SeqFeature::Similarity
|
|
226 Args : [optional] Bio::SeqFeature::Similarity
|
|
227
|
|
228
|
|
229 =cut
|
|
230
|
|
231 sub hit {
|
|
232 my ($self, @args) = @_;
|
|
233 my $f = $self->feature2();
|
|
234 if(! @args || (!ref($args[0]) && $args[0] eq 'null') ) {
|
|
235 if( ! defined( $f) ) {
|
|
236 @args = Bio::SeqFeature::Similarity->new();
|
|
237 } elsif( ! $f->isa('Bio::SeqFeature::Similarity') &&
|
|
238 $f->isa('Bio::SeqFeatureI')) {
|
|
239 # a Bio::SeqFeature::Generic was placeholder for feature2
|
|
240 my $newf = new
|
|
241 Bio::SeqFeature::Similarity( -start => $f->start(),
|
|
242 -end => $f->end(),
|
|
243 -strand => $f->strand(),
|
|
244 -primary => $f->primary_tag(),
|
|
245 -source => $f->source_tag(),
|
|
246 -seq_id => $f->seq_id(),
|
|
247 -score => $f->score(),
|
|
248 -frame => $f->frame(),
|
|
249 );
|
|
250 foreach my $tag ( $newf->all_tags ) {
|
|
251 $tag->add_tag($tag, $newf->each_tag($tag));
|
|
252 }
|
|
253 @args = $newf;
|
|
254 }
|
|
255 }
|
|
256 return $self->feature2(@args);
|
|
257 }
|
|
258
|
|
259 =head2 source_tag
|
|
260
|
|
261 Title : source_tag
|
|
262 Usage : $source = $obj->source_tag(); # i.e., program
|
|
263 $obj->source_tag($evalue);
|
|
264 Function: Gets the source tag (program name typically) for a feature
|
|
265 Returns : string
|
|
266 Args : [optional] string
|
|
267
|
|
268
|
|
269 =cut
|
|
270
|
|
271 sub source_tag {
|
|
272 my ($self, @args) = @_;
|
|
273
|
|
274 if(@args) {
|
|
275 $self->hit()->source_tag(@args);
|
|
276 }
|
|
277 return $self->query()->source_tag(@args);
|
|
278 }
|
|
279
|
|
280 =head2 significance
|
|
281
|
|
282 Title : significance
|
|
283 Usage : $evalue = $obj->significance();
|
|
284 $obj->significance($evalue);
|
|
285 Function:
|
|
286 Returns :
|
|
287 Args :
|
|
288
|
|
289
|
|
290 =cut
|
|
291
|
|
292 sub significance {
|
|
293 my ($self, @args) = @_;
|
|
294
|
|
295 if(@args) {
|
|
296 $self->hit()->significance(@args);
|
|
297 }
|
|
298 return $self->query()->significance(@args);
|
|
299 }
|
|
300
|
|
301 =head2 score
|
|
302
|
|
303 Title : score
|
|
304 Usage : $score = $obj->score();
|
|
305 $obj->score($value);
|
|
306 Function:
|
|
307 Returns :
|
|
308 Args :
|
|
309
|
|
310
|
|
311 =cut
|
|
312
|
|
313 sub score {
|
|
314 my ($self, @args) = @_;
|
|
315
|
|
316 if(@args) {
|
|
317 $self->hit()->score(@args);
|
|
318 }
|
|
319 return $self->query()->score(@args);
|
|
320 }
|
|
321
|
|
322 =head2 bits
|
|
323
|
|
324 Title : bits
|
|
325 Usage : $bits = $obj->bits();
|
|
326 $obj->bits($value);
|
|
327 Function:
|
|
328 Returns :
|
|
329 Args :
|
|
330
|
|
331
|
|
332 =cut
|
|
333
|
|
334 sub bits {
|
|
335 my ($self, @args) = @_;
|
|
336
|
|
337 if(@args) {
|
|
338 $self->hit()->bits(@args);
|
|
339 }
|
|
340 return $self->query()->bits(@args);
|
|
341 }
|
|
342
|
|
343 1;
|