| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# BioPerl module for Bio::FeatureHolderI |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Cared for by Hilmar Lapp |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Copyright Hilmar Lapp |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Bio::FeatureHolderI - the base interface an object with features must implement |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Bio::SeqIO; |
|
21
|
|
|
|
|
|
|
# get a feature-holding object somehow: for example, Bio::SeqI objects |
|
22
|
|
|
|
|
|
|
# have features |
|
23
|
|
|
|
|
|
|
my $seqio = Bio::SeqIO->new(-fh => \*STDIN, -format => 'genbank'); |
|
24
|
|
|
|
|
|
|
while (my $seq = $seqio->next_seq()) { |
|
25
|
|
|
|
|
|
|
# $seq is-a Bio::FeatureHolderI, hence: |
|
26
|
|
|
|
|
|
|
my @feas = $seq->get_SeqFeatures(); |
|
27
|
|
|
|
|
|
|
# each element is-a Bio::SeqFeatureI |
|
28
|
|
|
|
|
|
|
foreach my $fea (@feas) { |
|
29
|
|
|
|
|
|
|
# do something with the feature objects |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This is the base interface that all feature-holding objects must |
|
36
|
|
|
|
|
|
|
implement. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Popular feature-holders are for instance L objects. Since |
|
39
|
|
|
|
|
|
|
L defines a sub_SeqFeature() method, most |
|
40
|
|
|
|
|
|
|
Bio::SeqFeatureI implementations like L will |
|
41
|
|
|
|
|
|
|
implement the feature holder interface as well. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 FEEDBACK |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 Mailing Lists |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
|
48
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to |
|
49
|
|
|
|
|
|
|
the Bioperl mailing list. Your participation is much appreciated. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
|
52
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 Support |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
I |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
|
61
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
|
62
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
|
63
|
|
|
|
|
|
|
with code and data examples if at all possible. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 Reporting Bugs |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
|
68
|
|
|
|
|
|
|
of the bugs and their resolution. Bug reports can be submitted via the |
|
69
|
|
|
|
|
|
|
web: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
https://github.com/bioperl/bioperl-live/issues |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR - Hilmar Lapp |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Email hlapp at gmx.net |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Steffen Grossmann [SG], grossman-at-molgen.mpg.de |
|
80
|
|
|
|
|
|
|
Mark A. Jensen, maj -at- fortinbras -dot- us |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 APPENDIX |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. |
|
85
|
|
|
|
|
|
|
Internal methods are usually preceded with a _ |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Let the code begin... |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package Bio::FeatureHolderI; |
|
95
|
181
|
|
|
181
|
|
847
|
use strict; |
|
|
181
|
|
|
|
|
303
|
|
|
|
181
|
|
|
|
|
4052
|
|
|
96
|
181
|
|
|
181
|
|
630
|
use Carp; |
|
|
181
|
|
|
|
|
256
|
|
|
|
181
|
|
|
|
|
10061
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
181
|
|
|
181
|
|
671
|
use base qw(Bio::Root::RootI); |
|
|
181
|
|
|
|
|
363
|
|
|
|
181
|
|
|
|
|
60470
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 get_SeqFeatures() |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Usage : @feats = $obj->get_SeqFeatures() |
|
103
|
|
|
|
|
|
|
Function: Get the feature objects held by this feature holder. |
|
104
|
|
|
|
|
|
|
Example : |
|
105
|
|
|
|
|
|
|
Returns : an array of Bio::SeqFeatureI implementing objects |
|
106
|
|
|
|
|
|
|
if tag specified, return features having that tag |
|
107
|
|
|
|
|
|
|
Args : [optional] scalar string (feature tag) |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_SeqFeatures { |
|
112
|
0
|
|
|
0
|
1
|
0
|
shift->throw_not_implemented(); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 add_SeqFeature() |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Usage : $feat->add_SeqFeature($subfeat); |
|
118
|
|
|
|
|
|
|
$feat->add_SeqFeature($subfeat,'EXPAND') |
|
119
|
|
|
|
|
|
|
Function: Add a SeqFeature into the subSeqFeature array. |
|
120
|
|
|
|
|
|
|
with no 'EXPAND' qualifer, subfeat will be tested |
|
121
|
|
|
|
|
|
|
as to whether it lies inside the parent, and throw |
|
122
|
|
|
|
|
|
|
an exception if not. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
If EXPAND is used and the object implements Bio::RangeI |
|
125
|
|
|
|
|
|
|
(which is not guaranteed), the parent''s start/end/strand |
|
126
|
|
|
|
|
|
|
will be extended so that the new subFeature can be accomodated. |
|
127
|
|
|
|
|
|
|
Example : |
|
128
|
|
|
|
|
|
|
Returns : nothing |
|
129
|
|
|
|
|
|
|
Args : a Bio::SeqFeatureI object |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub add_SeqFeature { |
|
134
|
0
|
|
|
0
|
1
|
0
|
shift->throw_not_implemented(); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 remove_SeqFeatures() |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Usage : $obj->remove_SeqFeatures |
|
141
|
|
|
|
|
|
|
Function: Removes all sub SeqFeatures. If you want to remove only a subset, |
|
142
|
|
|
|
|
|
|
remove that subset from the returned array, and add back the rest. |
|
143
|
|
|
|
|
|
|
Returns : The array of Bio::SeqFeatureI implementing sub-features that was |
|
144
|
|
|
|
|
|
|
deleted from this feature. |
|
145
|
|
|
|
|
|
|
Args : none |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub remove_SeqFeatures { |
|
150
|
0
|
|
|
0
|
1
|
0
|
shift->throw_not_implemented(); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 feature_count |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Title : feature_count |
|
156
|
|
|
|
|
|
|
Usage : $obj->feature_count() |
|
157
|
|
|
|
|
|
|
Function: Return the number of SeqFeatures attached to a feature holder. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is before flattening a possible sub-feature tree. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
We provide a default implementation here that just counts |
|
162
|
|
|
|
|
|
|
the number of objects returned by get_SeqFeatures(). |
|
163
|
|
|
|
|
|
|
Implementors may want to override this with a more |
|
164
|
|
|
|
|
|
|
efficient implementation. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Returns : integer representing the number of SeqFeatures |
|
167
|
|
|
|
|
|
|
Args : None |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
At some day we may want to expand this method to allow for a feature |
|
170
|
|
|
|
|
|
|
filter to be passed in. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Our default implementation allows for any number of additional |
|
173
|
|
|
|
|
|
|
arguments and will pass them on to get_SeqFeatures(). I.e., in order to |
|
174
|
|
|
|
|
|
|
support filter arguments, just support them in get_SeqFeatures(). |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub feature_count { |
|
179
|
0
|
|
|
0
|
1
|
0
|
return scalar(shift->get_SeqFeatures(@_)); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 get_all_SeqFeatures |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Title : get_all_SeqFeatures |
|
185
|
|
|
|
|
|
|
Usage : |
|
186
|
|
|
|
|
|
|
Function: Get the flattened tree of feature objects held by this |
|
187
|
|
|
|
|
|
|
feature holder. The difference to get_SeqFeatures is that |
|
188
|
|
|
|
|
|
|
the entire tree of sub-features will be flattened out. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
We provide a default implementation here, so implementors |
|
191
|
|
|
|
|
|
|
don''t necessarily need to implement this method. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Example : |
|
194
|
|
|
|
|
|
|
Returns : an array of Bio::SeqFeatureI implementing objects |
|
195
|
|
|
|
|
|
|
Args : none |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
At some day we may want to expand this method to allow for a feature |
|
198
|
|
|
|
|
|
|
filter to be passed in. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Our default implementation allows for any number of additional |
|
201
|
|
|
|
|
|
|
arguments and will pass them on to any invocation of |
|
202
|
|
|
|
|
|
|
get_SeqFeatures(), wherever a component of the tree implements |
|
203
|
|
|
|
|
|
|
FeatureHolderI. I.e., in order to support filter arguments, just |
|
204
|
|
|
|
|
|
|
support them in get_SeqFeatures(). |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub get_all_SeqFeatures{ |
|
209
|
2126
|
|
|
2126
|
1
|
3892
|
my $self = shift; |
|
210
|
2126
|
|
|
|
|
1752
|
my @flatarr; |
|
211
|
|
|
|
|
|
|
|
|
212
|
2126
|
|
|
|
|
3602
|
foreach my $feat ( $self->get_SeqFeatures(@_) ){ |
|
213
|
8767
|
|
|
|
|
6425
|
push(@flatarr,$feat); |
|
214
|
8767
|
|
|
|
|
9401
|
&_add_flattened_SeqFeatures(\@flatarr,$feat,@_); |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# needed to deal with subfeatures which appear more than once in the hierarchy [SG] |
|
218
|
2126
|
|
|
|
|
3385
|
my %seen = (); |
|
219
|
2126
|
|
|
|
|
2165
|
my @uniq_flatarr = (); |
|
220
|
2126
|
|
|
|
|
2226
|
foreach my $feat (@flatarr) { |
|
221
|
10782
|
100
|
|
|
|
27519
|
push(@uniq_flatarr, $feat) unless $seen{$feat}++; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
2126
|
|
|
|
|
17416
|
return @uniq_flatarr; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub _add_flattened_SeqFeatures { |
|
227
|
10782
|
|
|
10782
|
|
7852
|
my ($arrayref,$feat,@args) = @_; |
|
228
|
10782
|
|
|
|
|
7856
|
my @subs = (); |
|
229
|
|
|
|
|
|
|
|
|
230
|
10782
|
50
|
|
|
|
16144
|
if($feat->isa("Bio::FeatureHolderI")) { |
|
|
|
0
|
|
|
|
|
|
|
231
|
10782
|
|
|
|
|
12156
|
@subs = $feat->get_SeqFeatures(@args); |
|
232
|
|
|
|
|
|
|
} elsif($feat->isa("Bio::SeqFeatureI")) { |
|
233
|
0
|
|
|
|
|
0
|
@subs = $feat->sub_SeqFeature(); |
|
234
|
|
|
|
|
|
|
} else { |
|
235
|
0
|
|
|
|
|
0
|
confess ref($feat)." is neither a FeatureHolderI nor a SeqFeatureI. ". |
|
236
|
|
|
|
|
|
|
"Don't know how to flatten."; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
10782
|
|
|
|
|
14604
|
foreach my $sub (@subs) { |
|
239
|
2015
|
|
|
|
|
1925
|
push(@$arrayref,$sub); |
|
240
|
2015
|
|
|
|
|
2310
|
&_add_flattened_SeqFeatures($arrayref,$sub); |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub set_ParentIDs_from_hierarchy(){ |
|
246
|
|
|
|
|
|
|
# DEPRECATED - use IDHandler |
|
247
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
248
|
0
|
|
|
|
|
|
require "Bio/SeqFeature/Tools/IDHandler.pm"; |
|
249
|
0
|
|
|
|
|
|
Bio::SeqFeature::Tools::IDHandler->new->set_ParentIDs_from_hierarchy($self); |
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub create_hierarchy_from_ParentIDs(){ |
|
253
|
|
|
|
|
|
|
# DEPRECATED - use IDHandler |
|
254
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
255
|
0
|
|
|
|
|
|
require "Bio/SeqFeature/Tools/IDHandler.pm"; |
|
256
|
0
|
|
|
|
|
|
Bio::SeqFeature::Tools::IDHandler->new->create_hierarchy_from_ParentIDs($self); |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
1; |