Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Annotation/Reference.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: Reference.pm,v 1.18 2002/09/25 18:11:33 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Annotation::Reference | |
| 4 # | |
| 5 # Cared for by Ewan Birney <birney@ebi.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::Annotation::Reference - Specialised DBLink object for Literature References | |
| 16 | |
| 17 =head1 SYNOPSIS | |
| 18 | |
| 19 $reg = Bio::Annotation::Reference->new( -title => 'title line', | |
| 20 -location => 'location line', | |
| 21 -authors => 'author line', | |
| 22 -medline => 998122 ); | |
| 23 | |
| 24 =head1 DESCRIPTION | |
| 25 | |
| 26 Object which presents a literature reference. This is considered to be | |
| 27 a specialised form of database link. The additional methods provided | |
| 28 are all set/get methods to store strings commonly associated with | |
| 29 references, in particular title, location (ie, journal page) and | |
| 30 authors line. | |
| 31 | |
| 32 There is no attempt to do anything more than store these things as | |
| 33 strings for processing elsewhere. This is mainly because parsing these | |
| 34 things suck and generally are specific to the specific format one is | |
| 35 using. To provide an easy route to go format --E<gt> object --E<gt> format | |
| 36 without losing data, we keep them as strings. Feel free to post the | |
| 37 list for a better solution, but in general this gets very messy very | |
| 38 fast... | |
| 39 | |
| 40 =head1 CONTACT | |
| 41 | |
| 42 Describe contact details here | |
| 43 | |
| 44 =head1 APPENDIX | |
| 45 | |
| 46 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ | |
| 47 | |
| 48 =cut | |
| 49 | |
| 50 | |
| 51 # Let the code begin... | |
| 52 | |
| 53 package Bio::Annotation::Reference; | |
| 54 use vars qw(@ISA); | |
| 55 use strict; | |
| 56 | |
| 57 use Bio::Annotation::DBLink; | |
| 58 use Bio::AnnotationI; | |
| 59 | |
| 60 @ISA = qw(Bio::Annotation::DBLink); | |
| 61 | |
| 62 =head2 new | |
| 63 | |
| 64 Title : new | |
| 65 Usage : $ref = Bio::Annotation::Reference->new( -title => 'title line', | |
| 66 -authors => 'author line', | |
| 67 -location => 'location line', | |
| 68 -medline => 9988812); | |
| 69 Function: | |
| 70 Example : | |
| 71 Returns : a new Bio::Annotation::Reference object | |
| 72 Args : a hash with optional title, authors, location, medline, start and end | |
| 73 attributes | |
| 74 | |
| 75 | |
| 76 =cut | |
| 77 | |
| 78 sub new{ | |
| 79 my ($class,@args) = @_; | |
| 80 | |
| 81 my $self = $class->SUPER::new(@args); | |
| 82 | |
| 83 my ($start,$end,$authors,$location,$title,$medline,$tag) = | |
| 84 $self->_rearrange([qw(START | |
| 85 END | |
| 86 AUTHORS | |
| 87 LOCATION | |
| 88 TITLE | |
| 89 MEDLINE | |
| 90 TAGNAME | |
| 91 )],@args); | |
| 92 | |
| 93 defined $start && $self->start($start); | |
| 94 defined $end && $self->end($end); | |
| 95 defined $authors && $self->authors($authors); | |
| 96 defined $location && $self->location($location); | |
| 97 defined $title && $self->title($title); | |
| 98 defined $medline && $self->medline($medline); | |
| 99 defined $tag && $self->tagname($tag); | |
| 100 | |
| 101 return $self; | |
| 102 } | |
| 103 | |
| 104 | |
| 105 =head1 AnnotationI implementing functions | |
| 106 | |
| 107 =cut | |
| 108 | |
| 109 =head2 as_text | |
| 110 | |
| 111 Title : as_text | |
| 112 Usage : | |
| 113 Function: | |
| 114 Example : | |
| 115 Returns : | |
| 116 Args : | |
| 117 | |
| 118 | |
| 119 =cut | |
| 120 | |
| 121 sub as_text{ | |
| 122 my ($self) = @_; | |
| 123 | |
| 124 # this could get out of hand! | |
| 125 return "Reference: ".$self->title; | |
| 126 } | |
| 127 | |
| 128 | |
| 129 =head2 hash_tree | |
| 130 | |
| 131 Title : hash_tree | |
| 132 Usage : | |
| 133 Function: | |
| 134 Example : | |
| 135 Returns : | |
| 136 Args : | |
| 137 | |
| 138 | |
| 139 =cut | |
| 140 | |
| 141 sub hash_tree{ | |
| 142 my ($self) = @_; | |
| 143 | |
| 144 my $h = {}; | |
| 145 $h->{'title'} = $self->title; | |
| 146 $h->{'authors'} = $self->authors; | |
| 147 $h->{'location'} = $self->location; | |
| 148 if( defined $self->start ) { | |
| 149 $h->{'start'} = $self->start; | |
| 150 } | |
| 151 if( defined $self->end ) { | |
| 152 $h->{'end'} = $self->end; | |
| 153 } | |
| 154 $h->{'medline'} = $self->medline; | |
| 155 | |
| 156 return $h; | |
| 157 } | |
| 158 | |
| 159 =head2 tagname | |
| 160 | |
| 161 Title : tagname | |
| 162 Usage : $obj->tagname($newval) | |
| 163 Function: Get/set the tagname for this annotation value. | |
| 164 | |
| 165 Setting this is optional. If set, it obviates the need to provide | |
| 166 a tag to Bio::AnnotationCollectionI when adding this object. When | |
| 167 obtaining an AnnotationI object from the collection, the collection | |
| 168 will set the value to the tag under which it was stored unless the | |
| 169 object has a tag stored already. | |
| 170 Example : | |
| 171 Returns : value of tagname (a scalar) | |
| 172 Args : new value (a scalar, optional) | |
| 173 | |
| 174 | |
| 175 =cut | |
| 176 | |
| 177 sub tagname{ | |
| 178 my ($self,$value) = @_; | |
| 179 if( defined $value) { | |
| 180 $self->{'tagname'} = $value; | |
| 181 } | |
| 182 return $self->{'tagname'}; | |
| 183 } | |
| 184 | |
| 185 | |
| 186 =head1 Specific accessors for References | |
| 187 | |
| 188 =cut | |
| 189 | |
| 190 | |
| 191 =head2 start | |
| 192 | |
| 193 Title : start | |
| 194 Usage : $self->start($newval) | |
| 195 Function: Gives the reference start base | |
| 196 Example : | |
| 197 Returns : value of start | |
| 198 Args : newvalue (optional) | |
| 199 | |
| 200 | |
| 201 =cut | |
| 202 | |
| 203 sub start { | |
| 204 my ($self,$value) = @_; | |
| 205 if( defined $value) { | |
| 206 $self->{'start'} = $value; | |
| 207 } | |
| 208 return $self->{'start'}; | |
| 209 | |
| 210 } | |
| 211 | |
| 212 =head2 end | |
| 213 | |
| 214 Title : end | |
| 215 Usage : $self->end($newval) | |
| 216 Function: Gives the reference end base | |
| 217 Example : | |
| 218 Returns : value of end | |
| 219 Args : newvalue (optional) | |
| 220 | |
| 221 | |
| 222 =cut | |
| 223 | |
| 224 sub end { | |
| 225 my ($self,$value) = @_; | |
| 226 if( defined $value) { | |
| 227 $self->{'end'} = $value; | |
| 228 } | |
| 229 return $self->{'end'}; | |
| 230 } | |
| 231 | |
| 232 =head2 rp | |
| 233 | |
| 234 Title : rp | |
| 235 Usage : $self->rp($newval) | |
| 236 Function: Gives the RP line. No attempt is made to parse this line. | |
| 237 Example : | |
| 238 Returns : value of rp | |
| 239 Args : newvalue (optional) | |
| 240 | |
| 241 | |
| 242 =cut | |
| 243 | |
| 244 sub rp{ | |
| 245 my ($self,$value) = @_; | |
| 246 if( defined $value) { | |
| 247 $self->{'rp'} = $value; | |
| 248 } | |
| 249 return $self->{'rp'}; | |
| 250 | |
| 251 } | |
| 252 | |
| 253 =head2 authors | |
| 254 | |
| 255 Title : authors | |
| 256 Usage : $self->authors($newval) | |
| 257 Function: Gives the author line. No attempt is made to parse the author line | |
| 258 Example : | |
| 259 Returns : value of authors | |
| 260 Args : newvalue (optional) | |
| 261 | |
| 262 | |
| 263 =cut | |
| 264 | |
| 265 sub authors{ | |
| 266 my ($self,$value) = @_; | |
| 267 if( defined $value) { | |
| 268 $self->{'authors'} = $value; | |
| 269 } | |
| 270 return $self->{'authors'}; | |
| 271 | |
| 272 } | |
| 273 | |
| 274 =head2 location | |
| 275 | |
| 276 Title : location | |
| 277 Usage : $self->location($newval) | |
| 278 Function: Gives the location line. No attempt is made to parse the location line | |
| 279 Example : | |
| 280 Returns : value of location | |
| 281 Args : newvalue (optional) | |
| 282 | |
| 283 | |
| 284 =cut | |
| 285 | |
| 286 sub location{ | |
| 287 my ($self,$value) = @_; | |
| 288 if( defined $value) { | |
| 289 $self->{'location'} = $value; | |
| 290 } | |
| 291 return $self->{'location'}; | |
| 292 | |
| 293 } | |
| 294 | |
| 295 =head2 title | |
| 296 | |
| 297 Title : title | |
| 298 Usage : $self->title($newval) | |
| 299 Function: Gives the title line (if exists) | |
| 300 Example : | |
| 301 Returns : value of title | |
| 302 Args : newvalue (optional) | |
| 303 | |
| 304 | |
| 305 =cut | |
| 306 | |
| 307 sub title{ | |
| 308 my ($self,$value) = @_; | |
| 309 if( defined $value) { | |
| 310 $self->{'title'} = $value; | |
| 311 } | |
| 312 return $self->{'title'}; | |
| 313 | |
| 314 } | |
| 315 | |
| 316 =head2 medline | |
| 317 | |
| 318 Title : medline | |
| 319 Usage : $self->medline($newval) | |
| 320 Function: Gives the medline number | |
| 321 Example : | |
| 322 Returns : value of medline | |
| 323 Args : newvalue (optional) | |
| 324 | |
| 325 | |
| 326 =cut | |
| 327 | |
| 328 sub medline{ | |
| 329 my ($self,$value) = @_; | |
| 330 if( defined $value) { | |
| 331 $self->{'medline'} = $value; | |
| 332 } | |
| 333 return $self->{'medline'}; | |
| 334 } | |
| 335 | |
| 336 =head2 pubmed | |
| 337 | |
| 338 Title : pubmed | |
| 339 Usage : $refobj->pubmed($newval) | |
| 340 Function: Get/Set the PubMed number, if it is different from the MedLine | |
| 341 number. | |
| 342 Example : | |
| 343 Returns : value of medline | |
| 344 Args : newvalue (optional) | |
| 345 | |
| 346 | |
| 347 =cut | |
| 348 | |
| 349 sub pubmed { | |
| 350 my ($self,$value) = @_; | |
| 351 if( defined $value) { | |
| 352 $self->{'pubmed'} = $value; | |
| 353 } | |
| 354 return $self->{'pubmed'}; | |
| 355 } | |
| 356 | |
| 357 =head2 database | |
| 358 | |
| 359 Title : database | |
| 360 Usage : | |
| 361 Function: Overrides DBLink database to be hard coded to 'MEDLINE', unless | |
| 362 the database has been set explicitely before. | |
| 363 Example : | |
| 364 Returns : | |
| 365 Args : | |
| 366 | |
| 367 | |
| 368 =cut | |
| 369 | |
| 370 sub database{ | |
| 371 my ($self, @args) = @_; | |
| 372 | |
| 373 return $self->SUPER::database(@args) || 'MEDLINE'; | |
| 374 } | |
| 375 | |
| 376 =head2 primary_id | |
| 377 | |
| 378 Title : primary_id | |
| 379 Usage : | |
| 380 Function: Overrides DBLink primary_id to provide medline number | |
| 381 Example : | |
| 382 Returns : | |
| 383 Args : | |
| 384 | |
| 385 | |
| 386 =cut | |
| 387 | |
| 388 sub primary_id{ | |
| 389 my ($self, @args) = @_; | |
| 390 | |
| 391 return $self->medline(@args); | |
| 392 } | |
| 393 | |
| 394 =head2 optional_id | |
| 395 | |
| 396 Title : optional_id | |
| 397 Usage : | |
| 398 Function: Overrides DBLink optional_id to provide the PubMed number. | |
| 399 Example : | |
| 400 Returns : | |
| 401 Args : | |
| 402 | |
| 403 | |
| 404 =cut | |
| 405 | |
| 406 sub optional_id{ | |
| 407 my ($self, @args) = @_; | |
| 408 | |
| 409 return $self->pubmed(@args); | |
| 410 } | |
| 411 | |
| 412 =head2 publisher | |
| 413 | |
| 414 Title : publisher | |
| 415 Usage : $self->publisher($newval) | |
| 416 Function: Gives the publisher line. No attempt is made to parse the publisher line | |
| 417 Example : | |
| 418 Returns : value of publisher | |
| 419 Args : newvalue (optional) | |
| 420 | |
| 421 | |
| 422 =cut | |
| 423 | |
| 424 sub publisher { | |
| 425 my ($self,$value) = @_; | |
| 426 if( defined $value) { | |
| 427 $self->{'publisher'} = $value; | |
| 428 } | |
| 429 return $self->{'publisher'}; | |
| 430 } | |
| 431 | |
| 432 | |
| 433 =head2 editors | |
| 434 | |
| 435 Title : editors | |
| 436 Usage : $self->editors($newval) | |
| 437 Function: Gives the editors line. No attempt is made to parse the editors line | |
| 438 Example : | |
| 439 Returns : value of editors | |
| 440 Args : newvalue (optional) | |
| 441 | |
| 442 | |
| 443 =cut | |
| 444 | |
| 445 sub editors { | |
| 446 my ($self,$value) = @_; | |
| 447 if( defined $value) { | |
| 448 $self->{'editors'} = $value; | |
| 449 } | |
| 450 return $self->{'editors'}; | |
| 451 } | |
| 452 | |
| 453 | |
| 454 =head2 encoded_ref | |
| 455 | |
| 456 Title : encoded_ref | |
| 457 Usage : $self->encoded_ref($newval) | |
| 458 Function: Gives the encoded_ref line. No attempt is made to parse the encoded_ref line | |
| 459 (this is added for reading PDB records (REFN record), where this contains | |
| 460 ISBN/ISSN/ASTM code) | |
| 461 Example : | |
| 462 Returns : value of encoded_ref | |
| 463 Args : newvalue (optional) | |
| 464 | |
| 465 | |
| 466 =cut | |
| 467 | |
| 468 sub encoded_ref { | |
| 469 my ($self,$value) = @_; | |
| 470 if( defined $value) { | |
| 471 $self->{'encoded_ref'} = $value; | |
| 472 } | |
| 473 return $self->{'encoded_ref'}; | |
| 474 } | |
| 475 | |
| 476 | |
| 477 1; |
