ensembl-hive  2.7.0
TinyFeature.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 
18 =cut
19 
20 
21 =head1 CONTACT
22 
23  Please email comments or questions to the public Ensembl
24  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25 
26  Questions may also be sent to the Ensembl help desk at
27  <http://www.ensembl.org/Help/Contact>.
28 
29 =cut
30 
31 =head1 NAME
32 
33 Bio::EnsEMBL::IdMapping::TinyFeature - lightweight feature object
34 
35 =head1 SYNOPSIS
36 
37 This object isn't instantiated. See objects which inherit from it
38 (TinyGene, TinyTranscript, etc.) for examples.
39 
40 =head1 DESCRIPTION
41 
42 This is the base class for the lightweight feature objects used by the
43 stable Id maping application. For performance reasons, these objects
44 are instantiated using a new_fast() method. The internal implementation
45 is an arrayref (rather than the more common hashref), which optimises
46 memory usage.
47 
48 There are no adaptors to fetch TinyFeatures from the database. You
49 rather use the normal feature adaptors and then create the TinyFeatures
50 from the heavy objects you get. The memory saving will therefore mainly
51 take effect when serialising and reloading these objects.
52 
53 Also note that TinyFeatures don't have a slice attached to them - all
54 location information (where required) is stored on the feature object
55 directly.
56 
57 =head1 METHODS
58 
59  new_fast
60  id
61  stable_id
62  version
63  created_date
64  modified_date
65  to_string
66 
67 =cut
68 
69 package Bio::EnsEMBL::IdMapping::TinyFeature;
70 
71 # internal data structure (array indices):
72 #
73 # 0 dbID
74 # 1 stable_id
75 # 2 version
76 # 3 created_date
77 # 4 modified_date
78 #
79 # other instance variables differ by subclass implementation, so look there.
80 
81 
82 use strict;
83 use warnings;
84 no warnings 'uninitialized';
85 
86 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
87 
88 
89 =head2 new_fast
90 
91  Arg[1] : Arrayref $array_ref - the arrayref to bless into the new object
92  Description : Constructor.
93  Return type : Bio::EnsEMBL::IdMapping::TinyFeature implementing class
94  Exceptions : none
96  Status : At Risk
97  : under development
98 
99 =cut
100 
101 sub new_fast {
102  my $class = shift;
103  my $array_ref = shift;
104  return bless $array_ref, $class;
105 }
106 
107 
108 =head2 id
109 
110  Arg[1] : (optional) Int - the feature's internal Id ("dbID")
111  Description : Getter/setter for the feature's internal Id.
112  Return type : Int
113  Exceptions : none
115  Status : At Risk
116  : under development
117 
118 =cut
119 
120 sub id {
121  my $self = shift;
122  $self->[0] = shift if (@_);
123  return $self->[0];
124 }
125 
126 
127 =head2 stable_id
128 
129  Arg[1] : (optional) String - the feature's stable Id
130  Description : Getter/setter for the feature's stable Id.
131  Return type : String
132  Exceptions : none
134  Status : At Risk
135  : under development
136 
137 =cut
138 
139 sub stable_id {
140  my $self = shift;
141  $self->[1] = shift if (@_);
142  return $self->[1];
143 }
144 
145 
146 =head2 version
147 
148  Arg[1] : (optional) Int - the feature's stable Id version
149  Description : Getter/setter for the feature's stable Id version.
150  Return type : Int
151  Exceptions : none
153  Status : At Risk
154  : under development
155 
156 =cut
157 
158 sub version {
159  my $self = shift;
160  $self->[2] = shift if (@_);
161  return $self->[2];
162 }
163 
164 
165 =head2 created_date
166 
167  Arg[1] : (optional) String - the feature's stable Id creation date
168  Description : Getter/setter for the feature's stable Id creation date.
169  Return type : String
170  Exceptions : none
172  Status : At Risk
173  : under development
174 
175 =cut
176 
177 sub created_date {
178  my $self = shift;
179  $self->[3] = shift if (@_);
180  return $self->[3];
181 }
182 
183 
184 =head2 modified_date
185 
186  Arg[1] : (optional) String - the feature's stable Id modification date
187  Description : Getter/setter for the feature's stable Id modification date.
188  Return type : String
189  Exceptions : none
191  Status : At Risk
192  : under development
193 
194 =cut
195 
196 sub modified_date {
197  my $self = shift;
198  $self->[4] = shift if (@_);
199  return $self->[4];
200 }
201 
202 
203 =head2 to_string
204 
205  Example : print LOG "Created ", $f->to_string, "\n";
206  Description : Prints a string representation of the feature for debug
207  purposes.
208  Return type : String
209  Exceptions : none
210  Caller : general
211  Status : At Risk
212  : under development
213 
214 =cut
215 
216 sub to_string {
217  my $self = shift;
218  return $self->id.':'.$self->stable_id.'.'.$self->version;
219 }
220 
221 
222 1;
223 
debug
public debug()
Bio::EnsEMBL::IdMapping::TinyFeature
Definition: TinyFeature.pm:30
Bio::EnsEMBL::IdMapping::Cache
Definition: Cache.pm:18
Bio::EnsEMBL::Utils::Exception
Definition: Exception.pm:68