EnsEMBL/DensityType.pm untested

filter: Statementstmt 0.0% 0 / 58 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 22 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 116 CC 11 SCAR 27.7
CC
11
Cov
0%
new
42.0
analysis
12.0
value_type
6.0
CRAP 16.0
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::DensityType - A type representing a density, or percentage
34 coverage etc. in a given region.
35  
36 =head1 SYNOPSIS
37  
38 use Bio::EnsEMBL::DensityType;
39  
40 $type = Bio::EnsEMBL::DensityType->new(
41 -analysis => $analysis,
42 -blocksize => 1000000,
43 -value_type => $type
44 );
45  
46 =head1 DESCRIPTION
47  
48 A density type represents a density, or percentage coverage etc. in a
49 given region.
50  
51 =head1 METHODS
52  
53 =cut
54  
55 use strict;
56 use warnings;
57  
58 package Bio::EnsEMBL::DensityType;
59 $Bio::EnsEMBL::DensityType::VERSION = '114.0.0_50'; # TRIAL
60 $Bio::EnsEMBL::DensityType::VERSION = '114.0.050';
61 use Bio::EnsEMBL::Storable;
62 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
63 use Bio::EnsEMBL::Utils::Exception qw(throw);
64  
65 use vars qw(@ISA);
66  
67 @ISA = qw(Bio::EnsEMBL::Storable);
68  
69 =head2 new
70  
71 Arg [..] : Takes a set of named arguments
72 Example : $dt = new Bio::EnsEMBL::DensityType::DensityType(
73 -analysis => $analysis,
74 -blocksize => 1e6,
75 -value_type => 'sum')
76  
77 Description: Creates a new Density Type object
78 Returntype : Bio::EnsEMBL::DensityType
79 Exceptions : blocksize > 0,
80 valuetype must be 'sum' or 'ratio',
81 valid analysis object must be passed
82 Caller : general
83 Status : Stable
84  
85 =cut
86  
87  
88 sub new {
89 my $class = shift;
90  
91 my $self = $class->SUPER::new(@_);
92  
93 my ($analysis, $block_size, $value_type, $region_features) =
94 rearrange(['ANALYSIS','BLOCK_SIZE','VALUE_TYPE','REGION_FEATURES'],@_);
95  
96 if($analysis) {
97 if(!ref($analysis) || !$analysis->isa('Bio::EnsEMBL::Analysis')) {
98 throw('-ANALYSIS argument must be a Bio::EnsEMBL::Analysis not '.
99 $analysis);
100 }
101 }
102  
103 if($value_type ne "sum" and $value_type ne "ratio"){
104 throw('-VALUE_TYPE argument must be "ratio" or "sum" not *'.
105 $value_type."*");
106 }
107  
108 $block_size ||= 0;
109 $region_features ||= 0;
110  
111 if($block_size && $region_features){
112 throw('Set either -BLOCK_SIZE or -REGION_FEATURES, not both');
113 }
114  
115 if( $block_size <0 or $region_features < 0 ) {
116 throw( 'No negative values for -BLOCK_SIZE or -REGION_FEATURES' );
117 }
118  
119  
120 $self->{'analysis'} = $analysis;
121 $self->{'block_size'} = $block_size;
122 $self->{'value_type'} = $value_type;
123 $self->{'region_features'} = $region_features;
124  
125 return $self;
126 }
127  
128 =head2 analysis
129  
130 Arg [1] : Bio::EnsEMBL::Analysis
131 Description: get/set for attribute analysis
132 Returntype : Bio::EnsEMBL::Analysis
133 Exceptions : none
134 Caller : general
135 Status : Stable
136  
137 =cut
138  
139 sub analysis{
140 my $self = shift;
141  
142 if(@_) {
143 my $a = shift;
144 if(defined($a) && (!ref($a) || !$a->isa('Bio::EnsEMBL::Analysis'))) {
145 throw("Argument must be undef or a Bio::EnsEMBL::Analysis object.");
146 }
147 $self->{'analysis'} = $a;
148 }
149 return $self->{'analysis'};
150 }
151  
152 =head2 value_type
153  
154 Arg [1] : string $value_type
155 Description: gettter/setter for the type
156 Returntype : float
157 Exceptions : none
158 Caller : general
159 Status : Stable
160  
161 =cut
162  
163 sub value_type{
164 my $self = shift;
165 $self->{'value_type'} = shift if(@_);
166 return $self->{'value_type'};
167 }
168  
169  
170 =head2 block_size
171  
172 Arg [1] : int
173 Description: getter/setter for attribute block_size
174 Returntype : int
175 Exceptions : none
176 Caller : general
177 Status : Stable
178  
179 =cut
180  
181 sub block_size{
182 my $self = shift;
183 $self->{'block_size'} = shift if(@_);
184 return $self->{'block_size'};
185 }
186  
187  
188 =head2 region_features
189  
190 Arg [1] : int $region_features
191 Example : The number of features per seq_region inside this density_type..
192 Description: get/set for attribute region_features
193 Returntype : string
194 Exceptions : none
195 Caller : general
196  
197 =cut
198  
199 sub region_features {
200 my $self = shift;
201 $self->{'region_features'} = shift if( @_ );
202 return $self->{'region_features'};
203 }
204  
205  
206 1;