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
;
65 use base
qw(Bio::Annotation::DBLink Bio::AnnotationI Bio::Range);
69 my($class,@args) = @_;
71 my $self = $class->SUPER::new
(@args);
73 my ($target_id, $tstart, $tend, $tstrand) =
74 $self->_rearrange([ qw(
80 $target_id && $self->target_id($target_id);
81 $tstart && $self->start($tstart);
82 $tend && $self->end($tend);
83 $tstrand && $self->strand($tstrand);
88 =head1 AnnotationI implementing functions
108 my $target = $self->target_id || '';
109 my $start = $self->start || '';
110 my $end = $self->end || '';
111 my $strand = $self->strand || '';
113 return "Target=".$target." ".$start." ".$end." ".$strand;
119 Usage : my $str = $ann->display_text();
120 Function: returns a string. Unlike as_text(), this method returns a string
121 formatted as would be expected for te specific implementation.
123 One can pass a callback as an argument which allows custom text
124 generation; the callback is passed the current instance and any text
128 Args : [optional] callback
133 my $DEFAULT_CB = sub { $_[0]->as_text || ''};
136 my ($self, $cb) = @_;
138 $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
147 Usage : $obj->tagname($newval)
148 Function: Get/set the tagname for this annotation value.
150 Setting this is optional. If set, it obviates the need to
151 provide a tag to Bio::AnnotationCollectionI when adding
152 this object. When obtaining an AnnotationI object from the
153 collection, the collection will set the value to the tag
154 under which it was stored unless the object has a tag
158 Returns : value of tagname (a scalar)
159 Args : new value (a scalar, optional)
165 my ($self,$value) = @_;
166 if( defined $value) {
167 $self->{'tagname'} = $value;
169 return $self->{'tagname'};
172 =head1 Specific accessors for Targets
182 $obj->target_id() #get existing value
183 $obj->target_id($newval) #set new value
189 value of target_id (a scalar)
193 new value of target_id (to set)
201 return $self->{'target_id'} = shift if defined($_[0]);
202 return $self->{'target_id'} || $self->primary_id();