DBEntry.pm 9.22 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


Graham McVicker's avatar
PODs  
Graham McVicker committed
49
50
51
52
53
54
55
56
57
58
59
60
61
=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     : ?

=cut

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

Graham McVicker's avatar
PODs  
Graham McVicker committed
71
72
73
74
75
76
77
78
79
80


=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,
81
						       -display_id => $did,
82
83
84
                                                       -description => $description,
						       -primary_id_linkable =>$primary_id_linkable,
						       -display_id_linkable =>$display_id_linkable,
Glenn Proctor's avatar
Glenn Proctor committed
85
86
						       -priority => $priority,
						       -db_display_name => $db_display_name );
Graham McVicker's avatar
PODs  
Graham McVicker committed
87
88
89
90
91
92
93
  Description: Creates a new DBEntry object
  Returntype : Bio::EnsEMBL::DBEntry
  Exceptions : none
  Caller     : Bio::EnsEMBL::DBEntryAdaptor

=cut

94
95
96
97
98
sub new {
  my ($class, @args) = @_;

  my $self = bless {},$class;

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

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

110
  if( defined $primary_id ) { $self->primary_id( $primary_id ) }
Arne Stabenau's avatar
Arne Stabenau committed
111
112
  if( defined $version ) { $self->version( $version ) } else
    { $self->version( "" ); }
113
114
  if( defined $dbname ) { $self->dbname( $dbname ) }
  if( defined $release) { $self->release( $release ) }
115
  if( defined $display_id) { $self->display_id( $display_id ) }
116
  if( defined $description) { $self->description($description) }
117
118
119
  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
120
  if( defined $db_display_name) { $self->db_display_name($db_display_name) }
121
  $self->{synonyms} = [];;
122
123
124
125
126

  return $self;
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
127

Arne Stabenau's avatar
Arne Stabenau committed
128
129
130
131
132
133
134
135
136
137
138
139
=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

=cut

140
141
142
sub primary_id {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
143
    $self->{primary_id} = $arg;
144
  } 
145
  return $self->{primary_id};
146
147
}

148

Graham McVicker's avatar
PODs  
Graham McVicker committed
149

Arne Stabenau's avatar
Arne Stabenau committed
150
=head2 display_id
151

Arne Stabenau's avatar
Arne Stabenau committed
152
153
154
155
156
157
158
159
  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
160
161
162
163
164
165

=cut

sub display_id{
   my ( $self, $arg ) = @_;
   if( defined $arg ) {
166
       $self->{display_id} = $arg;
167
   } 
168
   return $self->{display_id};
169
170
171
172

}


Graham McVicker's avatar
PODs  
Graham McVicker committed
173

Arne Stabenau's avatar
Arne Stabenau committed
174
175
176
177
178
179
180
181
182
183
184
=head2 dbname

  Arg [1]    : string $dbname
  Example    : none
  Description: get/set for attribute dbname
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

185
186
187
sub dbname {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
188
    $self->{dbname} = $arg;
189
  } 
190
  return $self->{dbname};
191
192
193
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
194

Arne Stabenau's avatar
Arne Stabenau committed
195
196
197
198
199
200
201
202
203
204
205
206
=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

=cut

207
208
209
210
211
sub database {
  my $self = shift;
  return $self->dbname();
}

Arne Stabenau's avatar
Arne Stabenau committed
212

Graham McVicker's avatar
PODs  
Graham McVicker committed
213

Arne Stabenau's avatar
Arne Stabenau committed
214
215
216
217
218
219
220
221
222
223
224
225
=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

=cut

226
227
sub optional_id {
  my $self = shift;
228
  return $self->display_id;
229
230
231
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
232

Arne Stabenau's avatar
Arne Stabenau committed
233
234
235
236
237
238
239
240
241
242
243
=head2 release

  Arg [1]    : string $release
  Example    : none
  Description: get/set for attribute release
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

244
245
246
sub release {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
247
    $self->{release} = $arg;
248
  } 
249
  return $self->{release};
250
251
252
}


