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
;
58 use base
qw(Bio::Annotation::DBLink);
63 Usage : $ref = Bio::Annotation::Reference->new( -title => 'title line',
64 -authors => 'author line',
65 -location => 'location line',
69 Returns : a new Bio::Annotation::Reference object
70 Args : a hash with optional title, authors, location, medline, pubmed,
71 start, end, consortium, rp and rg attributes
77 my ($class,@args) = @_;
79 my $self = $class->SUPER::new
(@args);
81 my ($start,$end,$authors,$consortium,$location,$title,$medline,
82 $pubmed,$rp,$rg,$doi) =
83 $self->_rearrange([qw(START
96 defined $start && $self->start($start);
97 defined $end && $self->end($end);
98 defined $authors && $self->authors($authors);
99 defined $consortium && $self->consortium($consortium);
100 defined $location && $self->location($location);
101 defined $title && $self->title($title);
102 defined $medline && $self->medline($medline);
103 defined $pubmed && $self->pubmed($pubmed);
104 defined $rp && $self->rp($rp);
105 defined $rg && $self->rg($rg);
106 defined $doi && $self->doi($doi);
111 =head1 AnnotationI implementing functions
130 # this could get out of hand!
131 return "Reference: ".$self->title;
137 Usage : my $str = $ann->display_text();
138 Function: returns a string. Unlike as_text(), this method returns a string
139 formatted as would be expected for te specific implementation.
141 One can pass a callback as an argument which allows custom text
142 generation; the callback is passed the current instance and any text
146 Args : [optional] callback
151 my $DEFAULT_CB = sub { $_[0]->title || ''};
154 my ($self, $cb) = @_;
156 $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
178 $h->{'title'} = $self->title;
179 $h->{'authors'} = $self->authors;
180 $h->{'location'} = $self->location;
181 if (defined $self->start) {
182 $h->{'start'} = $self->start;
184 if (defined $self->end) {
185 $h->{'end'} = $self->end;
187 $h->{'medline'} = $self->medline;
188 if (defined $self->pubmed) {
189 $h->{'pubmed'} = $self->pubmed;
198 Usage : $obj->tagname($newval)
199 Function: Get/set the tagname for this annotation value.
201 Setting this is optional. If set, it obviates the need to provide
202 a tag to Bio::AnnotationCollectionI when adding this object. When
203 obtaining an AnnotationI object from the collection, the collection
204 will set the value to the tag under which it was stored unless the
205 object has a tag stored already.
207 Returns : value of tagname (a scalar)
208 Args : new value (a scalar, optional)
214 =head1 Specific accessors for References
222 Usage : $self->start($newval)
223 Function: Gives the reference start base
225 Returns : value of start
226 Args : newvalue (optional)
232 my ($self,$value) = @_;
233 if( defined $value) {
234 $self->{'start'} = $value;
236 return $self->{'start'};
243 Usage : $self->end($newval)
244 Function: Gives the reference end base
246 Returns : value of end
247 Args : newvalue (optional)
253 my ($self,$value) = @_;
254 if( defined $value) {
255 $self->{'end'} = $value;
257 return $self->{'end'};
263 Usage : $self->rp($newval)
264 Function: Gives the RP line. No attempt is made to parse this line.
266 Returns : value of rp
267 Args : newvalue (optional)
273 my ($self,$value) = @_;
274 if( defined $value) {
275 $self->{'rp'} = $value;
277 return $self->{'rp'};
283 Usage : $obj->rg($newval)
284 Function: Gives the RG line. This is Swissprot/Uniprot specific, and
285 if set will usually be identical to the authors attribute,
286 but the swissprot manual does allow both RG and RA (author)
287 to be present for the same reference.
290 Returns : value of rg (a scalar)
291 Args : on set, new value (a scalar or undef, optional)
299 return $self->{'rg'} = shift if @_;
300 return $self->{'rg'};
306 Usage : $self->authors($newval)
307 Function: Gives the author line. No attempt is made to parse the author line
309 Returns : value of authors
310 Args : newvalue (optional)
316 my ($self,$value) = @_;
317 if( defined $value) {
318 $self->{'authors'} = $value;
320 return $self->{'authors'};
327 Usage : $self->location($newval)
328 Function: Gives the location line. No attempt is made to parse the location line
330 Returns : value of location
331 Args : newvalue (optional)
337 my ($self,$value) = @_;
338 if( defined $value) {
339 $self->{'location'} = $value;
341 return $self->{'location'};
348 Usage : $self->title($newval)
349 Function: Gives the title line (if exists)
351 Returns : value of title
352 Args : newvalue (optional)
358 my ($self,$value) = @_;
359 if( defined $value) {
360 $self->{'title'} = $value;
362 return $self->{'title'};
369 Usage : $self->medline($newval)
370 Function: Gives the medline number
372 Returns : value of medline
373 Args : newvalue (optional)
379 my ($self,$value) = @_;
380 if( defined $value) {
381 $self->{'medline'} = $value;
383 return $self->{'medline'};
389 Usage : $refobj->pubmed($newval)
390 Function: Get/Set the PubMed number, if it is different from the MedLine
393 Returns : value of medline
394 Args : newvalue (optional)
400 my ($self,$value) = @_;
401 if( defined $value) {
402 $self->{'pubmed'} = $value;
404 return $self->{'pubmed'};
411 Function: Overrides DBLink database to be hard coded to 'MEDLINE' (or 'PUBMED'
412 if only pubmed id has been supplied), unless the database has been
413 set explicitly before.
422 my ($self, @args) = @_;
423 my $default = 'MEDLINE';
424 if (! defined $self->medline && defined $self->pubmed) {
427 return $self->SUPER::database
(@args) || $default;
434 Function: Overrides DBLink primary_id to provide medline number, or pubmed
435 number if only that has been defined
444 my ($self, @args) = @_;
446 $self->medline(@args);
448 if (! defined $self->medline && defined $self->pubmed) {
449 return $self->pubmed;
451 return $self->medline;
458 Function: Overrides DBLink optional_id to provide the PubMed number.
467 my ($self, @args) = @_;
469 return $self->pubmed(@args);
475 Usage : $self->publisher($newval)
476 Function: Gives the publisher line. No attempt is made to parse the publisher line
478 Returns : value of publisher
479 Args : newvalue (optional)
485 my ($self,$value) = @_;
486 if( defined $value) {
487 $self->{'publisher'} = $value;
489 return $self->{'publisher'};
496 Usage : $self->editors($newval)
497 Function: Gives the editors line. No attempt is made to parse the editors line
499 Returns : value of editors
500 Args : newvalue (optional)
506 my ($self,$value) = @_;
507 if( defined $value) {
508 $self->{'editors'} = $value;
510 return $self->{'editors'};
517 Usage : $self->encoded_ref($newval)
518 Function: Gives the encoded_ref line. No attempt is made to parse the encoded_ref line
519 (this is added for reading PDB records (REFN record), where this contains
522 Returns : value of encoded_ref
523 Args : newvalue (optional)
529 my ($self,$value) = @_;
530 if( defined $value) {
531 $self->{'encoded_ref'} = $value;
533 return $self->{'encoded_ref'};
539 Usage : $self->doi($newval)
540 Function: Gives the DOI (Digital Object Identifier) from the International
541 DOI Foundation (http://www.doi.org/), which can be used to resolve
542 URL links for the full-text documents using:
544 http://dx.doi.org/<doi>
547 Returns : value of doi
548 Args : newvalue (optional)
553 my ($self,$value) = @_;
554 if( defined $value) {
555 $self->{'doi'} = $value;
557 return $self->{'doi'};
563 Usage : $self->consortium($newval)
564 Function: Gives the consortium line. No attempt is made to parse the consortium line
566 Returns : value of consortium
567 Args : newvalue (optional)
573 my ($self,$value) = @_;
574 if( defined $value) {
575 $self->{'consortium'} = $value;
577 return $self->{'consortium'};
583 Usage : $obj->gb_reference($newval)
584 Function: Gives the generic GenBank REFERENCE line. This is GenBank-specific.
585 If set, this includes everything on the reference line except
586 the REFERENCE tag and the reference count. This is mainly a
587 fallback for the few instances when REFERENCE lines have unusual
588 additional information such as split sequence locations, feature
589 references, etc. See Bug 2020 in Bugzilla for more information.
591 Returns : value of gb_reference (a scalar)
592 Args : on set, new value (a scalar or undef, optional)
598 my ($self,$value) = @_;
599 if( defined $value) {
600 $self->{'gb_reference'} = $value;
602 return $self->{'gb_reference'};