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

=cut



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

39
use Bio::EnsEMBL::Storable;
David Barnwell's avatar
David Barnwell committed
40
use Bio::Annotation::DBLink;
41
42
43
44

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

45
46
47
48
use vars qw(@ISA $AUTOLOAD);
use strict;


49
@ISA = qw( Bio::EnsEMBL::Storable Bio::Annotation::DBLink );
50
51


Graham McVicker's avatar
PODs  
Graham McVicker committed
52
53
54
55
56
57
58
59
60
61
62
63
64
=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
65
66
67
sub new_fast {
  my $class = shift;
  my $hashref = shift;
Brian Gibbins's avatar
Brian Gibbins committed
68
  bless $hashref, $class;
69
  $hashref->{_synonyms} = [];
Brian Gibbins's avatar
Brian Gibbins committed
70
  
71
  return $hashref;
Graham McVicker's avatar
Graham McVicker committed
72
73
}

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


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

=cut

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

  my $self = bless {},$class;

Arne Stabenau's avatar
Arne Stabenau committed
98
  my ( $adaptor, $dbID, $primary_id, $version,
99
100
101
102
103
104
105
       $dbname, $release, $display_id, $description ) =
    rearrange ( ['ADAPTOR','DBID','PRIMARY_ID','VERSION',
                 'DBNAME','RELEASE','DISPLAY_ID','DESCRIPTION'], @args );

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

106
  if( defined $primary_id ) { $self->primary_id( $primary_id ) }
Arne Stabenau's avatar
Arne Stabenau committed
107
108
  if( defined $version ) { $self->version( $version ) } else
    { $self->version( "" ); }
109
110
  if( defined $dbname ) { $self->dbname( $dbname ) }
  if( defined $release) { $self->release( $release ) }
111
  if( defined $display_id) { $self->display_id( $display_id ) }
112
  if( defined $description) { $self->description($description) }
113
  $self->{synonyms} = [];;
114
115
116
117
118

  return $self;
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
119

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

132
133
134
sub primary_id {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
135
    $self->{primary_id} = $arg;
136
  } 
137
  return $self->{primary_id};
138
139
}

140

Graham McVicker's avatar
PODs  
Graham McVicker committed
141

Arne Stabenau's avatar
Arne Stabenau committed
142
=head2 display_id
143

Arne Stabenau's avatar
Arne Stabenau committed
144
145
146
147
148
149
150
151
  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
152
153
154
155
156
157

=cut

sub display_id{
   my ( $self, $arg ) = @_;
   if( defined $arg ) {
158
       $self->{display_id} = $arg;
159
   } 
160
   return $self->{display_id};
161
162
163
164

}


Graham McVicker's avatar
PODs  
Graham McVicker committed
165

Arne Stabenau's avatar
Arne Stabenau committed
166
167
168
169
170
171
172
173
174
175
176
=head2 dbname

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

=cut

177
178
179
sub dbname {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
180
    $self->{dbname} = $arg;
181
  } 
182
  return $self->{dbname};
183
184
185
}


Graham McVicker's avatar
PODs  
Graham McVicker committed
186

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

199
200
201
202
203
sub database {
  my $self = shift;
  return $self->dbname();
}

Arne Stabenau's avatar
Arne Stabenau committed
204

Graham McVicker's avatar
PODs  
Graham McVicker committed
205

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

218
219
sub optional_id {
  my $self = shift;
220
  return $self->display_id;
221
222
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
234
235
=head2 release

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

=cut

236
237
238
sub release {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
239
    $self->{release} = $arg;
240
  } 
241
  return $self->{release};
242
243
244
}


Arne Stabenau's avatar
Arne Stabenau committed
245
246
247
248
249
250
251
252
253
254
255
=head2 version

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

=cut

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



Arne Stabenau's avatar
Arne Stabenau committed
266
267
268
269
270
271
272
273
274
275
276
277

=head2 description

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

=cut

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


Arne Stabenau's avatar
Arne Stabenau committed
287
288
289
290
291
292
293
294
295
296
297
298
299
=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


300
301
302
sub add_synonym {
  my ( $self, $arg ) = @_;
  if( defined $arg ) {
303
    push( @{$self->{synonyms}}, $arg );
304
305
306
  }
}

Arne Stabenau's avatar
Arne Stabenau committed
307

Graham McVicker's avatar
Graham McVicker committed
308
=head2 get_all_synonyms
Arne Stabenau's avatar
Arne Stabenau committed
309
310

  Args       : none
Graham McVicker's avatar
Graham McVicker committed
311
  Example    : @synonyms = @{$db_entry->get_all_synonyms()};
Arne Stabenau's avatar
Arne Stabenau committed
312
  Description: get a list of synonym added to this object
Graham McVicker's avatar
Graham McVicker committed
313
  Returntype : list reference of strings 
Arne Stabenau's avatar
Arne Stabenau committed
314
315
316
317
318
  Exceptions : none
  Caller     : general

=cut

Graham McVicker's avatar
Graham McVicker committed
319
sub get_all_synonyms {
320
  my $self = shift;
321
  return $self->{synonyms};
322
323
}

Arne Stabenau's avatar
Arne Stabenau committed
324
325
326
327
328
329
330
331
332
333
334
335

=head2 flush_synonyms

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

=cut

336
337
sub flush_synonyms {
  my $self = shift;
338
  $self->{synonyms} = [];
339
340
}

Arne Stabenau's avatar
Arne Stabenau committed
341

342
343
=head2 status

Arne Stabenau's avatar
Arne Stabenau committed
344
345
346
347
348
349
  Arg [1]    : string $status
  Example    : none
  Description: get/set for attribute status
  Returntype : string
  Exceptions : none
  Caller     : general
350
351
352

=cut

Arne Stabenau's avatar
Arne Stabenau committed
353

354
355
356
sub status{
 my ( $self, $arg ) = @_;
   if( defined $arg ) {
357
       $self->{status} = $arg;
358
   } 
359
   return $self->{status};
360
361
362
}


Arne Stabenau's avatar
Arne Stabenau committed
363
364
365
366
367
368
369
370
371
372
373
374

=head2 comment

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

=cut

375
376
377
378
379
380
381
382
#Cheat to comply with bioperl
sub comment {
    my ($self) = @_;
    if ($self) {
	return $self->description();
    }
}

Graham McVicker's avatar
Graham McVicker committed
383
384
385
386
387
388
389
390
391
392
393


=head2 get_synonyms

  Description: DEPRECATED use get_all_synonyms instead

=cut

sub get_synonyms {
  my $self = shift;

394
  deprecate("get_synonyms has been renamed get_all_synonyms.");
Graham McVicker's avatar
Graham McVicker committed
395
396
397
  return $self->get_all_synonyms;
}

398
1;