DBEntry.pm 8.32 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
28
29

=head1 APPENDIX

Graham McVicker's avatar
PODs  
Graham McVicker committed
30
31
The rest of the documentation details each of the object methods. Internal 
methods are usually preceded with a _
32
33
34
35
36
37
38
39

=cut


# Let the code begin...


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

use Bio::Annotation::DBLink;
42
43
44
45
use vars qw(@ISA $AUTOLOAD);
use strict;


46
@ISA = qw( Bio::EnsEMBL::Root 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
82
						       -display_id => $did,
                               -description => $description);
Graham McVicker's avatar
PODs  
Graham McVicker committed
83
84
85
86
87
88
89
  Description: Creates a new DBEntry object
  Returntype : Bio::EnsEMBL::DBEntry
  Exceptions : none
  Caller     : Bio::EnsEMBL::DBEntryAdaptor

=cut

90
91
92
93
94
sub new {
  my ($class, @args) = @_;

  my $self = bless {},$class;

Arne Stabenau's avatar
Arne Stabenau committed
95
  my ( $adaptor, $dbID, $primary_id, $version,
96
       $dbname, $release, $display_id, $description ) = $self->_rearrange
Arne Stabenau's avatar
Arne Stabenau committed
97
	 ( [ qw { ADAPTOR
98
99
100
101
102
		DBID
		PRIMARY_ID
		VERSION
		DBNAME
		RELEASE
103
		DISPLAY_ID
104
        DESCRIPTION
Arne Stabenau's avatar
Arne Stabenau committed
105
	      }], @args );
106
107
108
109

  if( defined $adaptor ) { $self->adaptor( $adaptor )}
  if( defined $dbID ) { $self->dbID( $dbID ) }
  if( defined $primary_id ) { $self->primary_id( $primary_id ) }
Arne Stabenau's avatar
Arne Stabenau committed
110
111
  if( defined $version ) { $self->version( $version ) } else
    { $self->version( "" ); }
112
113
  if( defined $dbname ) { $self->dbname( $dbname ) }
  if( defined $release) { $self->release( $release ) }
114
  if( defined $display_id) { $self->display_id( $display_id ) }
115
  if( defined $description) { $self->description($description) }
Arne Stabenau's avatar
Arne Stabenau committed
116
  $self->{_synonyms} = [];;
117
118
119
120
121

  return $self;
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
122

Arne Stabenau's avatar
Arne Stabenau committed
123
124
125
126
127
128
129
130
131
132
133
134
=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

135
136
137
138
139
140
141
142
sub primary_id {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_primary_id} = $arg;
  } 
  return $self->{_primary_id};
}

143

Graham McVicker's avatar
PODs  
Graham McVicker committed
144

Arne Stabenau's avatar
Arne Stabenau committed
145
=head2 display_id
146

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

=cut

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

}


Graham McVicker's avatar
PODs  
Graham McVicker committed
168

Arne Stabenau's avatar
Arne Stabenau committed
169
170
171
172
173
174
175
176
177
178
179
=head2 dbname

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

=cut

180
181
182
183
184
185
186
187
188
sub dbname {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_dbname} = $arg;
  } 
  return $self->{_dbname};
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
189

Arne Stabenau's avatar
Arne Stabenau committed
190
191
192
193
194
195
196
197
198
199
200
201
=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

202
203
204
205
206
sub database {
  my $self = shift;
  return $self->dbname();
}

Arne Stabenau's avatar
Arne Stabenau committed
207

Graham McVicker's avatar
PODs  
Graham McVicker committed
208

Arne Stabenau's avatar
Arne Stabenau committed
209
210
211
212
213
214
215
216
217
218
219
220
=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

221
222
sub optional_id {
  my $self = shift;
223
  return $self->display_id;
224
225
226
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
227

Arne Stabenau's avatar
Arne Stabenau committed
228
229
230
231
232
233
234
235
236
237
238
=head2 release

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

=cut

239
240
241
242
243
244
245
246
247
sub release {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_release} = $arg;
  } 
  return $self->{_release};
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
248
249
250
251
252
253
254
255
256
257
258
259
260
261

