Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/Funcgen/ResultFeature.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 # | |
2 # Ensembl module for Bio::EnsEMBL::Funcgen::ResultFeature | |
3 # | |
4 | |
5 =head1 LICENSE | |
6 | |
7 Copyright (c) 1999-2011 The European Bioinformatics Institute and | |
8 Genome Research Limited. All rights reserved. | |
9 | |
10 This software is distributed under a modified Apache license. | |
11 For license details, please see | |
12 | |
13 http://www.ensembl.org/info/about/code_licence.html | |
14 | |
15 =head1 CONTACT | |
16 | |
17 Please email comments or questions to the public Ensembl | |
18 developers list at <ensembl-dev@ebi.ac.uk>. | |
19 | |
20 Questions may also be sent to the Ensembl help desk at | |
21 <helpdesk@ensembl.org>. | |
22 | |
23 | |
24 =head1 NAME | |
25 | |
26 Bio::EnsEMBL::Funcgen::ResultFeature - A module to represent a lightweight ResultFeature object | |
27 | |
28 =head1 SYNOPSIS | |
29 | |
30 use Bio::EnsEMBL::Funcgen::ResultFeature; | |
31 | |
32 my $rfeature = Bio::EnsEMBL::Funcgen::ResultFeature->new_fast([$start, $end, $score ]); | |
33 | |
34 my @rfeatures = @{$rset->get_displayable_ResultFeature_by_Slice($slice)}; | |
35 | |
36 foreach my $rfeature (@rfeatures){ | |
37 my $score = $rfeature->score(); | |
38 my $rf_start = $rfeature->start(); | |
39 my $rf_end = $rfeature->end(); | |
40 } | |
41 | |
42 =head1 DESCRIPTION | |
43 | |
44 This is a very sparse class designed to be as lightweight as possible to enable fast rendering in the web browser. | |
45 As such only the information absolutely required is contained. Any a piori information is omitted e.g. seq_region_id, | |
46 this will already be known as ResultFeatures are retrieved via a Slice method in ResultSet via the ResultSetAdaptor, | |
47 likewise with analysis and experimental_chip information. ResultFeatures are transient objects, in that they are not | |
48 stored in the DB, but are a very small subset of information from the result and oligo_feature tables. ResultFeatures | |
49 should only be generated by the ResultSetAdaptor as there is no parameter checking in place. | |
50 | |
51 =cut | |
52 | |
53 use strict; | |
54 use warnings; | |
55 | |
56 #Could set global named vars here for element names. Would take more memory | |
57 | |
58 package Bio::EnsEMBL::Funcgen::ResultFeature; | |
59 | |
60 use base ('Bio::EnsEMBL::Feature'); | |
61 | |
62 =head2 new_fast | |
63 | |
64 Args : Array with attributes start, end, strand, score, probe, result_set_id, winow_size IN THAT ORDER. | |
65 WARNING: None of these are validated, hence can omit some where not needed | |
66 Example : none | |
67 Description: Fast and list version of new. Only works if the code is very disciplined. | |
68 Returntype : Bio::EnsEMBL::Funcgen::ResultFeature | |
69 Exceptions : None | |
70 Caller : ResultSetAdaptor | |
71 Status : At Risk | |
72 | |
73 =cut | |
74 | |
75 sub new_fast { | |
76 my ($class, @args) = @_; | |
77 #return bless ($arrayref, $class); | |
78 | |
79 #Passing arrayref here may cause problems with changing vars after obj creation | |
80 | |
81 #warn "in new fast with @args"; | |
82 | |
83 bless \@args, $class; | |
84 } | |
85 | |
86 | |
87 | |
88 | |
89 =head2 start | |
90 | |
91 Example : my $start = $rf->start(); | |
92 Description: Getter of the start attribute for ResultFeature | |
93 objects. | |
94 Returntype : int | |
95 Exceptions : None | |
96 Caller : General | |
97 Status : At Risk - Now also sets to enable projection | |
98 | |
99 =cut | |
100 | |
101 sub start { | |
102 $_[0]->[0] = $_[1] if $_[1]; | |
103 $_[0]->[0]; | |
104 } | |
105 | |
106 | |
107 =head2 end | |
108 | |
109 Example : my $start = $rf->end(); | |
110 Description: Getter of the end attribute for ResultFeature | |
111 objects. | |
112 Returntype : int | |
113 Exceptions : None | |
114 Caller : General | |
115 Status : At Risk - Now also sets to enable projection | |
116 | |
117 =cut | |
118 | |
119 sub end { | |
120 $_[0]->[1] = $_[1] if $_[1]; | |
121 $_[0]->[1]; | |
122 } | |
123 | |
124 | |
125 #Do we need to chacnge this to strand and have slice strand context, as with start and end | |
126 | |
127 sub strand { $_[0]->[2];} | |
128 | |
129 =head2 score | |
130 | |
131 Example : my $score = $rf->score(); | |
132 Description: Getter of the score attribute for ResultFeature | |
133 objects | |
134 Returntype : string/float/double? | |
135 Exceptions : None | |
136 Caller : General | |
137 Status : At Risk | |
138 | |
139 =cut | |
140 | |
141 sub score { $_[0]->[3];} | |
142 | |
143 | |
144 =head2 probe | |
145 | |
146 Example : my $probe = $rf->probe(); | |
147 Description: Getter of the probe attribute for ResultFeature | |
148 objects | |
149 Returntype : Bio::EnsEMBL::Funcgen::Probe | |
150 Exceptions : None | |
151 Caller : General | |
152 Status : At Risk - This can only be used for Features with window 0. | |
153 | |
154 =cut | |
155 | |
156 #probe_id is currently not available in the result_feature table, so this would be a result/probe_feature query. | |
157 | |
158 sub probe { $_[0]->[4];} | |
159 | |
160 | |
161 #The following are only used for storage and retrieval, hence why they are not included in new_fast which is streamlined | |
162 #for performance | |
163 #These have no validation so all thi smust be done in the caller/storer i.e. the adaptor | |
164 | |
165 sub result_set_id { $_[0]->[5];} | |
166 sub window_size { $_[0]->[6];} | |
167 | |
168 #May not ever need this | |
169 #We pass the slice to store | |
170 #Don't normally want to remap, so don't need furing fetch | |
171 #Now also sets for to enable projection | |
172 | |
173 sub slice { | |
174 $_[0]->[7] = $_[1] if $_[1]; | |
175 $_[0]->[7]; | |
176 } | |
177 | |
178 | |
179 #Had to reimplement these as they used direct hash calls rather than acessor | |
180 #redefined to use accessors to array | |
181 | |
182 sub length { | |
183 my $self = shift; | |
184 return $self->end - $self->start + 1; | |
185 } | |
186 | |
187 =head2 move | |
188 | |
189 Arg [1] : int start | |
190 Arg [2] : int end | |
191 Arg [3] : (optional) int strand | |
192 Example : None | |
193 Description: Sets the start, end and strand in one call rather than in | |
194 3 seperate calls to the start(), end() and strand() methods. | |
195 This is for convenience and for speed when this needs to be | |
196 done within a tight loop. | |
197 Returntype : none | |
198 Exceptions : Thrown is invalid arguments are provided | |
199 Caller : general | |
200 Status : Stable | |
201 | |
202 =cut | |
203 | |
204 sub move { | |
205 my $self = shift; | |
206 | |
207 throw('start and end arguments are required') if(@_ < 2); | |
208 | |
209 my $start = shift; | |
210 my $end = shift; | |
211 my $strand = shift; | |
212 | |
213 if(defined($start) && defined($end) && $end < $start) { | |
214 throw('start must be less than or equal to end'); | |
215 } | |
216 if(defined($strand) && $strand != 0 && $strand != -1 && $strand != 1) { | |
217 throw('strand must be 0, -1 or 1'); | |
218 } | |
219 | |
220 $self->[0] = $start; | |
221 $self->[1] = $end; | |
222 $self->[2] = $strand if(defined($strand)); | |
223 } | |
224 | |
225 | |
226 | |
227 =head2 feature_Slice | |
228 | |
229 Args : none | |
230 Example : $slice = $feature->feature_Slice() | |
231 Description: Reimplementation of Bio::EnsEMBL::Feature method to enable | |
232 assembly mapping | |
233 Returntype : Bio::EnsEMBL::Slice or undef if this feature has no attached | |
234 Slice. | |
235 Exceptions : warning if Feature does not have attached slice. | |
236 Caller : web drawing code | |
237 Status : Stable | |
238 | |
239 =cut | |
240 | |
241 | |
242 sub feature_Slice { | |
243 my ($self) = @_; | |
244 | |
245 my $slice = $self->[7]; | |
246 | |
247 if(!$slice) { | |
248 warning('Cannot obtain Feature_Slice for feature without attached slice'); | |
249 return undef; | |
250 } | |
251 | |
252 return $slice->sub_Slice($self->[0], $self->[1]); | |
253 } | |
254 | |
255 | |
256 | |
257 1; | |
258 |