DBEntry.pm 9.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
#
# EnsEMBL module for DBEntry
#
# Cared for by Arne Stabenau <stabenau@ebi.ac.uk>
#
# Copyright EMBL/EBI 2001
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=pod 

Graham McVicker's avatar
PODs    
Graham McVicker committed
14
=head1 NAME 
15

Graham McVicker's avatar
PODs    
Graham McVicker committed
16
Bio::EnsEMBL::DBEntry - Module to collect information about an external reference
17
18
19
20
21

=head1 SYNOPSIS

=head1 DESCRIPTION

Graham McVicker's avatar
PODs    
Graham McVicker committed
22
23
This module stores information about external references to EnsEMBL objects

24
25
=head1 CONTACT

Graham McVicker's avatar
PODs    
Graham McVicker committed
26
Post questions to the EnsEMBL developer mailing list: <ensembl-dev@ebi.ac.uk> 
27

Graham McVicker's avatar
Graham McVicker committed
28
=head1 METHODS
29
30
31
32
33
34

=cut



package Bio::EnsEMBL::DBEntry;
David Barnwell's avatar
David Barnwell committed
35

36
use Bio::EnsEMBL::Storable;
David Barnwell's avatar
David Barnwell committed
37
use Bio::Annotation::DBLink;
38
39
40
41

use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(deprecate);

42
43
44
45
use vars qw(@ISA $AUTOLOAD);
use strict;


46
@ISA = qw( Bio::EnsEMBL::Storable Bio::Annotation::DBLink );
47
48


49

Graham McVicker's avatar
PODs    
Graham McVicker committed
50
51
52
53
54
55
56
57
58
59
=head2 new_fast

  Arg [1]    : hash reference $hashref
  Example    : none
  Description: A very quick constructor that requires internal knowledge of
               the class. This is used in speed critical sections of the code
               where many objects need to be created quickly.
  Returntype : Bio::EnsEMBL::DBEntry
  Exceptions : none
  Caller     : ?
60
  Status     : Stable
Graham McVicker's avatar
PODs    
Graham McVicker committed
61
62
63

=cut

Graham McVicker's avatar
Graham McVicker committed
64
65
66
sub new_fast {
  my $class = shift;
  my $hashref = shift;
Brian Gibbins's avatar
Brian Gibbins committed
67
  bless $hashref, $class;
68
  $hashref->{synonyms} = [];
Brian Gibbins's avatar
Brian Gibbins committed
69
  
70
  return $hashref;
Graham McVicker's avatar
Graham McVicker committed
71
72
}

Graham McVicker's avatar
PODs    
Graham McVicker committed
73
74
75
76
77
78
79
80
81
82


=head2 new

  Args [...] : list of named parameters 
  Example    : my $dbentry = new Bio::EnsEMBL::DBEntry(-adaptor => $adaptor,
						       -primary_id => $pid,
						       -version => $version,
						       -dbname  => $dbname,
						       -release => $release,
83
						       -display_id => $did,
84
85
86
                                                       -description => $description,
						       -primary_id_linkable =>$primary_id_linkable,
						       -display_id_linkable =>$display_id_linkable,
Glenn Proctor's avatar
Glenn Proctor committed
87
88
						       -priority => $priority,
						       -db_display_name => $db_display_name );
Graham McVicker's avatar
PODs    
Graham McVicker committed
89
90
91
92
  Description: Creates a new DBEntry object
  Returntype : Bio::EnsEMBL::DBEntry
  Exceptions : none
  Caller     : Bio::EnsEMBL::DBEntryAdaptor
93
94
95
96
  Status     : At Risk
             : due to 'PRIMARY_ID_LINKABLE','DISPLAY_ID_LINKABLE','PRIORITY'
             : being under development
             : If you don't use any of these the sub can be considered Stable
Graham McVicker's avatar
PODs    
Graham McVicker committed
97
98
99

=cut

100
101
102
103
104
sub new {
  my ($class, @args) = @_;

  my $self = bless {},$class;

Arne Stabenau's avatar
Arne Stabenau committed
105
  my ( $adaptor, $dbID, $primary_id, $version,
106
       $dbname, $release, $display_id, $description,
Glenn Proctor's avatar
Glenn Proctor committed
107
       $primary_id_linkable, $display_id_linkable, $priority, $db_display_name) =
108
    rearrange ( ['ADAPTOR','DBID','PRIMARY_ID','VERSION',
109
                 'DBNAME','RELEASE','DISPLAY_ID','DESCRIPTION',
Glenn Proctor's avatar
Glenn Proctor committed
110
111
		 'PRIMARY_ID_LINKABLE','DISPLAY_ID_LINKABLE','PRIORITY',
		 'DB_DISPLAY_NAME'], @args );
112
113
114
115

  $self->{'adaptor'} = $adaptor;
  $self->{'dbID'}    = $dbID;

116
  if( defined $primary_id ) { $self->primary_id( $primary_id ) }
Arne Stabenau's avatar
Arne Stabenau committed
117
118
  if( defined $version ) { $self->version( $version ) } else
    { $self->version( "" ); }
119
120
  if( defined $dbname ) { $self->dbname( $dbname ) }
  if( defined $release) { $self->release( $release ) }
121
  if( defined $display_id) { $self->display_id( $display_id ) }
122
  if( defined $description) { $self->description($description) }
123
124
125
  if( defined $primary_id_linkable) { $self->primary_id_linkable($primary_id_linkable) }
  if( defined $display_id_linkable) { $self->display_id_linkable($display_id_linkable) }
  if( defined $priority) { $self->priority($priority) }
Glenn Proctor's avatar
Glenn Proctor committed
126
  if( defined $db_display_name) { $self->db_display_name($db_display_name) }
127
  $self->{synonyms} = [];;
128
129
130
131
132

  return $self;
}