=head2 adaptor

  Arg [1]    : (optional) Bio::EnsEMBL::DBSQL::DBEntryAdaptor $arg
  Example    : $adaptor = $dbentry->adaptor;
  Description: Getter/Setter for the adaptor used by this object for database 
               interaction. This attribute is set by the adaptor when this
               object is stored in the database or retrieved from the database.
  Returntype : Bio::EnsEMBL::DBSQL::DBEntryAdaptor
  Exceptions : none
  Caller     : general

=cut

262
263
264
265
266
267
268
269
270
sub adaptor {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_adaptor} = $arg;
  } 
  return $self->{_adaptor};
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
271
272
273
274
275
276
277
278
279
280
281
282
283
284

=head2 dbID

  Arg [1]    : (optional) int 
  Example    : $dbID = $dbentry->dbID;
  Description: Getter/Setter for this objects unique database identifier. This
               attribute is set the adaptor when this object is store in the
               database or retrieved from the database.
  Returntype : int
  Exceptions : none
  Caller     : general

=cut

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


Arne Stabenau's avatar
Arne Stabenau committed
294
295
296
297
298
299
300
301
302
303
304
305

=head2 version

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

=cut

306
307
308
309
310
311
312
313
314
315
sub version {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_version} = $arg;
  } 
  return $self->{_version};
}



Arne Stabenau's avatar
Arne Stabenau committed
316
317
318
319
320
321
322
323
324
325
326
327

=head2 description

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

=cut

328
329
330
331
332
333
334
335
336
sub description {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    $self->{_description} = $arg;
  } 
  return $self->{_description};
}


Arne Stabenau's avatar
Arne Stabenau committed
337
338
339
340
341
342
343
344
345
346
347
348
349
=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


350
351
352
353
354
355
356
sub add_synonym {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
    push( @{$self->{_synonyms}}, $arg );
  }
}

Arne Stabenau's avatar
Arne Stabenau committed
357

Graham McVicker's avatar
Graham McVicker committed
358
=head2 get_all_synonyms
Arne Stabenau's avatar
Arne Stabenau committed
359
360

  Args       : none
Graham McVicker's avatar
Graham McVicker committed
361
  Example    : @synonyms = @{$db_entry->get_all_synonyms()};
Arne Stabenau's avatar
Arne Stabenau committed
362
  Description: get a list of synonym added to this object
Graham McVicker's avatar
Graham McVicker committed
363
  Returntype : list reference of strings 
Arne Stabenau's avatar
Arne Stabenau committed
364
365
366
367
368
  Exceptions : none
  Caller     : general

=cut

Graham McVicker's avatar
Graham McVicker committed
369
sub get_all_synonyms {
370
  my $self = shift;
Graham McVicker's avatar
Graham McVicker committed
371
  return $self->{_synonyms};
372
373
}

Arne Stabenau's avatar
Arne Stabenau committed
374
375
376
377
378
379
380
381
382
383
384
385

=head2 flush_synonyms

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

=cut

386
387
388
389
390
sub flush_synonyms {
  my $self = shift;
  $self->{_synonyms} = [];
}

Arne Stabenau's avatar
Arne Stabenau committed
391

392
393
=head2 status

Arne Stabenau's avatar
Arne Stabenau committed
394
395
396
397
398
399
  Arg [1]    : string $status
  Example    : none
  Description: get/set for attribute status
  Returntype : string
  Exceptions : none
  Caller     : general
400
401
402

=cut

Arne Stabenau's avatar
Arne Stabenau committed
403

404
405
406
407
408
409
410
411
412
sub status{
 my ( $self, $arg ) = @_;
   if( defined $arg ) {
       $self->{_status} = $arg;
   } 
   return $self->{_status};
}


Arne Stabenau's avatar
Arne Stabenau committed
413
414
415
416
417
418
419
420
421
422
423
424

=head2 comment

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

=cut

425
426
427
428
429
430
431
432
#Cheat to comply with bioperl
sub comment {
    my ($self) = @_;
    if ($self) {
	return $self->description();
    }
}

Graham McVicker's avatar
Graham McVicker committed
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452


=head2 get_synonyms

  Arg [1]    : none
  Example    : none
  Description: DEPRECATED use get_all_synonyms instead
  Returntype : none
  Exceptions : none
  Caller     : none

=cut

sub get_synonyms {
  my $self = shift;

  $self->warn("get_synonyms has been rename get_all_synonyms\n" . caller);
  return $self->get_all_synonyms;
}

453
1;