0
|
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::DensityFeature - A feature representing a density, or
|
|
24 precentage coverage etc. in a given region.
|
|
25
|
|
26 =head1 SYNOPSIS
|
|
27
|
|
28 use Bio::EnsEMBL::DensityFeature;
|
|
29
|
|
30 $feature = Bio::EnsEMBL::DensityFeature->new(
|
|
31 -seq_region => $region,
|
|
32 -start => 1,
|
|
33 -end => 1e6,
|
|
34 -density_type => $dt,
|
|
35 -density_value => 98.5
|
|
36 );
|
|
37
|
|
38 =head1 DESCRIPTION
|
|
39
|
|
40 A density feature represents a count, density, or percentage coverage,
|
|
41 etc. for a given region.
|
|
42
|
|
43 This module is part of the Ensembl project http://www.ensembl.org
|
|
44
|
|
45 =head1 METHODS
|
|
46
|
|
47 =cut
|
|
48
|
|
49
|
|
50 use strict;
|
|
51 use warnings;
|
|
52
|
|
53 package Bio::EnsEMBL::DensityFeature;
|
|
54
|
|
55 use Bio::EnsEMBL::Feature;
|
|
56 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
|
|
57 use Bio::EnsEMBL::Utils::Exception qw(throw);
|
|
58 use Bio::EnsEMBL::DensityType;
|
|
59
|
|
60 use vars qw(@ISA);
|
|
61
|
|
62 @ISA = qw(Bio::EnsEMBL::Feature);
|
|
63
|
|
64
|
|
65 =head2 new
|
|
66
|
|
67 Arg [SEQ_REGION] : the sequence over which the density was calculated.
|
|
68
|
|
69 Arg [START] : start point on the seq at which density was calulated.
|
|
70
|
|
71 Arg [END] : end point on the seq at which density was calulated.
|
|
72
|
|
73 Arg [DENSITY_TYPE] : the type of density calculated.
|
|
74
|
|
75 Arg [DENSITY_VALUE] : the density.
|
|
76
|
|
77 Arg [...] : Named arguments passed to superclass
|
|
78 Example : $feature = Bio::EnsEMBL::DensityFeature->new
|
|
79 (-seq_region => $region,
|
|
80 -start => 1,
|
|
81 -end => 1e6,
|
|
82 -density_type => $dt,
|
|
83 -density_value => 98.5)
|
|
84
|
|
85 Description: Creates a new density feature.
|
|
86 Returntype : Bio::EnsEMBL::DensityFeature
|
|
87 Exceptions : throw if invalid density value type is provided
|
|
88 Caller : general
|
|
89 Status : Stable
|
|
90
|
|
91 =cut
|
|
92
|
|
93 sub new {
|
|
94 my $caller = shift;
|
|
95
|
|
96 #allow constructor to be called as class or object method
|
|
97 my $class = ref($caller) || $caller;
|
|
98
|
|
99 my $self = $class->SUPER::new(@_);
|
|
100
|
|
101 my($seq_region, $start, $end, $dt, $dv) =
|
|
102 rearrange(['SEQ_REGION', 'START', 'END', 'DENSITY_TYPE', 'DENSITY_VALUE'],
|
|
103 @_);
|
|
104
|
|
105 throw("Density value must be >= 0.") if($dv < 0);
|
|
106
|
|
107 if(!defined($dt)){
|
|
108 throw("Density Type is NOT optional.");
|
|
109 }
|
|
110
|
|
111 $self->{'density_type'} = $dt;
|
|
112 $self->{'density_value'} = $dv;
|
|
113
|
|
114 $self->{'slice'} = $seq_region;
|
|
115 $self->{'start'} = $start;
|
|
116 $self->{'end'} = $end;
|
|
117
|
|
118
|
|
119 return $self;
|
|
120 }
|
|
121
|
|
122
|
|
123 =head2 new_fast
|
|
124
|
|
125 Arg [...] : none
|
|
126 Example : $feature = Bio::EnsEMBL::DensityFeature->new_fast();
|
|
127 Description: Creates a new density feature.
|
|
128 Returntype : Bio::EnsEMBL::DensityFeature
|
|
129 Exceptions : none
|
|
130 Caller : general
|
|
131 Status : Stable
|
|
132
|
|
133 =cut
|
|
134
|
|
135 sub new_fast{
|
|
136 my $caller = shift;
|
|
137
|
|
138 #allow constructor to be called as class or object method
|
|
139 my $class = ref($caller) || $caller;
|
|
140
|
|
141 my $self = $class->SUPER::new(@_);
|
|
142
|
|
143 return $self;
|
|
144 }
|
|
145
|
|
146
|
|
147 =head2 strand
|
|
148
|
|
149 Arg [1] : none
|
|
150 Example : $strand = $df->strand();
|
|
151 Description: Getter fot the strand attribute. Density features always have
|
|
152 strand 0 and this attribute is not settable.
|
|
153 Returntype : int (always 0)
|
|
154 Exceptions : warning if an attempt is made to set the strand
|
|
155 Caller : general
|
|
156 Status : Stable
|
|
157
|
|
158 =cut
|
|
159
|
|
160 sub strand {
|
|
161 my $self = shift;
|
|
162 warning("DensityFeature strand is not settable") if(@_);
|
|
163 return 0;
|
|
164 }
|
|
165
|
|
166
|
|
167
|
|
168 =head2 density_value
|
|
169
|
|
170 Arg [1] : (optional) float $density_value
|
|
171 Example : $dv = $density_feature->density_value();
|
|
172 Description: Getter/Setter for the density value of this DensityFeature.
|
|
173 The density value may be a count, a percentage, or a coverage
|
|
174 of a feature type in the area defined by this feature.
|
|
175 Returntype : float
|
|
176 Exceptions : throw if a negative density value is provided
|
|
177 Caller : general
|
|
178 Status : Stable
|
|
179
|
|
180 =cut
|
|
181
|
|
182 sub density_value {
|
|
183 my $self = shift;
|
|
184
|
|
185 if(@_) {
|
|
186 my $density_value = shift;
|
|
187 throw("Density value must be >= 0.") if($density_value < 0);
|
|
188 $self->{'density_value'} = $density_value;
|
|
189 }
|
|
190
|
|
191 return $self->{'density_value'};
|
|
192 }
|
|
193
|
|
194
|
|
195
|
|
196 =head2 analysis
|
|
197
|
|
198 Arg [1] : (optional) Bio::EnsEMBL::Analysis $analysis
|
|
199 New value for the analysis of the attached DensityType
|
|
200 Example : print $df->analysis()->logic_name();
|
|
201 Description: Overridden superclass analysis method, to chain to analysis
|
|
202 method on attached DensityType.
|
|
203 Returntype : Bio::EnsEMBL::Analysis
|
|
204 Exceptions : none
|
|
205 Caller : general
|
|
206 Status : Stable
|
|
207
|
|
208 =cut
|
|
209
|
|
210 sub analysis {
|
|
211 my $self = shift;
|
|
212
|
|
213 my $dt = $self->density_type();
|
|
214
|
|
215 return undef if(!$dt);
|
|
216
|
|
217 return $dt->analysis(@_);
|
|
218 }
|
|
219
|
|
220
|
|
221
|
|
222 =head2 density_type
|
|
223
|
|
224 Arg [1] : string $newval (optional)
|
|
225 The new value to set the density_value_type attribute to
|
|
226 Example : $density_value_type = $obj->density_value_type()
|
|
227 Description: Getter/Setter for the density_value_type attribute
|
|
228 Returntype : Bio::EnsEMBL::DensityType
|
|
229 Exceptions : if object passed is not of type DensityType
|
|
230 Caller : general
|
|
231 Status : Stable
|
|
232
|
|
233 =cut
|
|
234
|
|
235 sub density_type{
|
|
236 my $self = shift;
|
|
237 if(@_) {
|
|
238 my $type = shift;
|
|
239 if( !ref $type || !$type->isa("Bio::EnsEMBL::DensityType")){
|
|
240 throw("object passed must be an ensembl DensityType ".
|
|
241 "not a [".ref($type)."]");
|
|
242 }
|
|
243 else{
|
|
244 $self->{'density_type'}=$type;
|
|
245 }
|
|
246 }
|
|
247 return $self->{'density_type'};
|
|
248 }
|
|
249
|
|
250
|
|
251 ###BG########
|
|
252
|
|
253 =head2 scaledvalue
|
|
254
|
|
255 Title : scaledvalue
|
|
256 Usage : $obj->scaledvalue($newval)
|
|
257 Function:
|
|
258 Returns : scalar - object's scaled value
|
|
259 Args : newvalue (optional)
|
|
260 Status : Stable
|
|
261
|
|
262 =cut
|
|
263
|
|
264 sub scaledvalue{
|
|
265 my $obj = shift;
|
|
266 if( @_ ) {
|
|
267 my $scaledvalue = shift;
|
|
268 $obj->{'scaledvalue'} = $scaledvalue;
|
|
269 }
|
|
270 return $obj->{'scaledvalue'};
|
|
271 }
|
|
272
|
|
273
|
|
274
|
|
275 =head2 url
|
|
276
|
|
277 Title : url
|
|
278 Usage : $obj->url($newval)
|
|
279 Function:
|
|
280 Returns : String containing this object's url
|
|
281 Args : newvalue (optional)
|
|
282 Status : Stable
|
|
283
|
|
284
|
|
285 =cut
|
|
286
|
|
287 sub url{
|
|
288 my $obj = shift;
|
|
289 if( @_ ) {
|
|
290 my $url = shift;
|
|
291 $obj->{'url'} = $url;
|
|
292 }
|
|
293 return $obj->{'url'};
|
|
294
|
|
295 }
|
|
296
|
|
297
|
|
298 1;
|
|
299
|
|
300
|
|
301
|