0
|
1 #
|
|
2 # Ensembl module for Bio::EnsEMBL::Funcgen::Collection::ResultFeature
|
|
3 #
|
|
4 =head1 LICENSE
|
|
5
|
|
6 Copyright (c) 1999-2011 The European Bioinformatics Institute and
|
|
7 Genome Research Limited. All rights reserved.
|
|
8
|
|
9 This software is distributed under a modified Apache license.
|
|
10 For license details, please see
|
|
11
|
|
12 http://www.ensembl.org/info/about/code_licence.html
|
|
13
|
|
14 =head1 CONTACT
|
|
15
|
|
16 Please email comments or questions to the public Ensembl
|
|
17 developers list at <ensembl-dev@ebi.ac.uk>.
|
|
18
|
|
19 Questions may also be sent to the Ensembl help desk at
|
|
20 <helpdesk@ensembl.org>.
|
|
21
|
|
22
|
|
23 =head1 NAME
|
|
24
|
|
25 Bio::EnsEMBL::Funcgen::Collection::ResultFeature - A module to represent a lightweight ResultFeature collection
|
|
26
|
|
27 =head1 SYNOPSIS
|
|
28
|
|
29 use Bio::EnsEMBL::Funcgen::Collection::ResultFeature;
|
|
30
|
|
31 my $rfeature = Bio::EnsEMBL::Funcgen::Collection::ResultFeature->new_fast({
|
|
32 start => $start,
|
|
33 end => $end,
|
|
34 scores => [ $score ]
|
|
35 });
|
|
36
|
|
37 my @rfeatures = @{$rset->get_displayable_ResultFeatures_by_Slice($slice)};
|
|
38
|
|
39 foreach my $rfeature (@rfeatures){
|
|
40 my $score = $rfeature->score();
|
|
41 my $rf_start = $rfeature->start();
|
|
42 my $rf_end = $rfeature->end();
|
|
43 }
|
|
44
|
|
45 =head1 DESCRIPTION
|
|
46
|
|
47 This is a Collection feature which is designed to store compressed/collected
|
|
48 feature information for a defined window/bin size over a complete seq_region.
|
|
49 Or alternatively a single feature at the natural resolution i.e. window_size == 0.
|
|
50 The complete seq_region collections are cropped to provide a ResultFeature on any
|
|
51 given Slice. ResultFeatures are primarily stored in the result_feature table,
|
|
52 but can also be generated on the fly from unprocessed data in the array result
|
|
53 tables.
|
|
54
|
|
55
|
|
56 =head1 SEE ALSO
|
|
57
|
|
58 Bio::EnsEMBL::Funcgen::DBSQL::ResultFeatureAdaptor
|
|
59 Bio::EnsEMBL::Funcgen::Collector::ResultFeature
|
|
60
|
|
61 =cut
|
|
62
|
|
63
|
|
64 #This is distinct from a normal feature as the collection may have differen attributes and methods from the normal feature
|
|
65 #implementation. For example a Bio::EnsEMBL::Collection::Gene would only have summary information over several genes.
|
|
66 #Altho', unlikely that we'll ever collect genes.
|
|
67
|
|
68 use strict;
|
|
69 use warnings;
|
|
70
|
|
71
|
|
72 package Bio::EnsEMBL::Funcgen::Collection::ResultFeature;
|
|
73 use base ('Bio::EnsEMBL::Feature');#@ISA
|
|
74
|
|
75 #This needs to inherit from Bio::EnsEMBL::Collection
|
|
76 #Which can host some of the below methods
|
|
77
|
|
78 #Reverted to hash implementation as we no longer deal with
|
|
79 #huge amounts of features due to collections.
|
|
80 #This enables use of transform/seq_region_start/end methods
|
|
81 #and enable us to store on slices that do not begin at 1
|
|
82 #Altho need to remove code stipulating this
|
|
83
|
|
84
|
|
85
|
|
86 #To do
|
|
87 #Can we move any of these methods to a base Collection class?
|
|
88 #Should probably now use normal new method with validation?
|
|
89
|
|
90 =head2 new_fast
|
|
91
|
|
92 Args : Array with attributes start, end, strand, scores, probe, result_set_id, window_size, slice IN THAT ORDER.
|
|
93 WARNING: None of these are validated, hence can omit some where not needed
|
|
94 Example : none
|
|
95 Description: Fast and list version of new. Only works if the code is very disciplined.
|
|
96 Returntype : Bio::EnsEMBL::Funcgen::ResultFeature
|
|
97 Exceptions : None
|
|
98 Caller : ResultSetAdaptor
|
|
99 Status : At Risk
|
|
100
|
|
101 =cut
|
|
102
|
|
103 sub new_fast {
|
|
104 #This is agnostic towards to type of reference
|
|
105 return bless ($_[1], $_[0]);
|
|
106
|
|
107 }
|
|
108
|
|
109
|
|
110
|
|
111 =head2 scores
|
|
112
|
|
113 Example : my $score = $rf->score();
|
|
114 Description: Getter of the scores attribute for ResultFeature
|
|
115 objects
|
|
116 Returntype : Arrayref.
|
|
117 Exceptions : None
|
|
118 Caller : General
|
|
119 Status : At Risk
|
|
120
|
|
121 =cut
|
|
122
|
|
123 sub scores {
|
|
124 return $_[0]->{scores};
|
|
125 }
|
|
126
|
|
127
|
|
128
|
|
129 =head2 probe
|
|
130
|
|
131 Example : my $probe = $rf->probe();
|
|
132 Description: Getter of the probe attribute for ResultFeature
|
|
133 objects
|
|
134 Returntype : Bio::EnsEMBL::Funcgen::Probe
|
|
135 Exceptions : None
|
|
136 Caller : General
|
|
137 Status : At Risk - This can only be used for Features with window 0.
|
|
138
|
|
139 =cut
|
|
140
|
|
141 #probe_id is currently not available in the result_feature table, so this would be a result/probe_feature query.
|
|
142
|
|
143 sub probe {
|
|
144 return $_[0]->{probe};
|
|
145 }
|
|
146
|
|
147
|
|
148 sub result_set_id {
|
|
149 return $_[0]->{result_set_id};
|
|
150 }
|
|
151
|
|
152 sub window_size {
|
|
153 return $_[0]->{window_size};
|
|
154 }
|
|
155
|
|
156
|
|
157 sub get_min_max_scores{
|
|
158
|
|
159 if(! defined $_[0]->{'min_max_scores'}){
|
|
160 my @sorted_scores = sort { $a <=> $b } @{$_[0]->{'scores'}};
|
|
161 $_[0]->{'min_max_scores'} = [$sorted_scores[0], $sorted_scores[$#sorted_scores]];
|
|
162 }
|
|
163
|
|
164 return $_[0]->{'min_max_scores'};
|
|
165 }
|
|
166
|
|
167
|
|
168 1;
|
|
169
|