0
|
1 #
|
|
2 # Ensembl module for Bio::EnsEMBL::Funcgen::SetFeature
|
|
3 #
|
|
4
|
|
5
|
|
6 =head1 LICENSE
|
|
7
|
|
8 Copyright (c) 1999-2012 The European Bioinformatics Institute and
|
|
9 Genome Research Limited. All rights reserved.
|
|
10
|
|
11 This software is distributed under a modified Apache license.
|
|
12 For license details, please see
|
|
13
|
|
14 http://www.ensembl.org/info/about/code_licence.html
|
|
15
|
|
16 =head1 CONTACT
|
|
17
|
|
18 Please email comments or questions to the public Ensembl
|
|
19 developers list at <ensembl-dev@ebi.ac.uk>.
|
|
20
|
|
21 Questions may also be sent to the Ensembl help desk at
|
|
22 <helpdesk@ensembl.org>.
|
|
23
|
|
24
|
|
25 =head1 NAME
|
|
26
|
|
27 Bio::EnsEMBL::Funcgen::SetFeature - Base class for features of a Set.
|
|
28
|
|
29 =head1 SYNOPSIS
|
|
30
|
|
31 # Would normally be created from an in inheriting class e.g. AnnotatedFeature.pm
|
|
32
|
|
33 use base qw(Bio::Ensembl::Funcgen::SetFeature);
|
|
34
|
|
35 sub new {
|
|
36 my $caller = shift;
|
|
37 my $class = ref($caller) || $caller;
|
|
38 my $self = $class->SUPER::new(@_);
|
|
39 # More construction here
|
|
40 }
|
|
41
|
|
42 # Alternative direct contruction
|
|
43
|
|
44 my $feat = Bio::EnsEMBL::Funcgen::SetFeature->
|
|
45 (
|
|
46 -start => 100,
|
|
47 -end => 220,
|
|
48 -strand => -1,
|
|
49 -slice => $slice,
|
|
50 -set => $fset,
|
|
51 -feature_type => $ftype,
|
|
52 -display_label => $label,
|
|
53 );
|
|
54
|
|
55 # Accessing some attributes
|
|
56
|
|
57
|
|
58 my $start = $feat->start;
|
|
59 my $end = $feat->end;
|
|
60 my $strand = $feat->strand;
|
|
61 my $fset = $feat->set;
|
|
62 my $cell_type = $feat->cell_type;
|
|
63
|
|
64 # Printing some information
|
|
65
|
|
66 print $feature->display_label.' has the FeatureType '.$feat->feature_type->name."\n";
|
|
67
|
|
68 =head1 DESCRIPTION
|
|
69
|
|
70 This is a base class for features which are contained within a Funcgen FeatureSet or ResultSet.
|
|
71 It provides generic methods for attributes which are common across all inheriting classes.
|
|
72
|
|
73 =cut
|
|
74
|
|
75
|
|
76 package Bio::EnsEMBL::Funcgen::SetFeature;
|
|
77
|
|
78 use strict;
|
|
79 use warnings;
|
|
80
|
|
81 use Bio::EnsEMBL::Feature;
|
|
82 use Bio::EnsEMBL::Funcgen::Storable;
|
|
83 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
|
|
84 use Bio::EnsEMBL::Utils::Exception qw(throw);
|
|
85
|
|
86 use vars qw(@ISA);
|
|
87 @ISA = qw(Bio::EnsEMBL::Feature Bio::EnsEMBL::Funcgen::Storable);
|
|
88 #can't use base with dual inheritance
|
|
89
|
|
90 =head2 new
|
|
91
|
|
92
|
|
93 Arg [-SET] : Bio::EnsEMBL::Funcgen::ResultSet or FeatureSet.
|
|
94 Arg [-DISPLAY_LABEL]: (optional) String - Display label for this feature
|
|
95 Arg [-FEATURE_TYPE] : (optional) Bio::EnsEMBL::Funcgen::FeatureType.
|
|
96 Defaults to Feature/ResultSet FeatureType.
|
|
97
|
|
98 #Bio::EnsEMBL::Feature arguments
|
|
99 Arg [-SLICE] : Bio::EnsEMBL::Slice - The slice on which this feature is.
|
|
100 Arg [-STRAND] : (optional) Int - The orientation of this feature relative to the
|
|
101 strand it is on. Valid values are 1, -1 and 0.
|
|
102 Arg [-START] : Int - The start coordinate of this feature relative to the start of the slice
|
|
103 it is sitting on. Coordinates start at 1 and are inclusive.
|
|
104 Arg [-END] : Int -The end coordinate of this feature relative to the start of the slice
|
|
105 it is sitting on. Coordinates start at 1 and are inclusive.
|
|
106 Arg [-ANALYSIS] : (optional) Bio::EnsEMBL::Analysis. Defaults to Feature/ResultSet Analysis.
|
|
107 Arg [-dbID] : (optional) Int - Internal database ID.
|
|
108 Arg [-ADAPTOR] : (optional) Bio::EnsEMBL::Funcgen::DBSQL::BaseFeatureAdaptor
|
|
109
|
|
110
|
|
111
|
|
112 Example : my $feature = Bio::EnsEMBL::Funcgen::SetFeature->new
|
|
113 (
|
|
114 -SLICE => $chr_1_slice,
|
|
115 -START => 1000000,
|
|
116 -END => 1000024,
|
|
117 -STRAND => -1,
|
|
118 -DISPLAY_LABEL => $text,
|
|
119 -SET => $fset,
|
|
120 );
|
|
121
|
|
122 Description: Constructor for SetFeature objects. Should never be called directly, only by its children.
|
|
123 Returntype : Bio::EnsEMBL::Funcgen::SetFeature
|
|
124 Exceptions : Throws if no valid ResultSet or FeatureSet passed
|
|
125 Throws if FeatureType is passed but not valid
|
|
126 Caller : General
|
|
127 Status : At Risk - FEATURE_SET arg to be removed, superceded by SET in v67
|
|
128
|
|
129 =cut
|
|
130
|
|
131 sub new {
|
|
132 my $caller = shift;
|
|
133 my $class = ref($caller) || $caller;
|
|
134
|
|
135 my ($display_label, $fset, $ftype, $set)
|
|
136 = rearrange(['DISPLAY_LABEL', 'FEATURE_SET', 'FEATURE_TYPE', 'SET'], @_);
|
|
137
|
|
138 $set ||= $fset;
|
|
139
|
|
140 if( ( ref($set) ne 'Bio::EnsEMBL::Funcgen::FeatureSet') &&
|
|
141 ( ref($set) ne 'Bio::EnsEMBL::Funcgen::ResultSet') ){
|
|
142 throw("Must pass valid Bio::EnsEMBL::Funcgen::FeatureSet or ResultSet object");
|
|
143 }
|
|
144
|
|
145 #Grab FeatureSet first so we can pass analysis to base Feature class
|
|
146 #Funcgen analysis is currently always at the Set level
|
|
147 #if this ever changes the SetFeature->analysis method will also need changing
|
|
148 my $self = $class->SUPER::new(@_, -analysis => $set->analysis);
|
|
149
|
|
150 if($ftype){
|
|
151
|
|
152 if (ref($ftype) ne 'Bio::EnsEMBL::Funcgen::FeatureType') {
|
|
153 throw('feature_type param must be a valid Bio::EnsEMBL::Funcgen::FeatureType');
|
|
154 }
|
|
155
|
|
156 $self->{feature_type} = $ftype;
|
|
157 }
|
|
158
|
|
159 #Setting attrs directly removes the need for setter code in methods
|
|
160 $self->{set} = $set;
|
|
161 $self->{display_label} = $display_label if defined $display_label;
|
|
162
|
|
163 return $self;
|
|
164 }
|
|
165
|
|
166
|
|
167
|
|
168 =head2 feature_set
|
|
169
|
|
170 Example : my $set = $efeature->feature_set();
|
|
171 Description: WARNING: Can now also return ResultSet aswell as FeatureSet attribute for this feature.
|
|
172 Returntype : Bio::EnsEMBL::Funcgen::FeatureSet or ResultSet
|
|
173 Exceptions : None
|
|
174 Caller : General
|
|
175 Status : At Risk - marked as to be removed in v67
|
|
176
|
|
177 =cut
|
|
178
|
|
179 sub feature_set {
|
|
180 #??? deprecate
|
|
181 #check webcode?
|
|
182
|
|
183 return $_[0]->{set};
|
|
184 }
|
|
185
|
|
186
|
|
187 =head2 set
|
|
188
|
|
189 Example : my $set = $set_feature->set();
|
|
190 Description: Getter for the set attribute for this feature.
|
|
191 Returntype : Bio::EnsEMBL::Funcgen::FeatureSet or ResultSet
|
|
192 Exceptions : None
|
|
193 Caller : General
|
|
194 Status : At Risk
|
|
195
|
|
196 =cut
|
|
197
|
|
198 sub set {
|
|
199 return $_[0]->{set};
|
|
200 }
|
|
201
|
|
202 =head2 cell_type
|
|
203
|
|
204 Example : my $cell_name = $set_feature->cell_type->name;
|
|
205 Description: Getter for the CellType attribute for the Set of this Feature.
|
|
206 May not always be for some Set types e.g. ExternalFeatures.
|
|
207 Returntype : Bio::EnsEMBL::Funcgen::CellType
|
|
208 Exceptions : None
|
|
209 Caller : General
|
|
210 Status : stable
|
|
211
|
|
212 =cut
|
|
213
|
|
214 sub cell_type{
|
|
215 return $_[0]->set->cell_type;
|
|
216 }
|
|
217
|
|
218
|
|
219 =head2 feature_type
|
|
220
|
|
221 Example : my $ft_name = $set_feature->feature_type->name;
|
|
222 Description: Getter for the FeatureType attribute for this feature.
|
|
223 If not explicitly set, defaults to the Set FeatureType
|
|
224 Returntype : Bio::EnsEMBL::Funcgen::FeatureType
|
|
225 Exceptions : None
|
|
226 Caller : General
|
|
227 Status : stable
|
|
228
|
|
229 =cut
|
|
230
|
|
231 sub feature_type{
|
|
232 my $self = shift;
|
|
233
|
|
234 if(! defined $self->{feature_type}){
|
|
235 $self->{feature_type} = $self->set->feature_type;
|
|
236 }
|
|
237
|
|
238 return $self->{feature_type};
|
|
239 }
|
|
240
|
|
241
|
|
242 =head2 analysis
|
|
243
|
|
244 Example : my $analysis = $setfeature->analysis;
|
|
245 Description: Getter for the Analysis attribute for this feature.
|
|
246 Re-implementation of Bio::EnsEMBL::Feature->analysis.
|
|
247 Returntype : Bio::EnsEMBL::Analysis
|
|
248 Exceptions : None
|
|
249 Caller : General
|
|
250 Status : stable
|
|
251
|
|
252 =cut
|
|
253
|
|
254 #what about MFs? add as feature_set as MOODS/PWM analysis not represented
|
|
255 #This is a mandatory requirement for Bio::EnsEMBL::Feature
|
|
256 #Do we ever actually have analysis at the feature level?
|
|
257
|
|
258 sub analysis{
|
|
259 return $_[0]->set->analysis;
|
|
260 }
|
|
261
|
|
262
|
|
263 =head2 display_label
|
|
264
|
|
265 Example : my $label = $feature->display_label;
|
|
266 Description: Getter for the display label of this feature.
|
|
267 This will most likely be over-ridden by inheriting class
|
|
268 Returntype : String
|
|
269 Exceptions : None
|
|
270 Caller : General
|
|
271 Status : Stable
|
|
272
|
|
273 =cut
|
|
274
|
|
275 sub display_label{
|
|
276 return $_[0]->{display_label};
|
|
277 }
|
|
278
|
|
279
|
|
280 1;
|