2 # BioPerl module for Bio::Annotation::Target
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Scott Cain <cain@cshl.org>
10 # Based on the Bio::Annotation::DBLink by Ewan Birney
12 # You may distribute this module under the same terms as perl itself
14 # POD documentation - main docs before the code
18 Bio::Annotation::Target - Provides an object which represents a target (ie, a
19 similarity hit) from one object to something in another database
23 $target1 = Bio::Annotation::Target->new(-target_id => 'F321966.1',
31 $target2 = Bio::Annotation::Target->new();
32 $target2->target_id('Q75IM5');
36 # Target is-a Bio::AnnotationI object, can be added to annotation
37 # collections, e.g. the one on features or seqs
38 $feat->annotation->add_Annotation('Target', $target2);
43 Provides an object which represents a target (ie, a similarity hit) from
44 one object to something in another database without prescribing what is
47 =head1 AUTHOR - Scott Cain
49 Scott Cain - cain@cshl.org
53 The rest of the documentation details each of the object
54 methods. Internal methods are usually preceded with a _
59 # Let the code begin...
61 package Bio
::Annotation
::Target
;
64 use base
qw(Bio::Annotation::DBLink Bio::AnnotationI Bio::Range);
68 my($class,@args) = @_;
70 my $self = $class->SUPER::new
(@args);
72 my ($target_id, $tstart, $tend, $tstrand) =
73 $self->_rearrange([ qw(
79 $target_id && $self->target_id($target_id);
80 $tstart && $self->start($tstart);
81 $tend && $self->end($tend);
82 $tstrand && $self->strand($tstrand);
87 =head1 AnnotationI implementing functions
107 my $target = $self->target_id || '';
108 my $start = $self->start || '';
109 my $end = $self->end || '';
110 my $strand = $self->strand || '';
112 return "Target=".$target." ".$start." ".$end." ".$strand;
118 Usage : my $str = $ann->display_text();
119 Function: returns a string. Unlike as_text(), this method returns a string
120 formatted as would be expected for te specific implementation.
122 One can pass a callback as an argument which allows custom text
123 generation; the callback is passed the current instance and any text
127 Args : [optional] callback
132 my $DEFAULT_CB = sub { $_[0]->as_text || ''};
135 my ($self, $cb) = @_;
137 $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
146 Usage : $obj->tagname($newval)
147 Function: Get/set the tagname for this annotation value.
149 Setting this is optional. If set, it obviates the need to
150 provide a tag to Bio::AnnotationCollectionI when adding
151 this object. When obtaining an AnnotationI object from the
152 collection, the collection will set the value to the tag
153 under which it was stored unless the object has a tag
157 Returns : value of tagname (a scalar)
158 Args : new value (a scalar, optional)
164 my ($self,$value) = @_;
165 if( defined $value) {
166 $self->{'tagname'} = $value;
168 return $self->{'tagname'};
171 =head1 Specific accessors for Targets
181 $obj->target_id() #get existing value
182 $obj->target_id($newval) #set new value
188 value of target_id (a scalar)
192 new value of target_id (to set)
200 return $self->{'target_id'} = shift if defined($_[0]);
201 return $self->{'target_id'} || $self->primary_id();