Bio/SeqFeature/Gene/Transcript.pm

filter: Statementstmt 74.1% 166 / 224 Branchbran 59.5% 50 / 84 Conditioncond 56.2% 27 / 48 MC/DCmcdc 41.3% 12 / 29 Subroutinesub 75.0% 24 / 32 Podpod 86.9% 20 / 23 totaltotal 67.9% 299 / 440 CC 69 SCAR 22.9
CC
69
Cov
68%
_flush
42.0
introns
16.1
_make_cds
14.3
CRAP 9.9
« Bio/Tools/Genscan.pm ↑ Summary Bio/SearchIO/axt.pm »
1 #
2 # BioPerl module for Bio::SeqFeature::Gene::Transcript
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::Transcript - A feature representing a transcript
17  
18 =head1 SYNOPSIS
19  
20 # See documentation of methods.
21  
22 =head1 DESCRIPTION
23  
24 A feature representing a transcript.
25  
26 =head1 FEEDBACK
27  
28 =head2 Mailing Lists
29  
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to one
32 of the Bioperl mailing lists. Your participation is much appreciated.
33  
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
36  
37 =head2 Support
38  
39 Please direct usage questions or support issues to the mailing list:
40  
41 I<bioperl-l@bioperl.org>
42  
43 rather than to the module maintainer directly. Many experienced and
44 reponsive experts will be able look at the problem and quickly
45 address it. Please include a thorough description of the problem
46 with code and data examples if at all possible.
47  
48 =head2 Reporting Bugs
49  
50 Report bugs to the Bioperl bug tracking system to help us keep track
51 the bugs and their resolution. Bug reports can be submitted via the
52 web:
53  
54 https://github.com/bioperl/bioperl-live/issues
55  
56 =head1 AUTHOR - Hilmar Lapp
57  
58 Email hlapp@gmx.net
59  
60 =head1 APPENDIX
61  
62 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
63  
64 =cut
65  
66  
67 # Let the code begin...
68  
69 package Bio::SeqFeature::Gene::Transcript;
70 24 $Bio::SeqFeature::Gene::Transcript::VERSION = '1.7.8';
71 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
72  
73  
74 24 ▶use Bio::PrimarySeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 24 ▶use base qw(Bio::SeqFeature::Generic Bio::SeqFeature::Gene::TranscriptI);
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 96 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
79 96 my ($caller, @args) = @_;
80 96 my $self = $caller->SUPER::new(@args);
81 96 $self->_register_for_cleanup(\&transcript_destroy);
82 96 my ($primary) = $self->_rearrange([qw(PRIMARY)],@args);
83  
84 96 ▶ $primary = 'transcript' unless $primary;
Branch: 1 branch
BranchTrueFalseTotal
unless $primary 67 29 96
85 96 $self->primary_tag($primary);
86 96 ▶ $self->strand(0) if(! defined($self->strand()));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->strand 96 0 96
87 96 return $self;
88 }
89  
90  
91 =head2 promoters
92  
93 Title : promoters()
94 Usage : @proms = $transcript->promoters();
95 Function: Get the promoter features/sites of this transcript.
96  
97 Note that OO-modeling of regulatory elements is not stable yet.
98 This means that this method might change or even disappear in a
99 future release. Be aware of this if you use it.
100  
101 Returns : An array of Bio::SeqFeatureI implementing objects representing the
102 promoter regions or sites.
103 Args :
104  
105  
106 =cut
107  
108 9 ▶sub promoters {
Subroutine promoters: called CC=1 SCAR=0.0
Pod documented
109 9 my ($self) = @_;
110 9 return $self->get_feature_type('Bio::SeqFeature::Gene::Promoter');
111 }
112  
113 =head2 add_promoter
114  
115 Title : add_promoter()
116 Usage : $transcript->add_promoter($feature);
117 Function: Add a promoter feature/site to this transcript.
118  
119  
120 Note that OO-modeling of regulatory elements is not stable yet.
121 This means that this method might change or even disappear in a
122 future release. Be aware of this if you use it.
123  
124 Returns :
125 Args : A Bio::SeqFeatureI implementing object.
126  
127  
128 =cut
129  
130 9 ▶sub add_promoter {
Subroutine add_promoter: called CC=1 SCAR=0.0
Pod documented
131 9 my ($self, $fea) = @_;
132 9 $self->_add($fea,'Bio::SeqFeature::Gene::Promoter');
133 }
134  
135 =head2 flush_promoters
136  
137 Title : flush_promoters()
138 Usage : $transcript->flush_promoters();
139 Function: Remove all promoter features/sites from this transcript.
140  
141 Note that OO-modeling of regulatory elements is not stable yet.
142 This means that this method might change or even disappear in a
143 future release. Be aware of this if you use it.
144  
145 Returns : the removed features as a list
146 Args : none
147  
148  
149 =cut
150  
151 0 ▶sub flush_promoters {
Subroutine flush_promoters: not called CC=1 SCAR=6.9
Pod documented
152 0 my ($self) = @_;
153 0 return $self->_flush('Bio::SeqFeature::Gene::Promoter');
154 }
155  
156 =head2 exons
157  
158 Title : exons()
159 Usage : @exons = $gene->exons();
160 ($inital_exon) = $gene->exons('Initial');
161 Function: Get all exon features or all exons of specified type of this
162 transcript.
163  
164 Exon type is treated as a case-insensitive regular expression and
165 is optional. For consistency, use only the following types:
166 initial, internal, terminal.
167  
168 Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects.
169 Args : An optional string specifying the primary_tag of the feature.
170  
171  
172 =cut
173  
174 111 ▶sub exons {
Subroutine exons: called CC=1 SCAR=0.0
Pod documented
175 111 my ($self, $type) = @_;
176 111 return $self->get_unordered_feature_type('Bio::SeqFeature::Gene::ExonI',
177 $type);
178 }
179  
180 =head2 exons_ordered
181  
182 Title : exons_ordered
183 Usage : @exons = $gene->exons_ordered();
184 @exons = $gene->exons_ordered("Internal");
185 Function: Get an ordered list of all exon features or all exons of specified
186 type of this transcript.
187  
188 Exon type is treated as a case-insensitive regular expression and
189 is optional. For consistency, use only the following types:
190  
191 Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects.
192 Args : An optional string specifying the primary_tag of the feature.
193  
194 =cut
195  
196 4 ▶sub exons_ordered {
Subroutine exons_ordered: called CC=1 SCAR=0.0
Pod documented
197 4 my ($self,$type) = @_;
198 4 return $self->get_feature_type('Bio::SeqFeature::Gene::ExonI', $type);
199 }
200  
201 =head2 add_exon
202  
203 Title : add_exon()
204 Usage : $transcript->add_exon($exon,'initial');
205 Function: Add a exon feature to this transcript.
206  
207 The second argument denotes the type of exon. Mixing exons with and
208 without a type is likely to cause trouble in exons(). Either
209 leave out the type for all exons or for none.
210  
211 Presently, the following types are known: initial, internal,
212 terminal, utr, utr5prime, and utr3prime (all case-insensitive).
213 UTR should better be added through utrs()/add_utr().
214  
215 If you wish to use other or additional types, you will almost
216 certainly have to call exon_type_sortorder() in order to replace
217 the default sort order, or mrna(), cds(), protein(), and exons()
218 may yield unexpected results.
219  
220 Returns :
221 Args : A Bio::SeqFeature::Gene::ExonI implementing object.
222 A string indicating the type of the exon (optional).
223  
224  
225 =cut
226  
227 509 ▶sub add_exon {
Subroutine add_exon: called CC=2 SCAR=7.6
Pod documented
228 509 my ($self, $fea, $type) = @_;
229 509 ▶ if(! $fea->isa('Bio::SeqFeature::Gene::ExonI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fea->isa("Bio::SeqFeature::Gene::ExonI")) 0 509 509
230 0 $self->throw("$fea does not implement Bio::SeqFeature::Gene::ExonI");
231 }
232 509 $self->_add($fea,'Bio::SeqFeature::Gene::Exon', $type);
233 }
234  
235 =head2 flush_exons
236  
237 Title : flush_exons()
238 Usage : $transcript->flush_exons();
239 $transcript->flush_exons('terminal');
240 Function: Remove all or a certain type of exon features from this transcript.
241  
242 See add_exon() for documentation about types.
243  
244 Calling without a type will not flush UTRs. Call flush_utrs() for
245 this purpose.
246 Returns : the deleted features as a list
247 Args : A string indicating the type of the exon (optional).
248  
249  
250 =cut
251  
252 0 ▶sub flush_exons {
Subroutine flush_exons: not called CC=1 SCAR=6.9
Pod documented
253 0 my ($self, $type) = @_;
254 0 return $self->_flush('Bio::SeqFeature::Gene::Exon',$type);
255 }
256  
257 =head2 introns
258  
259 Title : introns()
260 Usage : @introns = $gene->introns();
261 Function: Get all intron features this gene structure.
262  
263 Note that this implementation generates these features
264 on-the-fly, that is, it simply treats all regions between
265 exons as introns, assuming that exons do not overlap. A
266 consequence is that a consistent correspondence between the
267 elements in the returned array and the array that exons()
268 returns will exist only if the exons are properly sorted
269 within their types (forward for plus- strand and reverse
270 for minus-strand transcripts). To ensure correctness the
271 elements in the array returned will always be sorted.
272  
273 Returns : An array of Bio::SeqFeature::Gene::Intron objects representing
274 the intron regions.
275 Args :
276  
277  
278 =cut
279  
280 1 ▶sub introns {
Subroutine introns: called CC=12 SCAR=27.8
Pod documented
281 1 my ($self) = @_;
282 1 my @introns = ();
283 1 my @exons = $self->exons();
284 1 my ($strand, $rev_order);
285  
286 # if there's 1 or less exons we're done
287 1 ▶ return () unless($#exons > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $#exons > 0 0 1 1
288 # record strand and order (a minus-strand transcript is likely to have
289 # the exons stacked in reverse order)
290 1 foreach my $exon (@exons) {
291 1 $strand = $exon->strand();
292 1 ▶ last if $strand; # we're done if we've got 1 or -1
Branch: 1 branch
BranchTrueFalseTotal
if $strand 1 0 1
293 }
294 1 ▶ $rev_order = ($exons[0]->end() < $exons[1]->start() ? 0 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$exons[0]->end < $exons[1]->start ? : 1 0 1
295  
296 # Make sure exons are sorted. Because we assume they don't overlap, we
297 # simply sort by start position.
298 1 ▶ if((! defined($strand)) || ($strand != -1) || (! $rev_order)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $strand or $strand != -1 or not $rev_order) { } 1 0 1
Condition33%2/6
not defined $strand or $strand != -1 or not $rev_order
l!l&&r!l&&!r
100
not defined $strand or $strand != -1
l!l&&r!l&&!r
010
MC/DC0%0/3
not defined $strand or $strand != -1 or not $rev_order
not defined $strand $strand != -1 not $rev_order
Truth table25%1/4
not(A) or B or not(C)
A= not defined $strandB= $strand != -1C= not $rev_order
ABCresult
1XX1
01X1
0011
0000
299 # always sort forward for plus-strand transcripts, and for negative-
300 # strand transcripts that appear to be unsorted or forward sorted
301 4 @exons = map { $_->[0] } sort { $a->[1] <=> $b->[1] }
302 1 ▶ map { [ $_, $_->start * ($_->strand || 1)] } @exons;
Condition50%1/2
$_->strand || 1
l!l
40
MC/DC0%0/1
$_->strand || 1
$_->strand
Truth table50%1/2
A
A= $_->strand
Aresult
11
00
303 } else {
304 # sort in reverse order for transcripts on the negative strand and
305 # found to be in reverse order
306 0 @exons = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_, $_->start()] } @exons;
307 }
308 # loop over all intervening gaps
309 1 ▶ while ((my $exonA = shift (@exons)) &&(my $exonB = shift(@exons))){
Branch: 1 branch
BranchTrueFalseTotal
if (my $exonA = shift @exons and my $exonB = shift @exons) 3 1 4
Condition66%2/3
my $exonA = shift @exons and my $exonB = shift @exons
!ll&&!rl&&r
013
MC/DC50%1/2
my $exonA = shift @exons and my $exonB = shift @exons
my $exonA = shift @exons my $exonB = shift @exons
Truth table66%2/3
A and B
A= my $exonA = shift @exonsB= my $exonB = shift @exons
ABresult
0X0
100
111
310 3 my $intron = Bio::SeqFeature::Gene::Intron->new(-primary=>'intron');
311 3 $intron->upstream_Exon($exonA);
312 3 $intron->downstream_Exon($exonB);
313 3 ▶ $intron->attach_seq($self->entire_seq) if $self->entire_seq;
Branch: 1 branch
BranchTrueFalseTotal
if $self->entire_seq 0 3 3
314 3 unshift(@exons,$exonB);
315 3 push @introns,$intron;
316 }
317 1 return @introns;
318 }
319  
320 =head2 poly_A_site
321  
322 Title : poly_A_site()
323 Usage : $polyAsite = $transcript->poly_A_site();
324 Function: Get/set the poly-adenylation feature/site of this transcript.
325 Returns : A Bio::SeqFeatureI implementing object representing the
326 poly-adenylation region.
327 Args : A Bio::SeqFeatureI implementing object on set, or FALSE to flush
328 a previously set object.
329  
330  
331 =cut
332  
333 31 ▶sub poly_A_site {
Subroutine poly_A_site: called CC=2 SCAR=6.9
Pod documented
334 31 my ($self, $fea) = @_;
335 31 ▶ if ($fea) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fea) 11 20 31
336 11 $self->_add($fea,'Bio::SeqFeature::Gene::Poly_A_site');
337 }
338 31 return ($self->get_feature_type('Bio::SeqFeature::Gene::Poly_A_site'))[0];
339 }
340  
341 =head2 utrs
342  
343 Title : utrs()
344 Usage : @utr_sites = $transcript->utrs('utr3prime');
345 @utr_sites = $transcript->utrs('utr5prime');
346 @utr_sites = $transcript->utrs();
347 Function: Get the features representing untranslated regions (UTR) of this
348 transcript.
349  
350 You may provide an argument specifying the type of UTR. Currently
351 the following types are recognized: utr5prime utr3prime for UTR on the
352 5' and 3' end of the CDS, respectively.
353  
354 Returns : An array of Bio::SeqFeature::Gene::UTR objects
355 representing the UTR regions or sites.
356 Args : Optionally, either utr3prime, or utr5prime for the the type of UTR
357 feature.
358  
359  
360 =cut
361  
362 3 ▶sub utrs {
Subroutine utrs: called CC=1 SCAR=0.0
Pod documented
363 3 my ($self, $type) = @_;
364 3 return $self->get_feature_type('Bio::SeqFeature::Gene::UTR',$type);
365  
366 }
367  
368 =head2 add_utr
369  
370 Title : add_utr()
371 Usage : $transcript->add_utr($utrobj, 'utr3prime');
372 $transcript->add_utr($utrobj);
373 Function: Add a UTR feature/site to this transcript.
374  
375 The second parameter is optional and denotes the type of the UTR
376 feature. Presently recognized types include 'utr5prime' and 'utr3prime'
377 for UTR on the 5' and 3' end of a gene, respectively.
378  
379 Calling this method is the same as calling
380 add_exon($utrobj, 'utr'.$type). In this sense a UTR object is a
381 special exon object, which is transcribed, not spliced out, but
382 not translated.
383  
384 Note that the object supplied should return FALSE for is_coding().
385 Otherwise cds() and friends will become confused.
386  
387 Returns :
388 Args : A Bio::SeqFeature::Gene::UTR implementing object.
389  
390  
391 =cut
392  
393 2 ▶sub add_utr {
Subroutine add_utr: called CC=1 SCAR=0.0
Pod documented
394 2 my ($self, $fea, $type) = @_;
395 2 $self->_add($fea,'Bio::SeqFeature::Gene::UTR',$type);
396 }
397  
398 =head2 flush_utrs
399  
400 Title : flush_utrs()
401 Usage : $transcript->flush_utrs();
402 $transcript->flush_utrs('utr3prime');
403 Function: Remove all or a specific type of UTR features/sites from this
404 transcript.
405  
406 Cf. add_utr() for documentation about recognized types.
407 Returns : a list of the removed features
408 Args : Optionally a string denoting the type of UTR feature.
409  
410  
411 =cut
412  
413 0 ▶sub flush_utrs {
Subroutine flush_utrs: not called CC=1 SCAR=6.9
Pod documented
414 0 my ($self, $type) = @_;
415 0 return $self->_flush('Bio::SeqFeature::Gene::UTR',$type);
416 }
417  
418 =head2 sub_SeqFeature
419  
420 Title : sub_SeqFeature
421 Usage : @feats = $transcript->sub_SeqFeature();
422 Function: Returns an array of all subfeatures.
423  
424 This method is defined in Bio::SeqFeatureI. We override this here
425 to include the exon etc features.
426  
427 Returns : An array Bio::SeqFeatureI implementing objects.
428 Args : none
429  
430  
431 =cut
432  
433 9 ▶sub sub_SeqFeature {
Subroutine sub_SeqFeature: called CC=2 SCAR=6.9
Pod documented
434 9 my ($self) = @_;
435 9 my @feas;
436
437 # get what the parent already has
438 9 @feas = $self->SUPER::sub_SeqFeature();
439 # add the features we have in addition
440 9 push(@feas, $self->exons()); # this includes UTR features
441 9 push(@feas, $self->promoters());
442 9 ▶ push(@feas, $self->poly_A_site()) if($self->poly_A_site());
Branch: 1 branch
BranchTrueFalseTotal
if $self->poly_A_site 8 1 9
443 9 return @feas;
444 }
445  
446 =head2 flush_sub_SeqFeature
447  
448 Title : flush_sub_SeqFeature
449 Usage : $transcript->flush_sub_SeqFeature();
450 $transcript->flush_sub_SeqFeature(1);
451 Function: Removes all subfeatures.
452  
453 This method is overridden from Bio::SeqFeature::Generic to flush
454 all additional subfeatures like exons, promoters, etc., which is
455 almost certainly not what you want. To remove only features added
456 through $transcript->add_sub_SeqFeature($feature) pass any
457 argument evaluating to TRUE.
458  
459 Example :
460 Returns : none
461 Args : Optionally, an argument evaluating to TRUE will suppress flushing
462 of all transcript-specific subfeatures (exons etc.).
463  
464  
465 =cut
466  
467 0 ▶sub flush_sub_SeqFeature {
Subroutine flush_sub_SeqFeature: not called CC=2 SCAR=17.9
Pod documented
468 0 my ($self,$fea_only) = @_;
469  
470 0 $self->SUPER::flush_sub_SeqFeature();
471 0 ▶ if(! $fea_only) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $fea_only) 0 0 0
472 0 $self->flush_promoters();
473 0 $self->flush_exons();
474 0 $self->flush_utrs();
475 0 $self->poly_A_site(0);
476 }
477 }
478  
479  
480 =head2 cds
481  
482 Title : cds
483 Usage : $seq = $transcript->cds();
484 Function: Returns the CDS (coding sequence) as defined by the exons
485 of this transcript and the attached sequence.
486  
487 If no sequence is attached this method will return false.
488  
489 Note that the implementation provided here returns a
490 concatenation of all coding exons, thereby assuming that
491 exons do not overlap.
492  
493 Note also that you cannot set the CDS via this method. Set
494 a single CDS feature as a single exon, or derive your own
495 class if you want to store a predicted CDS.
496  
497 Example :
498 Returns : A Bio::PrimarySeqI implementing object.
499 Args :
500  
501 =cut
502  
503 4 ▶sub cds {
Subroutine cds: called CC=8 SCAR=21.3
Pod documented
504 4 my ($self) = @_;
505 4 my @exons = $self->exons_ordered(); #this is always sorted properly according to strand
506 4 my $strand;
507  
508 4 ▶ return unless(@exons);
Branch: 1 branch
BranchTrueFalseTotal
unless @exons 0 4 4
509 # record strand (a minus-strand transcript must have the exons sorted in
510 # reverse order)
511 4 foreach my $exon (@exons) {
512 40 ▶ if(defined($exon->strand()) && (! $strand)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exon->strand and not $strand) 5 35 40
Condition100%3/3
defined $exon->strand and not $strand
!ll&&!rl&&r
1345
MC/DC100%2/2
defined $exon->strand and not $strand
defined $exon->strand not $strand
Truth table100%3/3
A and not(B)
A= defined $exon->strandB= not $strand
ABresult
0X0
100
111
513 5 $strand = $exon->strand();
514 }
515 40 ▶ if($exon->strand() && (($exon->strand() * $strand) < 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exon->strand and $exon->strand * $strand < 0) 0 40 40
Condition66%2/3
$exon->strand and $exon->strand * $strand < 0
!ll&&!rl&&r
3370
MC/DC0%0/2
$exon->strand and $exon->strand * $strand < 0
$exon->strand $exon->strand * $strand < 0
Truth table66%2/3
A and B
A= $exon->strandB= $exon->strand * $strand < 0
ABresult
0X0
100
111
516 0 $self->throw("Transcript mixes coding exons on plus and minus ".
517 "strand. This makes no sense.");
518 }
519 }
520 4 my $cds = $self->_make_cds(@exons);
521 4 ▶ return unless $cds;
Branch: 1 branch
BranchTrueFalseTotal
unless $cds 0 4 4
522 4 return Bio::PrimarySeq->new('-id' => $self->seq_id(),
523 '-seq' => $cds,
524 '-alphabet' => "dna");
525 }
526  
527 =head2 protein
528  
529 Title : protein()
530 Usage : $protein = $transcript->protein();
531 Function: Get the protein encoded by the transcript as a sequence object.
532  
533 The implementation provided here simply calls translate() on the
534 object returned by cds().
535  
536 Returns : A Bio::PrimarySeqI implementing object.
537 Args :
538  
539  
540 =cut
541  
542 0 ▶sub protein {
Subroutine protein: not called CC=2 SCAR=17.9
Pod documented
543 0 my ($self) = @_;
544 0 my $seq;
545  
546 0 $seq = $self->cds();
547 0 ▶ return $seq->translate() if $seq;
Branch: 1 branch
BranchTrueFalseTotal
if $seq 0 0 0
548 0 return;
549 }
550  
551 =head2 mrna
552  
553 Title : mrna()
554 Usage : $mrna = $transcript->mrna();
555 Function: Get the mRNA of the transcript as a sequence object.
556  
557 The difference to cds() is that the sequence object returned by
558 this methods will also include UTR and the poly-adenylation site,
559 but not promoter sequence (TBD).
560  
561 HL: do we really need this method?
562  
563 Returns : A Bio::PrimarySeqI implementing object.
564 Args :
565  
566  
567 =cut
568  
569 1 ▶sub mrna {
Subroutine mrna: called CC=6 SCAR=18.2
Pod documented
570 1 my ($self) = @_;
571 1 my ($seq, $mrna, $elem);
572  
573 # get the coding part
574 1 $seq = $self->cds();
575 1 ▶ if(! $seq) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seq) 0 1 1
576 0 $seq = Bio::PrimarySeq->new('-id' => $self->seq_id(),
577 '-alphabet' => "rna",
578 '-seq' => "");
579 }
580 # get and add UTR sequences
581 1 $mrna = "";
582 1 foreach $elem ($self->utrs('utr5prime')) {
583 1 $mrna .= $elem->seq()->seq();
584 }
585 1 $seq->seq($mrna . $seq->seq());
586 1 $mrna = "";
587 1 foreach $elem ($self->utrs('utr3prime')) {
588 1 $mrna .= $elem->seq()->seq();
589 }
590 1 $seq->seq($seq->seq() . $mrna);
591 1 ▶ if($self->poly_A_site()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->poly_A_site) 1 0 1
592 1 $seq->seq($seq->seq() . $self->poly_A_site()->seq()->seq());
593 }
594 1 ▶ return if($seq->length() == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $seq->length == 0 0 1 1
595 1 return $seq;
596 }
597  
598 0 ▶sub _get_typed_keys {
Subroutine _get_typed_keys: not called CC=2 SCAR=17.9
599 0 my ($self, $keyprefix, $type) = @_;
600 0 my @keys = ();
601 0 my @feas = ();
602  
603 # make case-insensitive
604 0 ▶ $type = ($type ? lc($type) : "");
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 0 0 0
605 # pull out all feature types that exist and match
606 0 @keys = grep { /^_$keyprefix$type/i; } (keys(%{$self}));
607 0 return @keys;
608 }
609  
610 4 ▶sub _make_cds {
Subroutine _make_cds: called CC=10 SCAR=26.6
611 4 my ($self,@exons) = @_;
612 4 my $cds = "";
613  
614 4 foreach my $exon (@exons) {
615 40 ▶ next if((! defined($exon->seq())) || (! $exon->is_coding()));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $exon->seq and $exon->is_coding 2 38 40
Condition66%2/3
defined $exon->seq and $exon->is_coding
!ll&&!rl&&r
0238
MC/DC50%1/2
defined $exon->seq and $exon->is_coding
defined $exon->seq $exon->is_coding
Truth table66%2/3
A and B
A= defined $exon->seqB= $exon->is_coding
ABresult
0X0
100
111
616 38 my $phase = length($cds) % 3;
617 # let's check the simple case
618 38 ▶ if((! defined($exon->frame())) || ($phase == $exon->frame())) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $exon->frame or $phase == $exon->frame) { } 37 1 38
Condition100%3/3
not defined $exon->frame or $phase == $exon->frame
l!l&&r!l&&!r
1361
MC/DC100%2/2
not defined $exon->frame or $phase == $exon->frame
not defined $exon->frame $phase == $exon->frame
Truth table100%3/3
not(A) or B
A= not defined $exon->frameB= $phase == $exon->frame
ABresult
1X1
011
000
619 # this one fits exactly, or frame of the exon is undefined (should
620 # we warn about that?); we bypass the $exon->cds() here (hmm,
621 # not very clean style, but I don't see where this screws up)
622 37 $cds .= $exon->seq()->seq();
623 } else {
624 # this one is probably from exon shuffling and needs some work
625 1 my $seq = $exon->cds(); # now $seq is guaranteed to be in frame 0
626 1 ▶ next if(! $seq);
Branch: 1 branch
BranchTrueFalseTotal
unless $seq 0 1 1
627 1 $seq = $seq->seq();
628 # adjustment needed?
629 1 ▶ if($phase > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($phase > 0) 0 1 1
630 # how many Ns can we chop off the piece to be added?
631 0 my $n_crop = 0;
632 0 ▶ if($seq =~ /^(n+)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq =~ /^(n+)/i) 0 0 0
633 0 $n_crop = length($1);
634 }
635 0 ▶ if($n_crop >= $phase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n_crop >= $phase) { } 0 0 0
636 # chop off to match the phase
637 0 $seq = substr($seq, $phase);
638 } else {
639 # fill in Ns
640 0 $seq = ("n" x (3-$phase)) . $seq;
641 }
642 }
643 1 $cds .= $seq;
644 }
645 }
646 4 return $cds;
647 }
648  
649 =head2 features
650  
651 Title : features
652 Usage : my @features=$transcript->features;
653 Function: returns all the features associated with this transcript
654 Returns : a list of SeqFeatureI implementing objects
655 Args : none
656  
657  
658 =cut
659  
660  
661 254 ▶sub features {
Subroutine features: called CC=2 SCAR=7.0
Pod documented
662 254 my $self = shift;
663 254 ▶ return grep { defined } @{$self->{'_features'} || []};
Condition50%1/2
$self->{'_features'} || []
l!l
2540
MC/DC0%0/1
$self->{'_features'} || []
$self->{'_features'}
Truth table50%1/2
A
A= $self->{'_features'}
Aresult
11
00
664 }
665  
666 =head2 features_ordered
667  
668 Title : features_ordered
669 Usage : my @features=$transcript->features_ordered;
670 Function: returns all the features associated with this transcript,
671 in order by feature start, according to strand
672 Returns : a list of SeqFeatureI implementing objects
673 Args : none
674  
675  
676 =cut
677  
678 0 ▶sub features_ordered{
Subroutine features_ordered: not called CC=2 SCAR=17.9
Pod documented
679 0 my ($self) = @_;
680 0 ▶ return $self->_stranded_sort(@{$self->{'_features'} || []});
Condition0%0/2
$self->{'_features'} || []
l!l
00
MC/DC0%0/1
$self->{'_features'} || []
$self->{'_features'}
Truth table0%0/2
A
A= $self->{'_features'}
Aresult
11
00
681 }
682  
683  
684 158 ▶sub get_unordered_feature_type{
Subroutine get_unordered_feature_type: called CC=5 SCAR=16.1
Pod undocumented
685 158 my ($self, $type, $pri)=@_;
686 158 my @list;
687 158 foreach ( $self->features) {
688 1143 ▶ if ($_->isa($type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa($type)) 773 370 1143
689 773 ▶ if ($pri && $_->primary_tag !~ /$pri/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pri and not $_->primary_tag =~ /$pri/i) 35 738 773
Condition100%3/3
$pri and not $_->primary_tag =~ /$pri/i
!ll&&!rl&&r
735335
MC/DC100%2/2
$pri and not $_->primary_tag =~ /$pri/i
$pri not $_->primary_tag =~ /$pri/i
Truth table100%3/3
A and not(B)
A= $priB= not $_->primary_tag =~ /$pri/i
ABresult
0X0
100
111
690 35 next;
691 }
692 738 push @list,$_;
693 }
694 }
695 158 return @list;
696  
697 }
698  
699 47 ▶sub get_feature_type {
Subroutine get_feature_type: called CC=1 SCAR=0.0
Pod undocumented
700 47 my ($self)=shift;
701 47 return $self->_stranded_sort($self->get_unordered_feature_type(@_));
702 }
703  
704 #This was fixed by Gene Cutler - the indexing on the list being reversed
705 #fixed a bad bug. Thanks Gene!
706 0 ▶sub _flush {
Subroutine _flush: not called CC=6 SCAR=37.4
707 0 my ($self, $type, $pri)=@_;
708 0 my @list=$self->features;
709 0 my @cut;
710 0 for (reverse (0..$#list)) {
711 0 ▶ if (defined $list[$_] &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $list[$_] and $list[$_]->isa($type)) 0 0 0
Condition0%0/3
defined $list[$_] and $list[$_]->isa($type)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $list[$_] and $list[$_]->isa($type)
defined $list[$_] $list[$_]->isa($type)
Truth table0%0/3
A and B
A= defined $list[$_]B= $list[$_]->isa($type)
ABresult
0X0
100
111
712 $list[$_]->isa($type)) {
713 0 ▶ if ($pri && $list[$_]->primary_tag !~ /$pri/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pri and not $list[$_]->primary_tag =~ /$pri/i) 0 0 0
Condition0%0/3
$pri and not $list[$_]->primary_tag =~ /$pri/i
!ll&&!rl&&r
000
MC/DC0%0/2
$pri and not $list[$_]->primary_tag =~ /$pri/i
$pri not $list[$_]->primary_tag =~ /$pri/i
Truth table0%0/3
A and not(B)
A= $priB= not $list[$_]->primary_tag =~ /$pri/i
ABresult
0X0
100
111
714 0 next;
715 }
716 0 push @cut, splice @list, $_, 1; #remove the element of $type from @list
717 #and return each of them in @cut
718 }
719 }
720 0 $self->{'_features'}=\@list;
721 0 return reverse @cut;
722 }
723  
724 531 ▶sub _add {
Subroutine _add: called CC=10 SCAR=25.0
725 531 my ($self, $fea, $type, $pri)=@_;
726 531 require Bio::SeqFeature::Gene::Promoter;
727 531 require Bio::SeqFeature::Gene::UTR;
728 531 require Bio::SeqFeature::Gene::Exon;
729 531 require Bio::SeqFeature::Gene::Intron;
730 531 require Bio::SeqFeature::Gene::Poly_A_site;
731  
732 531 ▶ if(! $fea->isa('Bio::SeqFeatureI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fea->isa("Bio::SeqFeatureI")) 0 531 531
733 0 $self->throw("$fea does not implement Bio::SeqFeatureI");
734 }
735 531 ▶ if(! $fea->isa($type) || $pri) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $fea->isa($type) or $pri) 382 149 531
Condition100%3/3
not $fea->isa($type) or $pri
l!l&&r!l&&!r
19363149
MC/DC100%2/2
not $fea->isa($type) or $pri
not $fea->isa($type) $pri
Truth table100%3/3
not(A) or B
A= not $fea->isa($type)B= $pri
ABresult
1X1
011
000
736 382 $fea=$self->_new_of_type($fea,$type,$pri);
737 }
738 531 ▶ if (! $self->strand) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->strand) { } 87 444 531
739 87 $self->strand($fea->strand);
740 } else {
741 444 ▶ if ($self->strand * $fea->strand == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strand * $fea->strand == -1) 0 444 444
742 0 $self->throw("$fea is on opposite strand from $self");
743 }
744 }
745  
746 531 $self->_expand_region($fea);
747 531 ▶ if(defined($self->entire_seq()) && (! defined($fea->entire_seq())) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->entire_seq and not defined $fea->entire_seq and $fea->can("attach_seq")) 0 531 531
Condition33%2/6
defined $self->entire_seq and not defined $fea->entire_seq and $fea->can("attach_seq")
!ll&&!rl&&r
53100
defined $self->entire_seq and not defined $fea->entire_seq
!ll&&!rl&&r
53100
MC/DC0%0/3
defined $self->entire_seq and not defined $fea->entire_seq and $fea->can("attach_seq")
defined $self->entire_seq not defined $fea->entire_seq $fea->can("attach_seq")
Truth table25%1/4
A and not(B) and C
A= defined $self->entire_seqB= not defined $fea->entire_seqC= $fea->can("attach_seq")
ABCresult
0XX0
10X0
1100
1111
748 $fea->can('attach_seq')) {
749 0 $fea->attach_seq($self->entire_seq());
750 }
751 531 ▶ if (defined $self->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->parent) 0 531 531
752 0 $self->parent->_expand_region($fea);
753 }
754 531 push(@{$self->{'_features'}}, $fea);
755 531 1;
756 }
757  
758 47 ▶sub _stranded_sort {
Subroutine _stranded_sort: called CC=7 SCAR=19.5
759 47 my ($self,@list)=@_;
760 47 my $strand;
761 47 foreach my $fea (@list) {
762 78 ▶ if($fea->strand()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fea->strand) 64 14 78
763 # defined and != 0
764 64 ▶ $strand = $fea->strand() if(! $strand);
Branch: 1 branch
BranchTrueFalseTotal
unless $strand 30 34 64
765 64 ▶ if(($fea->strand() * $strand) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fea->strand * $strand < 0) 0 64 64
766 0 $strand = undef;
767 0 last;
768 }
769 }
770 }
771 47 ▶ if (defined $strand && $strand == - 1) { #reverse strand
Branch: 1 branch
BranchTrueFalseTotal
if (defined $strand and $strand == -1) { } 20 27 47
Condition100%3/3
defined $strand and $strand == -1
!ll&&!rl&&r
171020
MC/DC100%2/2
defined $strand and $strand == -1
defined $strand $strand == -1
Truth table100%3/3
A and B
A= defined $strandB= $strand == -1
ABresult
0X0
100
111
772 20 return map { $_->[0] } sort {$b->[1] <=> $a->[1]} map { [$_, $_->start] } @list;
773 } else { #undef or forward strand
774 27 return map { $_->[0] } sort {$a->[1] <=> $b->[1]} map { [$_, $_->start] } @list;
775 }
776 }
777  
778 382 ▶sub _new_of_type {
Subroutine _new_of_type: called CC=2 SCAR=6.9
779 382 my ($self, $fea, $type, $pri)= @_;
780 382 my $primary;
781 382 ▶ if ($pri) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pri) { } 363 19 382
782 363 $primary = $pri; #can set new primary tag if desired
783 } else {
784 19 ($primary) = $type =~ /.*::(.+)/; #or else primary is just end of type string
785 }
786 382 bless $fea,$type;
787 382 $fea->primary_tag($primary);
788 382 return $fea;
789 }
790  
791 96 ▶sub transcript_destroy {
Subroutine transcript_destroy: called CC=2 SCAR=6.9
Pod undocumented
792 96 my $self = shift;
793 # We're going to be really explicit to insure memory leaks
794 # don't occur
795 96 foreach my $f ( $self->features ) {
796 531 $f = undef;
797 }
798 96 $self->parent(undef);
799 }
800  
801 24 1;
« Bio/Tools/Genscan.pm ↑ Summary Bio/SearchIO/axt.pm »