Arne Stabenau's avatar
Arne Stabenau committed
253
254
255
256
257
258
259
260
261
262
263
=head2 version

  Arg [1]    : string $version
  Example    : none
  Description: get/set for attribute version
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

264
265
266
sub version {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
267
    $self->{version} = $arg;
268
  } 
269
  return $self->{version};
270
271
272
273
}



Arne Stabenau's avatar
Arne Stabenau committed
274
275
276
277
278
279
280
281
282
283
284
285

=head2 description

  Arg [1]    : string $description
  Example    : none
  Description: get/set for attribute description
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

286
287
288
sub description {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
289
    $self->{description} = $arg;
290
  } 
291
  return $self->{description};
292
293
294
}


295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
=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

=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

=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
  Priority: get/set for attribute priority
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

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

Glenn Proctor's avatar
Glenn Proctor committed
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372

=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
373
374
375
376
377
378
379
380
381
382
383
384
385
=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

=cut


386
387
388
sub add_synonym {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
389
    push( @{$self->{synonyms}}, $arg );
390
391
392
  }
}

Arne Stabenau's avatar
Arne Stabenau committed
393

Graham McVicker's avatar
Graham McVicker committed
394
=head2 get_all_synonyms
Arne Stabenau's avatar
Arne Stabenau committed
395
396

  Args       : none
Graham McVicker's avatar
Graham McVicker committed
397
  Example    : @synonyms = @{$db_entry->get_all_synonyms()};
Arne Stabenau's avatar
Arne Stabenau committed
398
  Description: get a list of synonym added to this object
Graham McVicker's avatar
Graham McVicker committed
399
  Returntype : list reference of strings 
Arne Stabenau's avatar
Arne Stabenau committed
400
401
402
403
404
  Exceptions : none
  Caller     : general

=cut

Graham McVicker's avatar
Graham McVicker committed
405
sub get_all_synonyms {
406
  my $self = shift;
407
  return $self->{synonyms};
408
409
}

Arne Stabenau's avatar
Arne Stabenau committed
410
411
412
413
414
415
416
417
418
419
420
421

=head2 flush_synonyms

  Args       : none
  Example    : none
  Description: remove all synonyms from this object
  Returntype : none
  Exceptions : none
  Caller     : general

=cut

422
423
sub flush_synonyms {
  my $self = shift;
424
  $self->{synonyms} = [];
425
426
}

Arne Stabenau's avatar
Arne Stabenau committed
427

428
429
=head2 status

Arne Stabenau's avatar
Arne Stabenau committed
430
431
432
433
434
435
  Arg [1]    : string $status
  Example    : none
  Description: get/set for attribute status
  Returntype : string
  Exceptions : none
  Caller     : general
436
437
438

=cut

Arne Stabenau's avatar
Arne Stabenau committed
439

440
441
442
sub status{
 my ( $self, $arg ) = @_;
   if( defined $arg ) {
443
       $self->{status} = $arg;
444
   } 
445
   return $self->{status};
446
447
448
}


Arne Stabenau's avatar
Arne Stabenau committed
449
450
451
452
453
454
455
456
457
458
459
460

=head2 comment

  Args       : none
  Example    : none
  Description: additional get for description to comply with bioperl
  Returntype : string
  Exceptions : none
  Caller     : general

=cut

461
462
463
464
465
466
467
468
#Cheat to comply with bioperl
sub comment {
    my ($self) = @_;
    if ($self) {
	return $self->description();
    }
}

Graham McVicker's avatar
Graham McVicker committed
469

Graham McVicker's avatar
Graham McVicker committed
470
471
472
=head1 DEPRECATED METHODS

=cut
Graham McVicker's avatar
Graham McVicker committed
473
474
475
476
477
478
479
480
481
482

=head2 get_synonyms

  Description: DEPRECATED use get_all_synonyms instead

=cut

sub get_synonyms {
  my $self = shift;

483
  deprecate("get_synonyms has been renamed get_all_synonyms.");
Graham McVicker's avatar
Graham McVicker committed
484
485
486
  return $self->get_all_synonyms;
}

487
1;