comparison variant_effect_predictor/Bio/EnsEMBL/Attribute.pm @ 0:2bc9b66ada89 draft default tip

Uploaded
author mahtabm
date Thu, 11 Apr 2013 06:29:17 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2bc9b66ada89
1 =head1 LICENSE
2
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
4 Genome Research Limited. All rights reserved.
5
6 This software is distributed under a modified Apache license.
7 For license details, please see
8
9 http://www.ensembl.org/info/about/code_licence.html
10
11 =head1 CONTACT
12
13 Please email comments or questions to the public Ensembl
14 developers list at <dev@ensembl.org>.
15
16 Questions may also be sent to the Ensembl help desk at
17 <helpdesk@ensembl.org>.
18
19 =cut
20
21 =head1 NAME
22
23 Bio::EnsEMBL::Attribute - A generic Attribute class.
24
25 =head1 SYNOPSIS
26
27 use Bio::EnsEMBL::Attribute;
28
29 my $attribute = Bio::EnsEMBL::Attribute->new
30 (-CODE => 'myCode',
31 -NAME => 'My Attribute',
32 -DESCRIPTION => 'This is my attribute description.',
33 -VALUE => '10023');
34
35 print $attrib->name(), "\n";
36 print $attrib->code(), "\n";
37 print $attrib->description(), "\n";
38 print $attrib->value(), "\n";
39
40 =head1 DESCRIPTION
41
42 This is a generic attribute class used to represent attributes
43 associated with seq_regions (and their Slices) and MiscFeatures.
44
45 =head1 SEE ALSO
46
47 Bio::EnsEMBL::Slice
48 Bio::EnsEMBL::MiscFeature
49 Bio::EnsEMBL::DBSQL::AttributeAdaptor
50
51 =cut
52
53 package Bio::EnsEMBL::Attribute;
54
55 use strict;
56 use warnings;
57
58 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
59 use Scalar::Util qw(weaken isweak);
60
61 =head2 new
62
63 Arg [-CODE] : string - the code for this attribute
64 Arg [-NAME] : string - a human readable name for this attribute
65 Arg [-DESCRIPTION] : string - a description for this attribute
66 Arg [-VALUE] : value - the value of this attribute
67 Example : my $attribute = Bio::EnsEMBL::Attribute->new
68 (-CODE => 'myCode',
69 -NAME => 'My Attribute',
70 -DESCRIPTION => 'This is my attribute description.',
71 -VALUE => '10023');
72 Description : Constructor. Instantiates a Bio::EnsEMBL::Attribute object.
73 Returntype : Bio::EnsEMBL::Attribute
74 Exceptions : none
75 Caller : general
76 Status : Stable
77
78 =cut
79
80
81 sub new {
82 my $caller = shift;
83
84 # allow to be called as class or object method
85 my $class = ref($caller) || $caller;
86
87 my ($code, $name, $desc, $value) =
88 rearrange([qw(CODE NAME DESCRIPTION VALUE)], @_);
89
90 return bless {'code' => $code,
91 'name' => $name,
92 'description' => $desc,
93 'value' => $value}, $class;
94 }
95
96 =head2 new_fast
97
98 Arg [1] : hashref to be blessed
99 Description: Construct a new Bio::EnsEMBL::Attribute using the hashref.
100 Exceptions : none
101 Returntype : Bio::EnsEMBL::Attribute
102 Caller : general, subclass constructors
103 Status : Stable
104
105 =cut
106
107
108 sub new_fast {
109 my $class = shift;
110 my $hashref = shift;
111 my $self = bless $hashref, $class;
112 weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
113 return $self;
114 }
115
116
117 =head2 code
118
119 Arg [1] : string $code (optional)
120 Example : $code = $attribute->code();
121 Description: Getter/Setter for code attribute
122 Returntype : string
123 Exceptions : none
124 Caller : general
125 Status : Stable
126
127 =cut
128
129 sub code {
130 my $self = shift;
131 $self->{'code'} = shift if(@_);
132 return $self->{'code'};
133 }
134
135
136 =head2 name
137
138 Arg [1] : string $name (optional)
139 Example : $name = $attribute->name();
140 Description: Getter/Setter for name attribute
141 Returntype : string
142 Exceptions : none
143 Caller : general
144 Status : Stable
145
146 =cut
147
148 sub name {
149 my $self = shift;
150 $self->{'name'} = shift if(@_);
151 return $self->{'name'};
152 }
153
154 =head2 description
155
156 Arg [1] : string $description (optional)
157 Example : $description = $attribute->description();
158 Description: Getter/Setter for description attribute
159 Returntype : string
160 Exceptions : none
161 Caller : general
162 Status : Stable
163
164 =cut
165
166 sub description {
167 my $self = shift;
168 $self->{'description'} = shift if(@_);
169 return $self->{'description'};
170 }
171
172
173 =head2 value
174
175 Arg [1] : string $value (optional)
176 Example : $value = $attribute->value();
177 Description: Getter/Setter for value attribute
178 Returntype : string
179 Exceptions : none
180 Caller : general
181 Status : Stable
182
183 =cut
184
185 sub value {
186 my $self = shift;
187 $self->{'value'} = shift if(@_);
188 return $self->{'value'};
189 }
190
191
192 1;