Bio/SeqFeature/Gene/GeneStructure.pm

filter: Statementstmt 64.9% 63 / 97 Branchbran 40.9% 9 / 22 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 72.2% 13 / 18 Podpod 92.3% 12 / 13 totaltotal 62.1% 100 / 161 CC 22 SCAR 19.6
CC
22
Cov
60%
add_transcript_as_features
30.0
add_transcript
6.1
promoters
6.0
CRAP 7.1
« Bio/Matrix/PSM/InstanceSite.pm ↑ Summary Bio/Location/Atomic.pm »
1 #
2 # BioPerl module for Bio::SeqFeature::Gene::GeneStructure
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Hilmar Lapp <hlapp@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  
16 Bio::SeqFeature::Gene::GeneStructure - A feature representing an arbitrarily complex structure of a gene
17  
18 =head1 SYNOPSIS
19  
20 # See documentation of methods.
21  
22 =head1 DESCRIPTION
23  
24 A feature representing a gene structure. As of now, a gene structure
25 really is only a collection of transcripts. See
26 L<Bio::SeqFeature::Gene::TranscriptI> (interface) and
27 L<Bio::SeqFeature::Gene::Transcript> (implementation) for the features
28 of such objects.
29  
30 =head1 FEEDBACK
31  
32 =head2 Mailing Lists
33  
34 User feedback is an integral part of the evolution of this and other
35 Bioperl modules. Send your comments and suggestions preferably to one
36 of the Bioperl mailing lists. Your participation is much appreciated.
37  
38 bioperl-l@bioperl.org - General discussion
39 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
40  
41 =head2 Support
42  
43 Please direct usage questions or support issues to the mailing list:
44  
45 I<bioperl-l@bioperl.org>
46  
47 rather than to the module maintainer directly. Many experienced and
48 reponsive experts will be able look at the problem and quickly
49 address it. Please include a thorough description of the problem
50 with code and data examples if at all possible.
51  
52 =head2 Reporting Bugs
53  
54 Report bugs to the Bioperl bug tracking system to help us keep track
55 the bugs and their resolution. Bug reports can be submitted via the
56 web:
57  
58 https://github.com/bioperl/bioperl-live/issues
59  
60 =head1 AUTHOR - Hilmar Lapp
61  
62 Email hlapp-at-gmx.net
63  
64 =head1 APPENDIX
65  
66 The rest of the documentation details each of the object
67 methods. Internal methods are usually preceded with a _
68  
69 =cut
70  
71  
72 # Let the code begin...
73  
74  
75 package Bio::SeqFeature::Gene::GeneStructure;
76 14 $Bio::SeqFeature::Gene::GeneStructure::VERSION = '1.7.8';
77 14 ▶use vars qw($WeakRefs);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 14 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.1
81 14 ▶ eval "use Scalar::Util qw(weaken);";
Subroutine BEGIN: called CC=1 SCAR=0.0
82 14 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 14 14
83 0 $Bio::SeqFeature::Gene::GeneStructure::WeakRefs = 0;
84 14 } else { $Bio::SeqFeature::Gene::GeneStructure::WeakRefs = 1; }
85 }
86  
87  
88 14 ▶use base qw(Bio::SeqFeature::Generic Bio::SeqFeature::Gene::GeneStructureI);
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90  
91 14 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
92 14 my ($caller, @args) = @_;
93 14 my $self = $caller->SUPER::new(@args);
94 14 $self->_register_for_cleanup(\&gene_cleanup);
95 14 my ($primary) =
96 $self->_rearrange([qw(PRIMARY
97 )],@args);
98
99 14 ▶ $primary = 'genestructure' unless $primary;
Branch: 1 branch
BranchTrueFalseTotal
unless $primary 13 1 14
100 14 $self->primary_tag($primary);
101 14 ▶ $self->strand(0) if(! defined($self->strand()));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->strand 13 1 14
102 14 return $self;
103 }
104  
105 =head2 transcripts
106  
107 Title : transcripts
108 Usage : @transcripts = $gene->transcripts();
109 Function: Get the transcripts of this gene structure. Many gene structures
110 will have only one transcript.
111  
112 Returns : An array of Bio::SeqFeature::Gene::TranscriptI implementing objects.
113 Args :
114  
115  
116 =cut
117  
118 18 ▶sub transcripts {
Subroutine transcripts: called CC=2 SCAR=7.2
Pod documented
119 18 ▶ return @{shift->{'_transcripts'} || []};
Condition50%1/2
+(shift())->{'_transcripts'} || []
l!l
180
MC/DC0%0/1
+(shift())->{'_transcripts'} || []
+(shift())->{'_transcripts'}
Truth table50%1/2
A
A= +(shift())->{'_transcripts'}
Aresult
11
00
120 }
121  
122 =head2 add_transcript
123  
124 Title : add_transcript()
125 Usage : $gene->add_transcript($transcript);
126 Function: Add a transcript to this gene structure.
127 Returns :
128 Args : A Bio::SeqFeature::Gene::TranscriptI implementing object.
129  
130  
131 =cut
132  
133 14 ▶sub add_transcript {
Subroutine add_transcript: called CC=5 SCAR=18.0
Pod documented
134 14 my ($self, $fea) = @_;
135  
136 14 ▶ if(!$fea || ! $fea->isa('Bio::SeqFeature::Gene::TranscriptI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fea and $fea->isa("Bio::SeqFeature::Gene::TranscriptI")) 0 14 14
Condition33%1/3
$fea and $fea->isa("Bio::SeqFeature::Gene::TranscriptI")
!ll&&!rl&&r
0014
MC/DC0%0/2
$fea and $fea->isa("Bio::SeqFeature::Gene::TranscriptI")
$fea $fea->isa("Bio::SeqFeature::Gene::TranscriptI")
Truth table33%1/3
A and B
A= $feaB= $fea->isa("Bio::SeqFeature::Gene::TranscriptI")
ABresult
0X0
100
111
137 0 $self->throw("$fea does not implement Bio::SeqFeature::Gene::TranscriptI");
138 }
139 14 ▶ unless( exists $self->{'_transcripts'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_transcripts"}) 14 0 14
140 14 $self->{'_transcripts'} = [];
141 }
142 14 $self->_expand_region($fea);
143 14 ▶ if( $Bio::SeqFeature::Gene::GeneStructure::WeakRefs ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::SeqFeature::Gene::GeneStructure::WeakRefs) { } 14 0 14
144 14 $fea->parent(weaken $self);
145 } else {
146 0 $fea->parent($self);
147 }
148 14 push(@{$self->{'_transcripts'}}, $fea);
149 }
150  
151 =head2 flush_transcripts
152  
153 Title : flush_transcripts()
154 Usage : $gene->flush_transcripts();
155 Function: Remove all transcripts from this gene structure.
156 Returns :
157 Args :
158  
159  
160 =cut
161  
162 14 ▶sub flush_transcripts {
Subroutine flush_transcripts: called CC=4 SCAR=14.0
Pod documented
163 14 my ($self) = @_;
164 14 ▶ if( defined $self->{'_transcripts'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_transcripts"}) 14 0 14
165 14 ▶ foreach my $t ( grep {defined} @{$self->{'_transcripts'} || []} ) {
Condition50%1/2
$self->{'_transcripts'} || []
l!l
140
MC/DC0%0/1
$self->{'_transcripts'} || []
$self->{'_transcripts'}
Truth table50%1/2
A
A= $self->{'_transcripts'}
Aresult
11
00
166 14 $t->parent(undef); # remove bkwds pointers
167 14 $t = undef;
168 }
169 14 delete($self->{'_transcripts'});
170 }
171 }
172  
173 =head2 add_transcript_as_features
174  
175 Title : add_transcript_as_features
176 Usage : $gene->add_transcript_as_features(@featurelist);
177 Function: take a list of Bio::SeqFeatureI objects and turn them into a
178 Bio::SeqFeature::Gene::Transcript object. Add that transcript to the gene.
179 Returns : nothing
180 Args : a list of Bio::SeqFeatureI compliant objects
181  
182  
183 =cut
184  
185 0 ▶sub add_transcript_as_features {
Subroutine add_transcript_as_features: not called CC=5 SCAR=34.0
Pod documented
186 0 my ($self,@features) = @_;
187 0 my $transcript=Bio::SeqFeature::Gene::Transcript->new;
188 0 foreach my $fea (@features) {
189 0 ▶ if ($fea->primary_tag =~ /utr/i) { #UTR / utr/ 3' utr / utr5 etc.
Branch: 3 branches
BranchTrueFalseTotal
if ($fea->primary_tag =~ /utr/i) { } 0 0 0
elsif ($fea->primary_tag =~ /promot/i) { } 0 0 0
elsif ($fea->primary_tag =~ /poly.*A/i) { } 0 0 0
190 0 $transcript->add_utr($fea);
191 } elsif ($fea->primary_tag =~ /promot/i) { #allow for spelling differences
192 0 $transcript->add_promoter($fea);
193 } elsif ($fea->primary_tag =~ /poly.*A/i) { #polyA, POLY_A, etc.
194 0 $transcript->poly_A_site($fea);
195 } else { #assume the rest are exons
196 0 $transcript->add_exon($fea);
197 }
198 }
199 0 $self->add_transcript($transcript);
200 }
201  
202  
203 =head2 promoters
204  
205 Title : promoters
206 Usage : @prom_sites = $gene->promoters();
207 Function: Get the promoter features of this gene structure.
208  
209 This method basically merges the promoters returned by transcripts.
210  
211 Note that OO-modeling of regulatory elements is not stable yet.
212 This means that this method might change or even disappear in a
213 future release. Be aware of this if you use it.
214  
215 Returns : An array of Bio::SeqFeatureI implementing objects.
216 Args :
217  
218  
219 =cut
220  
221 0 ▶sub promoters {
Subroutine promoters: not called CC=2 SCAR=17.9
Pod documented
222 0 my ($self) = @_;
223 0 my @transcripts = $self->transcripts();
224 0 my @feas = ();
225  
226 0 foreach my $tr (@transcripts) {
227 0 push(@feas, $tr->promoters());
228 }
229 0 return @feas;
230 }
231  
232  
233 =head2 exons
234  
235 Title : exons()
236 Usage : @exons = $gene->exons();
237 @inital_exons = $gene->exons('Initial');
238 Function: Get all exon features or all exons of a specified type of this gene
239 structure.
240  
241 Exon type is treated as a case-insensitive regular expression and
242 optional. For consistency, use only the following types:
243 initial, internal, terminal, utr, utr5prime, and utr3prime.
244 A special and virtual type is 'coding', which refers to all types
245 except utr.
246  
247 This method basically merges the exons returned by transcripts.
248  
249 Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects.
250 Args : An optional string specifying the type of exon.
251  
252  
253 =cut
254  
255 6 ▶sub exons {
Subroutine exons: called CC=2 SCAR=6.9
Pod documented
256 6 my ($self, @args) = @_;
257 6 my @transcripts = $self->transcripts();
258 6 my @feas = ();
259  
260 6 foreach my $tr (@transcripts) {
261 6 push(@feas, $tr->exons(@args));
262 }
263 6 return @feas;
264 }
265  
266 =head2 introns
267  
268 Title : introns()
269 Usage : @introns = $gene->introns();
270 Function: Get all introns of this gene structure.
271  
272 Note that this class currently generates these features on-the-fly,
273 that is, it simply treats all regions between exons as introns.
274 It assumes that the exons in the transcripts do not overlap.
275  
276 This method basically merges the introns returned by transcripts.
277  
278 Returns : An array of Bio::SeqFeatureI implementing objects.
279 Args :
280  
281  
282 =cut
283  
284 0 ▶sub introns {
Subroutine introns: not called CC=2 SCAR=17.9
Pod documented
285 0 my ($self) = @_;
286 0 my @transcripts = $self->transcripts();
287 0 my @feas = ();
288  
289 0 foreach my $tr (@transcripts) {
290 0 push(@feas, $tr->introns());
291 }
292 0 return @feas;
293 }
294  
295 =head2 poly_A_sites
296  
297 Title : poly_A_sites()
298 Usage : @polyAsites = $gene->poly_A_sites();
299 Function: Get the poly-adenylation sites of this gene structure.
300  
301 This method basically merges the poly-adenylation sites returned by
302 transcripts.
303  
304 Returns : An array of Bio::SeqFeatureI implementing objects.
305 Args :
306  
307  
308 =cut
309  
310 0 ▶sub poly_A_sites {
Subroutine poly_A_sites: not called CC=2 SCAR=17.9
Pod documented
311 0 my ($self) = @_;
312 0 my @transcripts = $self->transcripts();
313 0 my @feas = ();
314  
315 0 foreach my $tr (@transcripts) {
316 0 push(@feas, $tr->poly_A_site());
317 }
318 0 return @feas;
319 }
320  
321 =head2 utrs
322  
323 Title : utrs()
324 Usage : @utr_sites = $gene->utrs('3prime');
325 @utr_sites = $gene->utrs('5prime');
326 @utr_sites = $gene->utrs();
327 Function: Get the features representing untranslated regions (UTR) of this
328 gene structure.
329  
330 You may provide an argument specifying the type of UTR. Currently
331 the following types are recognized: 5prime 3prime for UTR on the
332 5' and 3' end of the CDS, respectively.
333  
334 This method basically merges the UTRs returned by transcripts.
335  
336 Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects
337 representing the UTR regions or sites.
338 Args : Optionally, either 3prime, or 5prime for the the type of UTR
339 feature.
340  
341  
342 =cut
343  
344 1 ▶sub utrs {
Subroutine utrs: called CC=2 SCAR=6.9
Pod documented
345 1 my ($self,@args) = @_;
346 1 my @transcripts = $self->transcripts();
347 1 my @feas = ();
348  
349 1 foreach my $tr (@transcripts) {
350 1 push(@feas, $tr->utrs(@args));
351 }
352 1 return @feas;
353 }
354  
355 =head2 sub_SeqFeature
356  
357 Title : sub_SeqFeature
358 Usage : @feats = $gene->sub_SeqFeature();
359 Function: Returns an array of all subfeatures.
360  
361 This method is defined in Bio::SeqFeatureI. We override this here
362 to include the transcripts.
363  
364 Returns : An array Bio::SeqFeatureI implementing objects.
365 Args : none
366  
367  
368 =cut
369  
370 1 ▶sub sub_SeqFeature {
Subroutine sub_SeqFeature: called CC=1 SCAR=0.0
Pod documented
371 1 my ($self) = @_;
372 1 my @feas = ();
373  
374 # get what the parent already has
375 1 @feas = $self->SUPER::sub_SeqFeature();
376 1 push(@feas, $self->transcripts());
377 1 return @feas;
378 }
379  
380 =head2 flush_sub_SeqFeature
381  
382 Title : flush_sub_SeqFeature
383 Usage : $gene->flush_sub_SeqFeature();
384 $gene->flush_sub_SeqFeature(1);
385 Function: Removes all subfeatures.
386  
387 This method is overridden from Bio::SeqFeature::Generic to flush
388 all additional subfeatures, i.e., transcripts, which is
389 almost certainly not what you want. To remove only features added
390 through $gene->add_sub_SeqFeature($feature) pass any
391 argument evaluating to TRUE.
392  
393 Example :
394 Returns : none
395 Args : Optionally, an argument evaluating to TRUE will suppress flushing
396 of all gene structure-specific subfeatures (transcripts).
397  
398  
399 =cut
400  
401 0 ▶sub flush_sub_SeqFeature {
Subroutine flush_sub_SeqFeature: not called CC=2 SCAR=17.9
Pod documented
402 0 my ($self,$fea_only) = @_;
403  
404 0 $self->SUPER::flush_sub_SeqFeature();
405 0 ▶ if(! $fea_only) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $fea_only) 0 0 0
406 0 $self->flush_transcripts();
407 }
408 }
409  
410 14 ▶sub gene_cleanup {
Subroutine gene_cleanup: called CC=1 SCAR=0.0
Pod undocumented
411 14 my $self = shift;
412 14 $self->flush_transcripts;
413 }
414  
415 14 1;
416  
417  
418  
419  
« Bio/Matrix/PSM/InstanceSite.pm ↑ Summary Bio/Location/Atomic.pm »