2 # BioPerl module for Bio::Annotation::Reference
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 # Copyright Ewan Birney
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Annotation::Reference - Specialised DBLink object for Literature References
20 $reg = Bio::Annotation::Reference->new( -title => 'title line',
21 -location => 'location line',
22 -authors => 'author line',
27 Object which presents a literature reference. This is considered to be
28 a specialised form of database link. The additional methods provided
29 are all set/get methods to store strings commonly associated with
30 references, in particular title, location (ie, journal page) and
33 There is no attempt to do anything more than store these things as
34 strings for processing elsewhere. This is mainly because parsing these
35 things suck and generally are specific to the specific format one is
36 using. To provide an easy route to go format --E<gt> object --E<gt> format
37 without losing data, we keep them as strings. Feel free to post the
38 list for a better solution, but in general this gets very messy very
41 =head1 AUTHOR - Ewan Birney
43 Email birney@ebi.ac.uk
47 The rest of the documentation details each of the object
48 methods. Internal methods are usually preceded with a _
53 # Let the code begin...
55 package Bio
::Annotation
::Reference
;
59 use base
qw(Bio::Annotation::DBLink);
64 Usage : $ref = Bio::Annotation::Reference->new( -title => 'title line',
65 -authors => 'author line',
66 -location => 'location line',
70 Returns : a new Bio::Annotation::Reference object
71 Args : a hash with optional title, authors, location, medline, pubmed,
72 start, end, consortium, rp and rg attributes
78 my ($class,@args) = @_;
80 my $self = $class->SUPER::new
(@args);
82 my ($start,$end,$authors,$consortium,$location,$title,$medline,
83 $pubmed,$rp,$rg,$doi) =
84 $self->_rearrange([qw(START
97 defined $start && $self->start($start);
98 defined $end && $self->end($end);
99 defined $authors && $self->authors($authors);
100 defined $consortium && $self->consortium($consortium);
101 defined $location && $self->location($location);
102 defined $title && $self->title($title);
103 defined $medline && $self->medline($medline);
104 defined $pubmed && $self->pubmed($pubmed);
105 defined $rp && $self->rp($rp);
106 defined $rg && $self->rg($rg);
107 defined $doi && $self->doi($doi);
112 =head1 AnnotationI implementing functions
131 # this could get out of hand!
132 return "Reference: ".$self->title;
138 Usage : my $str = $ann->display_text();
139 Function: returns a string. Unlike as_text(), this method returns a string
140 formatted as would be expected for te specific implementation.
142 One can pass a callback as an argument which allows custom text
143 generation; the callback is passed the current instance and any text
147 Args : [optional] callback
152 my $DEFAULT_CB = sub { $_[0]->title || ''};
155 my ($self, $cb) = @_;
157 $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
179 $h->{'title'} = $self->title;
180 $h->{'authors'} = $self->authors;
181 $h->{'location'} = $self->location;
182 if (defined $self->start) {
183 $h->{'start'} = $self->start;
185 if (defined $self->end) {
186 $h->{'end'} = $self->end;
188 $h->{'medline'} = $self->medline;
189 if (defined $self->pubmed) {
190 $h->{'pubmed'} = $self->pubmed;
199 Usage : $obj->tagname($newval)
200 Function: Get/set the tagname for this annotation value.
202 Setting this is optional. If set, it obviates the need to provide
203 a tag to Bio::AnnotationCollectionI when adding this object. When
204 obtaining an AnnotationI object from the collection, the collection
205 will set the value to the tag under which it was stored unless the
206 object has a tag stored already.
208 Returns : value of tagname (a scalar)
209 Args : new value (a scalar, optional)
215 =head1 Specific accessors for References
223 Usage : $self->start($newval)
224 Function: Gives the reference start base
226 Returns : value of start
227 Args : newvalue (optional)
233 my ($self,$value) = @_;
234 if( defined $value) {
235 $self->{'start'} = $value;
237 return $self->{'start'};
244 Usage : $self->end($newval)
245 Function: Gives the reference end base
247 Returns : value of end
248 Args : newvalue (optional)
254 my ($self,$value) = @_;
255 if( defined $value) {
256 $self->{'end'} = $value;
258 return $self->{'end'};
264 Usage : $self->rp($newval)
265 Function: Gives the RP line. No attempt is made to parse this line.
267 Returns : value of rp
268 Args : newvalue (optional)
274 my ($self,$value) = @_;
275 if( defined $value) {
276 $self->{'rp'} = $value;
278 return $self->{'rp'};
284 Usage : $obj->rg($newval)
285 Function: Gives the RG line. This is Swissprot/Uniprot specific, and
286 if set will usually be identical to the authors attribute,
287 but the swissprot manual does allow both RG and RA (author)
288 to be present for the same reference.
291 Returns : value of rg (a scalar)
292 Args : on set, new value (a scalar or undef, optional)
300 return $self->{'rg'} = shift if @_;
301 return $self->{'rg'};
307 Usage : $self->authors($newval)
308 Function: Gives the author line. No attempt is made to parse the author line
310 Returns : value of authors
311 Args : newvalue (optional)
317 my ($self,$value) = @_;
318 if( defined $value) {
319 $self->{'authors'} = $value;
321 return $self->{'authors'};
328 Usage : $self->location($newval)
329 Function: Gives the location line. No attempt is made to parse the location line
331 Returns : value of location
332 Args : newvalue (optional)
338 my ($self,$value) = @_;
339 if( defined $value) {
340 $self->{'location'} = $value;
342 return $self->{'location'};
349 Usage : $self->title($newval)
350 Function: Gives the title line (if exists)
352 Returns : value of title
353 Args : newvalue (optional)
359 my ($self,$value) = @_;
360 if( defined $value) {
361 $self->{'title'} = $value;
363 return $self->{'title'};
370 Usage : $self->medline($newval)
371 Function: Gives the medline number
373 Returns : value of medline
374 Args : newvalue (optional)
380 my ($self,$value) = @_;
381 if( defined $value) {
382 $self->{'medline'} = $value;
384 return $self->{'medline'};
390 Usage : $refobj->pubmed($newval)
391 Function: Get/Set the PubMed number, if it is different from the MedLine
394 Returns : value of medline
395 Args : newvalue (optional)
401 my ($self,$value) = @_;
402 if( defined $value) {
403 $self->{'pubmed'} = $value;
405 return $self->{'pubmed'};
412 Function: Overrides DBLink database to be hard coded to 'MEDLINE' (or 'PUBMED'
413 if only pubmed id has been supplied), unless the database has been
414 set explicitly before.
423 my ($self, @args) = @_;
424 my $default = 'MEDLINE';
425 if (! defined $self->medline && defined $self->pubmed) {
428 return $self->SUPER::database
(@args) || $default;
435 Function: Overrides DBLink primary_id to provide medline number, or pubmed
436 number if only that has been defined
445 my ($self, @args) = @_;
447 $self->medline(@args);
449 if (! defined $self->medline && defined $self->pubmed) {
450 return $self->pubmed;
452 return $self->medline;
459 Function: Overrides DBLink optional_id to provide the PubMed number.
468 my ($self, @args) = @_;
470 return $self->pubmed(@args);
476 Usage : $self->publisher($newval)
477 Function: Gives the publisher line. No attempt is made to parse the publisher line
479 Returns : value of publisher
480 Args : newvalue (optional)
486 my ($self,$value) = @_;
487 if( defined $value) {
488 $self->{'publisher'} = $value;
490 return $self->{'publisher'};
497 Usage : $self->editors($newval)
498 Function: Gives the editors line. No attempt is made to parse the editors line
500 Returns : value of editors
501 Args : newvalue (optional)
507 my ($self,$value) = @_;
508 if( defined $value) {
509 $self->{'editors'} = $value;
511 return $self->{'editors'};
518 Usage : $self->encoded_ref($newval)
519 Function: Gives the encoded_ref line. No attempt is made to parse the encoded_ref line
520 (this is added for reading PDB records (REFN record), where this contains
523 Returns : value of encoded_ref
524 Args : newvalue (optional)
530 my ($self,$value) = @_;
531 if( defined $value) {
532 $self->{'encoded_ref'} = $value;
534 return $self->{'encoded_ref'};
540 Usage : $self->doi($newval)
541 Function: Gives the DOI (Digital Object Identifier) from the International
542 DOI Foundation (http://www.doi.org/), which can be used to resolve
543 URL links for the full-text documents using:
545 http://dx.doi.org/<doi>
548 Returns : value of doi
549 Args : newvalue (optional)
554 my ($self,$value) = @_;
555 if( defined $value) {
556 $self->{'doi'} = $value;
558 return $self->{'doi'};
564 Usage : $self->consortium($newval)
565 Function: Gives the consortium line. No attempt is made to parse the consortium line
567 Returns : value of consortium
568 Args : newvalue (optional)
574 my ($self,$value) = @_;
575 if( defined $value) {
576 $self->{'consortium'} = $value;
578 return $self->{'consortium'};
584 Usage : $obj->gb_reference($newval)
585 Function: Gives the generic GenBank REFERENCE line. This is GenBank-specific.
586 If set, this includes everything on the reference line except
587 the REFERENCE tag and the reference count. This is mainly a
588 fallback for the few instances when REFERENCE lines have unusual
589 additional information such as split sequence locations, feature
590 references, etc. See Bug 2020 in Bugzilla for more information.
592 Returns : value of gb_reference (a scalar)
593 Args : on set, new value (a scalar or undef, optional)
599 my ($self,$value) = @_;
600 if( defined $value) {
601 $self->{'gb_reference'} = $value;
603 return $self->{'gb_reference'};