← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:46:12 2015

Filename/Users/ap13/perl5/lib/perl5/Bio/FeatureHolderI.pm
StatementsExecuted 7 statements in 402µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs23µsBio::FeatureHolderI::::BEGIN@95Bio::FeatureHolderI::BEGIN@95
1118µs46µsBio::FeatureHolderI::::BEGIN@96Bio::FeatureHolderI::BEGIN@96
1118µs56µsBio::FeatureHolderI::::BEGIN@98Bio::FeatureHolderI::BEGIN@98
0000s0sBio::FeatureHolderI::::_add_flattened_SeqFeaturesBio::FeatureHolderI::_add_flattened_SeqFeatures
0000s0sBio::FeatureHolderI::::add_SeqFeatureBio::FeatureHolderI::add_SeqFeature
0000s0sBio::FeatureHolderI::::create_hierarchy_from_ParentIDsBio::FeatureHolderI::create_hierarchy_from_ParentIDs
0000s0sBio::FeatureHolderI::::feature_countBio::FeatureHolderI::feature_count
0000s0sBio::FeatureHolderI::::get_SeqFeaturesBio::FeatureHolderI::get_SeqFeatures
0000s0sBio::FeatureHolderI::::get_all_SeqFeaturesBio::FeatureHolderI::get_all_SeqFeatures
0000s0sBio::FeatureHolderI::::remove_SeqFeaturesBio::FeatureHolderI::remove_SeqFeatures
0000s0sBio::FeatureHolderI::::set_ParentIDs_from_hierarchyBio::FeatureHolderI::set_ParentIDs_from_hierarchy
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#
2# BioPerl module for Bio::FeatureHolderI
3#
4# Please direct questions and support issues to <bioperl-l@bioperl.org>
5#
6# Cared for by Hilmar Lapp <hlapp at gmx.net>
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
16Bio::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
35This is the base interface that all feature-holding objects must
36implement.
37
38Popular feature-holders are for instance L<Bio::Seq> objects. Since
39L<Bio::SeqFeatureI> defines a sub_SeqFeature() method, most
40Bio::SeqFeatureI implementations like L<Bio::SeqFeature::Generic> will
41implement the feature holder interface as well.
42
43=head1 FEEDBACK
44
45=head2 Mailing Lists
46
47User feedback is an integral part of the evolution of this and other
48Bioperl modules. Send your comments and suggestions preferably to
49the 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
56Please direct usage questions or support issues to the mailing list:
57
58I<bioperl-l@bioperl.org>
59
60rather than to the module maintainer directly. Many experienced and
61reponsive experts will be able look at the problem and quickly
62address it. Please include a thorough description of the problem
63with code and data examples if at all possible.
64
65=head2 Reporting Bugs
66
67Report bugs to the Bioperl bug tracking system to help us keep track
68of the bugs and their resolution. Bug reports can be submitted via the
69web:
70
71 https://github.com/bioperl/bioperl-live/issues
72
73=head1 AUTHOR - Hilmar Lapp
74
75Email hlapp at gmx.net
76
77=head1 CONTRIBUTORS
78
79Steffen Grossmann [SG], grossman-at-molgen.mpg.de
80Mark A. Jensen, maj -at- fortinbras -dot- us
81
82=head1 APPENDIX
83
84The rest of the documentation details each of the object methods.
85Internal methods are usually preceded with a _
86
87=cut
88
89
90# Let the code begin...
91
- -
94package Bio::FeatureHolderI;
95222µs235µs
# spent 23µs (12+12) within Bio::FeatureHolderI::BEGIN@95 which was called: # once (12µs+12µs) by base::import at line 95
use strict;
# spent 23µs making 1 call to Bio::FeatureHolderI::BEGIN@95 # spent 12µs making 1 call to strict::import
96223µs283µs
# spent 46µs (8+38) within Bio::FeatureHolderI::BEGIN@96 which was called: # once (8µs+38µs) by base::import at line 96
use Carp;
# spent 46µs making 1 call to Bio::FeatureHolderI::BEGIN@96 # spent 38µs making 1 call to Exporter::import
97
982355µs256µs
# spent 56µs (8+48) within Bio::FeatureHolderI::BEGIN@98 which was called: # once (8µs+48µs) by base::import at line 98
use base qw(Bio::Root::RootI);
# spent 56µs making 1 call to Bio::FeatureHolderI::BEGIN@98 # spent 48µs making 1 call to base::import, recursion: max depth 3, sum of overlapping time 48µs
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
111sub get_SeqFeatures {
112 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
133sub add_SeqFeature {
134 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
149sub remove_SeqFeatures {
150 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
169At some day we may want to expand this method to allow for a feature
170filter to be passed in.
171
172Our default implementation allows for any number of additional
173arguments and will pass them on to get_SeqFeatures(). I.e., in order to
174support filter arguments, just support them in get_SeqFeatures().
175
176=cut
177
178sub feature_count {
179 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
197At some day we may want to expand this method to allow for a feature
198filter to be passed in.
199
200Our default implementation allows for any number of additional
201arguments and will pass them on to any invocation of
202get_SeqFeatures(), wherever a component of the tree implements
203FeatureHolderI. I.e., in order to support filter arguments, just
204support them in get_SeqFeatures().
205
206=cut
207
208sub get_all_SeqFeatures{
209 my $self = shift;
210 my @flatarr;
211
212 foreach my $feat ( $self->get_SeqFeatures(@_) ){
213 push(@flatarr,$feat);
214 &_add_flattened_SeqFeatures(\@flatarr,$feat,@_);
215 }
216
217 # needed to deal with subfeatures which appear more than once in the hierarchy [SG]
218 my %seen = ();
219 my @uniq_flatarr = ();
220 foreach my $feat (@flatarr) {
221 push(@uniq_flatarr, $feat) unless $seen{$feat}++;
222 }
223 return @uniq_flatarr;
224}
225
226sub _add_flattened_SeqFeatures {
227 my ($arrayref,$feat,@args) = @_;
228 my @subs = ();
229
230 if($feat->isa("Bio::FeatureHolderI")) {
231 @subs = $feat->get_SeqFeatures(@args);
232 } elsif($feat->isa("Bio::SeqFeatureI")) {
233 @subs = $feat->sub_SeqFeature();
234 } else {
235 confess ref($feat)." is neither a FeatureHolderI nor a SeqFeatureI. ".
236 "Don't know how to flatten.";
237 }
238 foreach my $sub (@subs) {
239 push(@$arrayref,$sub);
240 &_add_flattened_SeqFeatures($arrayref,$sub);
241 }
242
243}
244
245sub set_ParentIDs_from_hierarchy(){
246 # DEPRECATED - use IDHandler
247 my $self = shift;
248 require "Bio/SeqFeature/Tools/IDHandler.pm";
249 Bio::SeqFeature::Tools::IDHandler->new->set_ParentIDs_from_hierarchy($self);
250}
251
252sub create_hierarchy_from_ParentIDs(){
253 # DEPRECATED - use IDHandler
254 my $self = shift;
255 require "Bio/SeqFeature/Tools/IDHandler.pm";
256 Bio::SeqFeature::Tools::IDHandler->new->create_hierarchy_from_ParentIDs($self);
257}
258
- -
26112µs1;