Attribute.pm 3.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Ensembl module for Bio::EnsEMBL::Attribute
#
# Copyright (c) 2004 Ensembl
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::EnsEMBL::Attribute - A generic Attribute class.

=head1 SYNOPSIS

  use Bio::EnsEMBL::Attribute;

  my $attribute = Bio::EnsEMBL::Attribute->new
       (-CODE => 'myCode',
        -NAME => 'My Attribute',
Graham McVicker's avatar
Graham McVicker committed
21
        -DESCRIPTION => 'This is my attribute description.',
22
23
24
25
        -VALUE => '10023');

  print $attrib->name(), "\n";
  print $attrib->code(), "\n";
26
  print $attrib->description(), "\n";
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  print $attrib->value(), "\n";

=head1 DESCRIPTION

This is a generic attribute class used to represent attributes
associated with seq_regions (and their Slices) and MiscFeatures.

Also see B<Bio::EnsEMBL::Slice>, B<Bio::EnsEMBL::MiscFeature> and
B<Bio::EnsEMBL::DBSQL::AttributeAdaptor>.

=head1 CONTACT

This modules is part of the Ensembl project http://www.ensembl.org

Questions can be posted to the ensembl-dev mailing list:
ensembl-dev@ebi.ac.uk

=head1 METHODS

=cut

use strict;
use warnings;

package Bio::EnsEMBL::Attribute;

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

=head2 new

  Arg [-CODE]   : string - the code for this attribute
  Arg [-NAME]   : string - a human readable name for this attribute
59
  Arg [-DESCRIPTION]   : string - a description for this attribute
60
61
62
63
  Arg [-VALUE]  : value  - the value of this attribute
  Example    :   my $attribute = Bio::EnsEMBL::Attribute->new
                      (-CODE => 'myCode',
                       -NAME => 'My Attribute',
64
                       -DESCRIPTION => 'This is my attribute description.',
65
66
67
68
69
                       -VALUE => '10023');
  Description: Constructor.  Instantiates a Bio::EnsEMBL::Attribute object.
  Returntype : Bio::EnsEMBL::Attribute
  Exceptions : none
  Caller     : general
70
  Status     : Stable
71
72
73
74
75
76
77
78
79
80
81

=cut


sub new {
  my $caller = shift;

  # allow to be called as class or object method
  my $class = ref($caller) || $caller;

  my ($code, $name, $desc, $value) =
82
    rearrange([qw(CODE NAME DESCRIPTION VALUE)], @_);
83
84
85

  return bless {'code'    => $code,
                'name'    => $name,
86
                'description'    => $desc,
87
88
89
90
91
92
93
94
95
96
97
98
                'value'   => $value}, $class;
}


=head2 code

  Arg [1]    : string $code (optional)x
  Example    : $code = $attribute->code();
  Description: Getter/Setter for code attribute
  Returntype : string
  Exceptions : none
  Caller     : general
99
  Status     : Stable
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

=cut

sub code {
  my $self = shift;
  $self->{'code'} = shift if(@_);
  return $self->{'code'};
}


=head2 name

  Arg [1]    : string $name (optional)
  Example    : $name = $attribute->name();
  Description: Getter/Setter for name attribute
  Returntype : string
  Exceptions : none
  Caller     : general
118
  Status     : Stable
119
120
121
122
123
124
125
126
127

=cut

sub name {
  my $self = shift;
  $self->{'name'} = shift if(@_);
  return $self->{'name'};
}

128
=head2 description
129

130
131
  Arg [1]    : string $description (optional)
  Example    : $description = $attribute->description();
132
133
134
135
  Description: Getter/Setter for description attribute
  Returntype : string
  Exceptions : none
  Caller     : general
136
  Status     : Stable
137
138
139

=cut

140
sub description {
141
  my $self = shift;
142
143
  $self->{'description'} = shift if(@_);
  return $self->{'description'};
144
145
146
147
148
149
150
151
152
153
154
}


=head2 value

  Arg [1]    : string $value (optional)
  Example    : $value = $attribute->value();
  Description: Getter/Setter for value attribute
  Returntype : string
  Exceptions : none
  Caller     : general
155
  Status     : Stable
156
157
158
159
160
161
162
163
164
165
166

=cut

sub value {
  my $self = shift;
  $self->{'value'} = shift if(@_);
  return $self->{'value'};
}


1;