comparison variant_effect_predictor/Bio/SeqFeature/FeaturePair.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 # $Id: FeaturePair.pm,v 1.17 2002/10/08 08:38:31 lapp Exp $
2 #
3 # BioPerl module for Bio::SeqFeature::FeaturePair
4 #
5 # Cared for by Ewan Birney <birney@sanger.ac.uk>
6 #
7 # Copyright Ewan Birney
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::FeaturePair - hold pair feature information e.g. blast hits
16
17 =head1 SYNOPSIS
18
19 my $feat = new Bio::SeqFeature::FeaturePair(-feature1 => $f1,
20 -feature2 => $f2,
21 );
22
23 # Bio::SeqFeatureI methods can be used
24
25 my $start = $feat->start;
26 my $end = $feat->end;
27
28 # Bio::FeaturePair methods can be used
29 my $hstart = $feat->hstart;
30 my $hend = $feat->hend;
31
32 my $feature1 = $feat->feature1; # returns feature1 object
33
34 =head1 DESCRIPTION
35
36 A sequence feature object where the feature is itself a feature on
37 another sequence - e.g. a blast hit where residues 1-40 of a protein
38 sequence SW:HBA_HUMAN has hit to bases 100 - 220 on a genomic sequence
39 HS120G22. The genomic sequence coordinates are used to create one
40 sequence feature $f1 and the protein coordinates are used to create
41 feature $f2. A FeaturePair object can then be made
42
43 my $fp = new Bio::SeqFeature::FeaturePair(-feature1 => $f1, # genomic
44 -feature2 => $f2, # protein
45 );
46
47 This object can be used as a standard Bio::SeqFeatureI in which case
48
49 my $gstart = $fp->start # returns start coord on feature1 - genomic seq.
50 my $gend = $fp->end # returns end coord on feature1.
51
52 In general standard Bio::SeqFeatureI method calls return information
53 in feature1.
54
55 Data in the feature 2 object are generally obtained using the standard
56 methods prefixed by h (for hit!)
57
58 my $pstart = $fp->hstart # returns start coord on feature2 = protein seq.
59 my $pend = $fp->hend # returns end coord on feature2.
60
61 If you wish to swap feature1 and feature2 around :
62
63 $feat->invert
64
65 so...
66
67 $feat->start # etc. returns data in $feature2 object
68
69
70 No sub_SeqFeatures or tags can be stored in this object directly. Any
71 features or tags are expected to be stored in the contained objects
72 feature1, and feature2.
73
74 =head1 CONTACT
75
76 Ewan Birney E<lt>birney@sanger.ac.ukE<gt>
77
78 =head1 APPENDIX
79
80 The rest of the documentation details each of the object
81 methods. Internal methods are usually preceded with a _
82
83 =cut
84
85
86 # Let the code begin...
87
88
89 package Bio::SeqFeature::FeaturePair;
90 use vars qw(@ISA);
91 use strict;
92
93 use Bio::SeqFeatureI;
94 use Bio::SeqFeature::Generic;
95
96 @ISA = qw(Bio::SeqFeature::Generic);
97
98 sub new {
99 my ($class, @args) = @_;
100 my $self = $class->SUPER::new(@args);
101
102 my ($feature1,$feature2) =
103 $self->_rearrange([qw(FEATURE1
104 FEATURE2
105 )],@args);
106
107 # Store the features in the object
108 $feature1 && $self->feature1($feature1);
109 $feature2 && $self->feature2($feature2);
110 return $self;
111 }
112
113 =head2 feature1
114
115 Title : feature1
116 Usage : $f = $featpair->feature1
117 $featpair->feature1($feature)
118 Function: Get/set for the query feature
119 Returns : Bio::SeqFeatureI
120 Args : Bio::SeqFeatureI
121
122
123 =cut
124
125 sub feature1 {
126 my ($self,$arg) = @_;
127 if ( defined($arg) || !defined $self->{'feature1'} ) {
128 $arg = new Bio::SeqFeature::Generic() unless( defined $arg);
129 $self->throw("Argument [$arg] must be a Bio::SeqFeatureI")
130 unless (ref($arg) && $arg->isa("Bio::SeqFeatureI"));
131 $self->{'feature1'} = $arg;
132 }
133 return $self->{'feature1'};
134 }
135
136 =head2 feature2
137
138 Title : feature2
139 Usage : $f = $featpair->feature2
140 $featpair->feature2($feature)
141 Function: Get/set for the hit feature
142 Returns : Bio::SeqFeatureI
143 Args : Bio::SeqFeatureI
144
145
146 =cut
147
148 sub feature2 {
149 my ($self,$arg) = @_;
150
151 if ( defined($arg) || ! defined $self->{'feature2'}) {
152 $arg = new Bio::SeqFeature::Generic unless( defined $arg);
153 $self->throw("Argument [$arg] must be a Bio::SeqFeatureI")
154 unless (ref($arg) && $arg->isa("Bio::SeqFeatureI"));
155 $self->{'feature2'} = $arg;
156 }
157 return $self->{'feature2'};
158 }
159
160 =head2 start
161
162 Title : start
163 Usage : $start = $featpair->start
164 $featpair->start(20)
165 Function: Get/set on the start coordinate of feature1
166 Returns : integer
167 Args : [optional] beginning of feature
168
169 =cut
170
171 sub start {
172 my ($self,$value) = @_;
173 return $self->feature1->start($value);
174 }
175
176 =head2 end
177
178 Title : end
179 Usage : $end = $featpair->end
180 $featpair->end($end)
181 Function: get/set on the end coordinate of feature1
182 Returns : integer
183 Args : [optional] ending point of feature
184
185
186 =cut
187
188 sub end{
189 my ($self,$value) = @_;
190 return $self->feature1->end($value);
191 }
192
193 =head2 strand
194
195 Title : strand
196 Usage : $strand = $feat->strand()
197 $feat->strand($strand)
198 Function: get/set on strand information, being 1,-1 or 0
199 Returns : -1,1 or 0
200 Args : [optional] strand information to set
201
202
203 =cut
204
205 sub strand{
206 my ($self,$arg) = @_;
207 return $self->feature1->strand($arg);
208 }
209
210 =head2 location
211
212 Title : location
213 Usage : $location = $featpair->location
214 $featpair->location($location)
215 Function: Get/set location object (using feature1)
216 Returns : Bio::LocationI object
217 Args : [optional] LocationI to store
218
219 =cut
220
221 sub location {
222 my ($self,$value) = @_;
223 return $self->feature1->location($value);
224 }
225
226 =head2 score
227
228 Title : score
229 Usage : $score = $feat->score()
230 $feat->score($score)
231 Function: get/set on score information
232 Returns : float
233 Args : none if get, the new value if set
234
235
236 =cut
237
238 sub score {
239 my ($self,$arg) = @_;
240 return $self->feature1->score($arg);
241 }
242
243 =head2 frame
244
245 Title : frame
246 Usage : $frame = $feat->frame()
247 $feat->frame($frame)
248 Function: get/set on frame information
249 Returns : 0,1,2
250 Args : none if get, the new value if set
251
252
253 =cut
254
255 sub frame {
256 my ($self,$arg) = @_;
257 return $self->feature1->frame($arg);
258 }
259
260 =head2 primary_tag
261
262 Title : primary_tag
263 Usage : $ptag = $featpair->primary_tag
264 Function: get/set on the primary_tag of feature1
265 Returns : 0,1,2
266 Args : none if get, the new value if set
267
268
269 =cut
270
271 sub primary_tag{
272 my ($self,$arg) = @_;
273 return $self->feature1->primary_tag($arg);
274 }
275
276 =head2 source_tag
277
278 Title : source_tag
279 Usage : $tag = $feat->source_tag()
280 $feat->source_tag('genscan');
281 Function: Returns the source tag for a feature,
282 eg, 'genscan'
283 Returns : a string
284 Args : none
285
286
287 =cut
288
289 sub source_tag{
290 my ($self,$arg) = @_;
291 return $self->feature1->source_tag($arg);
292 }
293
294 =head2 seqname
295
296 Title : seqname
297 Usage : $obj->seq_id($newval)
298 Function: There are many cases when you make a feature that you
299 do know the sequence name, but do not know its actual
300 sequence. This is an attribute such that you can store
301 the seqname.
302
303 This attribute should *not* be used in GFF dumping, as
304 that should come from the collection in which the seq
305 feature was found.
306 Returns : value of seqname
307 Args : newvalue (optional)
308
309
310 =cut
311
312 sub seqname{
313 my ($self,$arg) = @_;
314 return $self->feature1->seq_id($arg);
315 }
316
317 =head2 hseqname
318
319 Title : hseqname
320 Usage : $featpair->hseqname($newval)
321 Function: Get/set method for the name of
322 feature2.
323 Returns : value of $feature2->seq_id
324 Args : newvalue (optional)
325
326
327 =cut
328
329 sub hseqname {
330 my ($self,$arg) = @_;
331 return $self->feature2->seq_id($arg);
332 }
333
334
335 =head2 hstart
336
337 Title : hstart
338 Usage : $start = $featpair->hstart
339 $featpair->hstart(20)
340 Function: Get/set on the start coordinate of feature2
341 Returns : integer
342 Args : none
343
344 =cut
345
346 sub hstart {
347 my ($self,$value) = @_;
348 return $self->feature2->start($value);
349 }
350
351 =head2 hend
352
353 Title : hend
354 Usage : $end = $featpair->hend
355 $featpair->hend($end)
356 Function: get/set on the end coordinate of feature2
357 Returns : integer
358 Args : none
359
360
361 =cut
362
363 sub hend{
364 my ($self,$value) = @_;
365 return $self->feature2->end($value);
366 }
367
368
369 =head2 hstrand
370
371 Title : hstrand
372 Usage : $strand = $feat->strand()
373 $feat->strand($strand)
374 Function: get/set on strand information, being 1,-1 or 0
375 Returns : -1,1 or 0
376 Args : none
377
378
379 =cut
380
381 sub hstrand{
382 my ($self,$arg) = @_;
383 return $self->feature2->strand($arg);
384 }
385
386 =head2 hscore
387
388 Title : hscore
389 Usage : $score = $feat->score()
390 $feat->score($score)
391 Function: get/set on score information
392 Returns : float
393 Args : none if get, the new value if set
394
395
396 =cut
397
398 sub hscore {
399 my ($self,$arg) = @_;
400 return $self->feature2->score($arg);
401 }
402
403 =head2 hframe
404
405 Title : hframe
406 Usage : $frame = $feat->frame()
407 $feat->frame($frame)
408 Function: get/set on frame information
409 Returns : 0,1,2
410 Args : none if get, the new value if set
411
412
413 =cut
414
415 sub hframe {
416 my ($self,$arg) = @_;
417 return $self->feature2->frame($arg);
418 }
419
420 =head2 hprimary_tag
421
422 Title : hprimary_tag
423 Usage : $ptag = $featpair->hprimary_tag
424 Function: Get/set on the primary_tag of feature2
425 Returns : 0,1,2
426 Args : none if get, the new value if set
427
428
429 =cut
430
431 sub hprimary_tag{
432 my ($self,$arg) = @_;
433 return $self->feature2->primary_tag($arg);
434 }
435
436 =head2 hsource_tag
437
438 Title : hsource_tag
439 Usage : $tag = $feat->hsource_tag()
440 $feat->source_tag('genscan');
441 Function: Returns the source tag for a feature,
442 eg, 'genscan'
443 Returns : a string
444 Args : none
445
446
447 =cut
448
449 sub hsource_tag{
450 my ($self,$arg) = @_;
451 return $self->feature2->source_tag($arg);
452 }
453
454 =head2 invert
455
456 Title : invert
457 Usage : $tag = $feat->invert
458 Function: Swaps feature1 and feature2 around
459 Returns : Nothing
460 Args : none
461
462
463 =cut
464
465 sub invert {
466 my ($self) = @_;
467
468 my $tmp = $self->feature1;
469
470 $self->feature1($self->feature2);
471 $self->feature2($tmp);
472 return undef;
473 }
474
475 1;