Graham McVicker's avatar
PODs    
Graham McVicker committed
133

Arne Stabenau's avatar
Arne Stabenau committed
134
135
136
137
138
139
140
141
142
=head2 primary_id

  Arg [1]    : string $primary_id
  Example    : none
  Description: get/set for attribute primary_id
               its this objects primary id in the external database
  Returntype : string
  Exceptions : none
  Caller     : general
143
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
144
145
146

=cut

147
148
149
sub primary_id {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
150
    $self->{primary_id} = $arg;
151
  } 
152

153
  return $self->{primary_id};
154
155
}

156

Graham McVicker's avatar
PODs    
Graham McVicker committed
157

Arne Stabenau's avatar
Arne Stabenau committed
158
=head2 display_id
159

Arne Stabenau's avatar
Arne Stabenau committed
160
161
162
163
164
165
166
167
  Arg [1]    : string $display_id
  Example    : none
  Description: get/set for attribute display_id
               This objects preferred display string. That can be the same
               as primary id or ensembl specific.
  Returntype : string
  Exceptions : none
  Caller     : general
168
  Status     : Stable
169
170
171
172
173
174

=cut

sub display_id{
   my ( $self, $arg ) = @_;
   if( defined $arg ) {
175
       $self->{display_id} = $arg;
176
   } 
177
   return $self->{display_id};
178
179
180
181

}


Graham McVicker's avatar
PODs    
Graham McVicker committed
182

Arne Stabenau's avatar
Arne Stabenau committed
183
184
185
186
187
188
189
190
=head2 dbname

  Arg [1]    : string $dbname
  Example    : none
  Description: get/set for attribute dbname
  Returntype : string
  Exceptions : none
  Caller     : general
191
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
192
193
194

=cut

195
196
197
sub dbname {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
198
    $self->{dbname} = $arg;
199
  } 
200
  return $self->{dbname};
201
202
203
}


Graham McVicker's avatar
PODs    
Graham McVicker committed
204

Arne Stabenau's avatar
Arne Stabenau committed
205
206
207
208
209
210
211
212
213
=head2 database

  Args       : none
  Example    : none
  Description: additional get for the dbname to make it compliant to
               some interface
  Returntype : string
  Exceptions : none
  Caller     : general
214
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
215
216
217

=cut

218
219
220
221
222
sub database {
  my $self = shift;
  return $self->dbname();
}

Arne Stabenau's avatar
Arne Stabenau committed
223

Graham McVicker's avatar
PODs    
Graham McVicker committed
224

Arne Stabenau's avatar
Arne Stabenau committed
225
226
227
228
229
230
231
232
233
=head2 optional_id

  Args       : none
  Example    : none
  Description: additional get for the display_id to make it compliant to
               some interface
  Returntype : string
  Exceptions : none
  Caller     : general
234
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
235
236
237

=cut

238
239
sub optional_id {
  my $self = shift;
240
  return $self->display_id;
241
242
243
}


Graham McVicker's avatar
PODs    
Graham McVicker committed
244

Arne Stabenau's avatar
Arne Stabenau committed
245
246
247
248
249
250
251
252
=head2 release

  Arg [1]    : string $release
  Example    : none
  Description: get/set for attribute release
  Returntype : string
  Exceptions : none
  Caller     : general
253
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
254
255
256

=cut

257
258
259
sub release {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
260
    $self->{release} = $arg;
261
  } 
262
  return $self->{release};
263
264
265
}


Arne Stabenau's avatar
Arne Stabenau committed
266
267
268
269
270
271
272
273
=head2 version

  Arg [1]    : string $version
  Example    : none
  Description: get/set for attribute version
  Returntype : string
  Exceptions : none
  Caller     : general
274
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
275
276
277

=cut

278
279
280
sub version {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
281
    $self->{version} = $arg;
282
  } 
283
  return $self->{version};
284
285
286
287
}



Arne Stabenau's avatar
Arne Stabenau committed
288
289
290
291
292
293
294
295
296

=head2 description

  Arg [1]    : string $description
  Example    : none
  Description: get/set for attribute description
  Returntype : string
  Exceptions : none
  Caller     : general
297
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
298
299
300

=cut

301
302
303
sub description {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
304
    $self->{description} = $arg;
305
  } 
306
  return $self->{description};
307
308
309
}


310
311
312
313
314
315
316
317
=head2 primary_id_linkable

  Arg [1]    : boolean $primary_id_linkable
  Example    : none
  Description: get/set for attribute primary_id_linkable
  Returntype : string
  Exceptions : none
  Caller     : general
318
319
  Status     : At Risk
             : due to it being under development
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

=cut

sub primary_id_linkable {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{primary_id_linkable} = $arg;
  } 
  return $self->{primary_id_linkable};
}

=head2 display_id_linkable

  Arg [1]    : boolean $display_id_linkable
  Example    : none
  Display_id_linkable: get/set for attribute display_id_linkable
  Returntype : string
  Exceptions : none
  Caller     : general
339
340
  Status     : At Risk
             : due to it being under development
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356

=cut

sub display_id_linkable {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{display_id_linkable} = $arg;
  } 
  return $self->{display_id_linkable};
}


=head2 priority

  Arg [1]    : int $priority
  Example    : none
357
  Priority   : get/set for attribute priority
358
359
360
  Returntype : string
  Exceptions : none
  Caller     : general
361
362
  Status     : At Risk
             : due to it being under development
363
364
365
366
367
368
369
370
371
372
373

=cut

sub priority {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{priority} = $arg;
  } 
  return $self->{priority};
}

Glenn Proctor's avatar
Glenn Proctor committed
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393

=head2 db_display_name

  Arg [1]    : String $db_display_name
  Example    : none
  Db_display_name: get/set for attribute db_display_name
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

sub db_display_name {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{db_display_name} = $arg;
  } 
  return $self->{db_display_name};
}

Arne Stabenau's avatar
Arne Stabenau committed
394
395
396
397
398
399
400
401
402
=head2 add_synonym

  Arg  1     : string $synonym
  Example    : none
  Description: adding a synonynm for the external object under which it is 
               also known
  Returntype : none
  Exceptions : none
  Caller     : general
403
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
404
405
406
407

=cut


408
409
410
sub add_synonym {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
411
    push( @{$self->{synonyms}}, $arg );
412
413
414
  }
}

Arne Stabenau's avatar
Arne Stabenau committed
415

Graham McVicker's avatar
Graham McVicker committed
416
=head2 get_all_synonyms
Arne Stabenau's avatar
Arne Stabenau committed
417
418

  Args       : none
Graham McVicker's avatar
Graham McVicker committed
419
  Example    : @synonyms = @{$db_entry->get_all_synonyms()};
Arne Stabenau's avatar
Arne Stabenau committed
420
  Description: get a list of synonym added to this object
Graham McVicker's avatar
Graham McVicker committed
421
  Returntype : list reference of strings 
Arne Stabenau's avatar
Arne Stabenau committed
422
423
  Exceptions : none
  Caller     : general
424
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
425
426
427

=cut

Graham McVicker's avatar
Graham McVicker committed
428
sub get_all_synonyms {
429
  my $self = shift;
430
  return $self->{synonyms};
431
432
}

Arne Stabenau's avatar
Arne Stabenau committed
433
434
435
436
437
438
439
440
441

=head2 flush_synonyms

  Args       : none
  Example    : none
  Description: remove all synonyms from this object
  Returntype : none
  Exceptions : none
  Caller     : general
442
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
443
444
445

=cut

446
447
sub flush_synonyms {
  my $self = shift;
448
  $self->{synonyms} = [];
449
450
}

Arne Stabenau's avatar
Arne Stabenau committed
451

452
453
=head2 status

Arne Stabenau's avatar
Arne Stabenau committed
454
455
456
457
458
459
  Arg [1]    : string $status
  Example    : none
  Description: get/set for attribute status
  Returntype : string
  Exceptions : none
  Caller     : general
460
  Status     : Stable
461
462
463

=cut

Arne Stabenau's avatar
Arne Stabenau committed
464

465
466
467
sub status{
 my ( $self, $arg ) = @_;
   if( defined $arg ) {
468
       $self->{status} = $arg;
469
   } 
470
   return $self->{status};
471
472
473
}


Arne Stabenau's avatar
Arne Stabenau committed
474
475
476
477
478
479
480
481
482

=head2 comment

  Args       : none
  Example    : none
  Description: additional get for description to comply with bioperl
  Returntype : string
  Exceptions : none
  Caller     : general
483
  Status     : Stable
Arne Stabenau's avatar
Arne Stabenau committed
484
485
486

=cut

487
488
489
490
491
492
493
494
#Cheat to comply with bioperl
sub comment {
    my ($self) = @_;
    if ($self) {
	return $self->description();
    }
}

Graham McVicker's avatar
Graham McVicker committed
495

Graham McVicker's avatar
Graham McVicker committed
496
497
498
=head1 DEPRECATED METHODS

=cut
Graham McVicker's avatar
Graham McVicker committed
499
500
501
502
503
504
505
506
507
508

=head2 get_synonyms

  Description: DEPRECATED use get_all_synonyms instead

=cut

sub get_synonyms {
  my $self = shift;

509
  deprecate("get_synonyms has been renamed get_all_synonyms.");
Graham McVicker's avatar
Graham McVicker committed
510
511
512
  return $self->get_all_synonyms;
}

513
1;