Bio/PrimarySeqI.pm

filter: Statementstmt 54.4% 111 / 204 Branchbran 44.2% 46 / 104 Conditioncond 60.0% 39 / 65 MC/DCmcdc 31.5% 12 / 38 Subroutinesub 39.2% 11 / 28 Podpod 100% 17 / 17 totaltotal 51.7% 236 / 456 CC 76 SCAR 37.5
CC
76
Cov
53%
_find_orfs_nucleotide
132.0
translate
72.1
trunc
12.3
CRAP 42.6
« Bio/SearchIO/sim4.pm ↑ Summary Bio/Tools/ipcress.pm »
1 #
2 # BioPerl module for Bio::PrimarySeqI
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
7 #
8 # Copyright Ewan Birney
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  
15 =head1 NAME
16  
17 Bio::PrimarySeqI - Interface definition for a Bio::PrimarySeq
18  
19 =head1 SYNOPSIS
20  
21 # Bio::PrimarySeqI is the interface class for sequences.
22 # If you are a newcomer to bioperl, you might want to start with
23 # Bio::Seq documentation.
24  
25 # Test if this is a seq object
26 $obj->isa("Bio::PrimarySeqI") ||
27 $obj->throw("$obj does not implement the Bio::PrimarySeqI interface");
28  
29 # Accessors
30 $string = $obj->seq();
31 $substring = $obj->subseq(12,50);
32 $display = $obj->display_id(); # for human display
33 $id = $obj->primary_id(); # unique id for this object,
34 # implementation defined
35 $unique_key= $obj->accession_number(); # unique biological id
36  
37  
38 # Object manipulation
39 eval {
40 $rev = $obj->revcom();
41 };
42 if( $@ ) {
43 $obj->throw( "Could not reverse complement. ".
44 "Probably not DNA. Actual exception\n$@\n" );
45 }
46  
47 $trunc = $obj->trunc(12,50);
48 # $rev and $trunc are Bio::PrimarySeqI compliant objects
49  
50  
51 =head1 DESCRIPTION
52  
53 This object defines an abstract interface to basic sequence
54 information - for most users of the package the documentation (and
55 methods) in this class are not useful - this is a developers-only
56 class which defines what methods have to be implemented by other Perl
57 objects to comply to the Bio::PrimarySeqI interface. Go "perldoc
58 Bio::Seq" or "man Bio::Seq" for more information on the main class for
59 sequences.
60  
61 PrimarySeq is an object just for the sequence and its name(s), nothing
62 more. Seq is the larger object complete with features. There is a pure
63 perl implementation of this in L<Bio::PrimarySeq>. If you just want to
64 use L<Bio::PrimarySeq> objects, then please read that module first. This
65 module defines the interface, and is of more interest to people who
66 want to wrap their own Perl Objects/RDBs/FileSystems etc in way that
67 they "are" bioperl sequence objects, even though it is not using Perl
68 to store the sequence etc.
69  
70 This interface defines what bioperl considers necessary to "be" a
71 sequence, without providing an implementation of this, an
72 implementation is provided in L<Bio::PrimarySeq>. If you want to provide
73 a Bio::PrimarySeq-compliant object which in fact wraps another
74 object/database/out-of-perl experience, then this is the correct thing
75 to wrap, generally by providing a wrapper class which would inherit
76 from your object and this Bio::PrimarySeqI interface. The wrapper class
77 then would have methods lists in the "Implementation Specific
78 Functions" which would provide these methods for your object.
79  
80 =head1 FEEDBACK
81  
82 =head2 Mailing Lists
83  
84 User feedback is an integral part of the evolution of this and other
85 Bioperl modules. Send your comments and suggestions preferably to one
86 of the Bioperl mailing lists. Your participation is much appreciated.
87  
88 bioperl-l@bioperl.org - General discussion
89 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
90  
91 =head2 Support
92  
93 Please direct usage questions or support issues to the mailing list:
94  
95 I<bioperl-l@bioperl.org>
96  
97 rather than to the module maintainer directly. Many experienced and
98 reponsive experts will be able look at the problem and quickly
99 address it. Please include a thorough description of the problem
100 with code and data examples if at all possible.
101  
102 =head2 Reporting Bugs
103  
104 Report bugs to the Bioperl bug tracking system to help us keep track
105 the bugs and their resolution. Bug reports can be submitted via the
106 web:
107  
108 https://github.com/bioperl/bioperl-live/issues
109  
110 =head1 AUTHOR - Ewan Birney
111  
112 Email birney@ebi.ac.uk
113  
114 =head1 APPENDIX
115  
116 The rest of the documentation details each of the object
117 methods. Internal methods are usually preceded with a _
118  
119 =cut
120  
121  
122 package Bio::PrimarySeqI;
123 340 $Bio::PrimarySeqI::VERSION = '1.7.8';
124 340 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 340 ▶use Bio::Tools::CodonTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 340 ▶use base qw(Bio::Root::RootI);
Subroutine BEGIN: called CC=1 SCAR=0.0
128  
129  
130 =head1 Implementation-specific Functions
131  
132 These functions are the ones that a specific implementation must
133 define.
134  
135 =head2 seq
136  
137 Title : seq
138 Usage : $string = $obj->seq()
139 Function: Returns the sequence as a string of letters. The
140 case of the letters is left up to the implementer.
141 Suggested cases are upper case for proteins and lower case for
142 DNA sequence (IUPAC standard), but implementations are suggested to
143 keep an open mind about case (some users... want mixed case!)
144 Returns : A scalar
145 Status : Virtual
146  
147 =cut
148  
149 0 ▶sub seq {
Subroutine seq: not called CC=1 SCAR=6.9
Pod documented
150 0 my ($self) = @_;
151 0 $self->throw_not_implemented();
152 }
153  
154  
155 =head2 subseq
156  
157 Title : subseq
158 Usage : $substring = $obj->subseq(10,40);
159 Function: Returns the subseq from start to end, where the first base
160 is 1 and the number is inclusive, i.e. 1-2 are the first two
161 bases of the sequence.
162  
163 Start cannot be larger than end but can be equal.
164  
165 Returns : A string
166 Args :
167 Status : Virtual
168  
169 =cut
170  
171 0 ▶sub subseq {
Subroutine subseq: not called CC=1 SCAR=6.9
Pod documented
172 0 my ($self) = @_;
173 0 $self->throw_not_implemented();
174 }
175  
176  
177 =head2 display_id
178  
179 Title : display_id
180 Usage : $id_string = $obj->display_id();
181 Function: Returns the display id, also known as the common name of the Sequence
182 object.
183  
184 The semantics of this is that it is the most likely string
185 to be used as an identifier of the sequence, and likely to
186 have "human" readability. The id is equivalent to the ID
187 field of the GenBank/EMBL databanks and the id field of the
188 Swissprot/sptrembl database. In fasta format, the >(\S+) is
189 presumed to be the id, though some people overload the id
190 to embed other information. Bioperl does not use any
191 embedded information in the ID field, and people are
192 encouraged to use other mechanisms (accession field for
193 example, or extending the sequence object) to solve this.
194  
195 Notice that $seq->id() maps to this function, mainly for
196 legacy/convenience reasons.
197 Returns : A string
198 Args : None
199 Status : Virtual
200  
201 =cut
202  
203 0 ▶sub display_id {
Subroutine display_id: not called CC=1 SCAR=6.9
Pod documented
204 0 my ($self) = @_;
205 0 $self->throw_not_implemented();
206 }
207  
208  
209 =head2 accession_number
210  
211 Title : accession_number
212 Usage : $unique_biological_key = $obj->accession_number;
213 Function: Returns the unique biological id for a sequence, commonly
214 called the accession_number. For sequences from established
215 databases, the implementors should try to use the correct
216 accession number. Notice that primary_id() provides the
217 unique id for the implementation, allowing multiple objects
218 to have the same accession number in a particular implementation.
219  
220 For sequences with no accession number, this method should return
221 "unknown".
222 Returns : A string
223 Args : None
224 Status : Virtual
225  
226 =cut
227  
228 0 ▶sub accession_number {
Subroutine accession_number: not called CC=1 SCAR=6.9
Pod documented
229 0 my ($self,@args) = @_;
230 0 $self->throw_not_implemented();
231 }
232  
233  
234 =head2 primary_id
235  
236 Title : primary_id
237 Usage : $unique_implementation_key = $obj->primary_id;
238 Function: Returns the unique id for this object in this
239 implementation. This allows implementations to manage their
240 own object ids in a way the implementation can control
241 clients can expect one id to map to one object.
242  
243 For sequences with no accession number, this method should
244 return a stringified memory location.
245  
246 Returns : A string
247 Args : None
248 Status : Virtual
249  
250 =cut
251  
252 0 ▶sub primary_id {
Subroutine primary_id: not called CC=1 SCAR=6.9
Pod documented
253 0 my ($self,@args) = @_;
254 0 $self->throw_not_implemented();
255 }
256  
257  
258 =head2 can_call_new
259  
260 Title : can_call_new
261 Usage : if( $obj->can_call_new ) {
262 $newobj = $obj->new( %param );
263 }
264 Function: Can_call_new returns 1 or 0 depending
265 on whether an implementation allows new
266 constructor to be called. If a new constructor
267 is allowed, then it should take the followed hashed
268 constructor list.
269  
270 $myobject->new( -seq => $sequence_as_string,
271 -display_id => $id
272 -accession_number => $accession
273 -alphabet => 'dna',
274 );
275 Returns : 1 or 0
276 Args :
277  
278  
279 =cut
280  
281 0 ▶sub can_call_new {
Subroutine can_call_new: not called CC=1 SCAR=6.9
Pod documented
282 0 my ($self,@args) = @_;
283 # we default to 0 here
284 0 return 0;
285 }
286  
287  
288 =head2 alphabet
289  
290 Title : alphabet
291 Usage : if( $obj->alphabet eq 'dna' ) { /Do Something/ }
292 Function: Returns the type of sequence being one of
293 'dna', 'rna' or 'protein'. This is case sensitive.
294  
295 This is not called "type" because this would cause
296 upgrade problems from the 0.5 and earlier Seq objects.
297  
298 Returns : A string either 'dna','rna','protein'. NB - the object must
299 make a call of the alphabet, if there is no alphabet specified it
300 has to guess.
301 Args : None
302 Status : Virtual
303  
304 =cut
305  
306 0 ▶sub alphabet {
Subroutine alphabet: not called CC=1 SCAR=6.9
Pod documented
307 0 my ( $self ) = @_;
308 0 $self->throw_not_implemented();
309 }
310  
311  
312 =head2 moltype
313  
314 Title : moltype
315 Usage : Deprecated. Use alphabet() instead.
316  
317 =cut
318  
319 0 ▶sub moltype {
Subroutine moltype: not called CC=1 SCAR=6.9
Pod documented
320 0 my ($self,@args) = @_;
321 0 $self->warn("moltype: pre v1.0 method. Calling alphabet() instead...");
322 0 return $self->alphabet(@args);
323 }
324  
325  
326 =head1 Implementation-optional Functions
327  
328 The following functions rely on the above functions. An
329 implementing class does not need to provide these functions, as they
330 will be provided by this class, but is free to override these
331 functions.
332  
333 The revcom(), trunc(), and translate() methods create new sequence
334 objects. They will call new() on the class of the sequence object
335 instance passed as argument, unless can_call_new() returns FALSE. In
336 the latter case a Bio::PrimarySeq object will be created. Implementors
337 which really want to control how objects are created (eg, for object
338 persistence over a database, or objects in a CORBA framework), they
339 are encouraged to override these methods
340  
341 =head2 revcom
342  
343 Title : revcom
344 Usage : $rev = $seq->revcom()
345 Function: Produces a new Bio::PrimarySeqI implementing object which
346 is the reversed complement of the sequence. For protein
347 sequences this throws an exception of "Sequence is a
348 protein. Cannot revcom".
349  
350 The id is the same id as the original sequence, and the
351 accession number is also identical. If someone wants to
352 track that this sequence has be reversed, it needs to
353 define its own extensions.
354  
355 To do an inplace edit of an object you can go:
356  
357 $seq = $seq->revcom();
358  
359 This of course, causes Perl to handle the garbage
360 collection of the old object, but it is roughly speaking as
361 efficient as an inplace edit.
362  
363 Returns : A new (fresh) Bio::PrimarySeqI object
364 Args : None
365  
366  
367 =cut
368  
369 201 ▶sub revcom {
Subroutine revcom: called CC=3 SCAR=12.6
Pod documented
370 201 my ($self) = @_;
371  
372 # Create a new fresh object if $self is 'Bio::Seq::LargePrimarySeq'
373 # or 'Bio::Seq::LargeSeq', if not take advantage of
374 # Bio::Root::clone to get an object copy
375 201 my $out;
376 201 ▶ if ( $self->isa('Bio::Seq::LargePrimarySeq')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Bio::Seq::LargePrimarySeq') or $self->isa('Bio::Seq::LargeSeq')) { } 0 201 201
Condition33%1/3
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
l!l&&r!l&&!r
00201
MC/DC0%0/2
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
$self->isa("Bio::Seq::LargePrimarySeq") $self->isa("Bio::Seq::LargeSeq")
Truth table33%1/3
A or B
A= $self->isa("Bio::Seq::LargePrimarySeq")B= $self->isa("Bio::Seq::LargeSeq")
ABresult
1X1
011
000
377 or $self->isa('Bio::Seq::LargeSeq')
378 ) {
379 0 my ($seqclass, $opts) = $self->_setup_class;
380 0 $out = $seqclass->new(
381 -seq => $self->_revcom_from_string($self->seq, $self->alphabet),
382 -is_circular => $self->is_circular,
383 -display_id => $self->display_id,
384 -accession_number => $self->accession_number,
385 -alphabet => $self->alphabet,
386 -desc => $self->desc,
387 -verbose => $self->verbose,
388 %$opts,
389 );
390 } else {
391 201 $out = $self->clone;
392 201 $out->seq( $out->_revcom_from_string($out->seq, $out->alphabet) );
393 }
394 201 return $out;
395 }
396  
397  
398 210 ▶sub _revcom_from_string {
Subroutine _revcom_from_string: called CC=7 SCAR=22.2
399 210 my ($self, $string, $alphabet) = @_;
400  
401 # Check that reverse-complementing makes sense
402 210 ▶ if( $alphabet eq 'protein' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alphabet eq "protein") 0 210 210
403 0 $self->throw("Sequence is a protein. Cannot revcom.");
404 }
405 210 ▶ if( $alphabet ne 'dna' && $alphabet ne 'rna' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alphabet ne "dna" and $alphabet ne "rna") 0 210 210
Condition66%2/3
$alphabet ne "dna" and $alphabet ne "rna"
!ll&&!rl&&r
20910
MC/DC0%0/2
$alphabet ne "dna" and $alphabet ne "rna"
$alphabet ne "dna" $alphabet ne "rna"
Truth table66%2/3
A and B
A= $alphabet ne "dna"B= $alphabet ne "rna"
ABresult
0X0
100
111
406 0 my $msg = "Sequence is not dna or rna, but [$alphabet]. Attempting to revcom, ".
407 "but unsure if this is right.";
408 0 ▶ if( $self->can('warn') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can('warn')) { } 0 0 0
409 0 $self->warn($msg);
410 } else {
411 0 warn("[$self] $msg");
412 }
413 }
414  
415 # If sequence is RNA, map to DNA (then map back later)
416 210 ▶ if( $alphabet eq 'rna' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alphabet eq "rna") 1 209 210
417 1 $string =~ tr/uU/tT/;
418 }
419  
420 # Reverse-complement now
421 210 $string =~ tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/;
422 210 $string = CORE::reverse $string;
423  
424 # Map back RNA to DNA
425 210 ▶ if( $alphabet eq 'rna' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alphabet eq "rna") 1 209 210
426 1 $string =~ tr/tT/uU/;
427 }
428  
429 210 return $string;
430 }
431  
432  
433 =head2 trunc
434  
435 Title : trunc
436 Usage : $subseq = $myseq->trunc(10,100);
437 Function: Provides a truncation of a sequence.
438 Returns : A fresh Bio::PrimarySeqI implementing object.
439 Args : Two integers denoting first and last base of the sub-sequence.
440  
441  
442 =cut
443  
444 280 ▶sub trunc {
Subroutine trunc: called CC=9 SCAR=25.1
Pod documented
445 280 my ($self,$start,$end) = @_;
446  
447 280 my $str;
448 280 ▶ if( defined $start && ref($start) &&
Branch: 3 branches
BranchTrueFalseTotal
if (defined $start and ref $start and $start->isa('Bio::LocationI')) { } 0 280 280
elsif (not $end) { } 0 280 280
elsif ($end < $start) { } 0 280 280
Condition33%2/6
defined $start and ref $start and $start->isa("Bio::LocationI")
!ll&&!rl&&r
28000
defined $start and ref $start
!ll&&!rl&&r
02800
MC/DC0%0/3
defined $start and ref $start and $start->isa("Bio::LocationI")
defined $start ref $start $start->isa("Bio::LocationI")
Truth table25%1/4
A and B and C
A= defined $startB= ref $startC= $start->isa("Bio::LocationI")
ABCresult
0XX0
10X0
1100
1111
449 $start->isa('Bio::LocationI') ) {
450 0 $str = $self->subseq($start); # start is a location actually
451 } elsif( !$end ) {
452 0 $self->throw("trunc start,end -- there was no end for $start");
453 } elsif( $end < $start ) {
454 0 my $msg = "start [$start] is greater than end [$end]. \n".
455 "If you want to truncated and reverse complement, \n".
456 "you must call trunc followed by revcom. Sorry.";
457 0 $self->throw($msg);
458 } else {
459 280 $str = $self->subseq($start,$end);
460 }
461  
462 # Create a new fresh object if $self is 'Bio::Seq::LargePrimarySeq'
463 # or 'Bio::Seq::LargeSeq', if not take advantage of
464 # Bio::Root::clone to get an object copy
465 280 my $out;
466 280 ▶ if ( $self->isa('Bio::Seq::LargePrimarySeq')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Bio::Seq::LargePrimarySeq') or $self->isa('Bio::Seq::LargeSeq') or $self->isa('Bio::Seq::RichSeq')) { } 8 272 280
Condition83%5/6
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq") or $self->isa("Bio::Seq::RichSeq")
l!l&&r!l&&!r
71272
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
l!l&&r!l&&!r
70273
MC/DC66%2/3
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq") or $self->isa("Bio::Seq::RichSeq")
$self->isa("Bio::Seq::LargePrimarySeq") $self->isa("Bio::Seq::LargeSeq") $self->isa("Bio::Seq::RichSeq")
Truth table75%3/4
A or B or C
A= $self->isa("Bio::Seq::LargePrimarySeq")B= $self->isa("Bio::Seq::LargeSeq")C= $self->isa("Bio::Seq::RichSeq")
ABCresult
1XX1
01X1
0011
0000
467 or $self->isa('Bio::Seq::LargeSeq')
468 or $self->isa('Bio::Seq::RichSeq')
469 ) {
470 8 my ($seqclass, $opts) = $self->_setup_class;
471 8 $out = $seqclass->new(
472 -seq => $str,
473 -is_circular => $self->is_circular,
474 -display_id => $self->display_id,
475 -accession_number => $self->accession_number,
476 -alphabet => $self->alphabet,
477 -desc => $self->desc,
478 -verbose => $self->verbose,
479 %$opts,
480 );
481 } else {
482 272 $out = $self->clone;
483 272 $out->seq($str);
484 }
485 280 return $out;
486 }
487  
488  
489 =head2 translate
490  
491 Title : translate
492 Usage : $protein_seq_obj = $dna_seq_obj->translate
493  
494 Or if you expect a complete coding sequence (CDS) translation,
495 with initiator at the beginning and terminator at the end:
496  
497 $protein_seq_obj = $cds_seq_obj->translate(-complete => 1);
498  
499 Or if you want translate() to find the first initiation
500 codon and return the corresponding protein:
501  
502 $protein_seq_obj = $cds_seq_obj->translate(-orf => 1);
503  
504 Function: Provides the translation of the DNA sequence using full
505 IUPAC ambiguities in DNA/RNA and amino acid codes.
506  
507 The complete CDS translation is identical to EMBL/TREMBL
508 database translation. Note that the trailing terminator
509 character is removed before returning the translated protein
510 object.
511  
512 Note: if you set $dna_seq_obj->verbose(1) you will get a
513 warning if the first codon is not a valid initiator.
514  
515 Returns : A Bio::PrimarySeqI implementing object
516 Args : -terminator
517 character for terminator, default '*'
518 -unknown
519 character for unknown, default 'X'
520 -frame
521 positive integer frame shift (in bases), default 0
522 -codontable_id
523 integer codon table id, default 1
524 -complete
525 boolean, if true, complete CDS is expected. default false
526 -complete_codons
527 boolean, if true, codons which are incomplete are translated if a
528 suitable amino acid is found. For instance, if the incomplete
529 codon is 'GG', the completed codon is 'GGN', which is glycine
530 (G). Defaults to 'false'; setting '-complete' also makes this
531 true.
532 -throw
533 boolean, throw exception if ORF not complete, default false
534 -orf
535 if 'longest', find longest ORF. other true value, find
536 first ORF. default 0
537 -codontable
538 optional L<Bio::Tools::CodonTable> object to use for
539 translation
540 -start
541 optional three-character string to force as initiation
542 codon (e.g. 'atg'). If unset, start codons are
543 determined by the CodonTable. Case insensitive.
544 -offset
545 optional positive integer offset for fuzzy locations.
546 if set, must be either 1, 2, or 3
547  
548 =head3 Notes
549  
550 The -start argument only applies when -orf is set to 1. By default all
551 initiation codons found in the given codon table are used but when
552 "start" is set to some codon this codon will be used exclusively as
553 the initiation codon. Note that the default codon table (NCBI
554 "Standard") has 3 initiation codons!
555  
556 By default translate() translates termination codons to the some
557 character (default is *), both internal and trailing codons. Setting
558 "-complete" to 1 tells translate() to remove the trailing character.
559  
560 -offset is used for seqfeatures which contain the the \codon_start tag
561 and can be set to 1, 2, or 3. This is the offset by which the
562 sequence translation starts relative to the first base of the feature
563  
564 For details on codon tables used by translate() see L<Bio::Tools::CodonTable>.
565  
566 Deprecated argument set (v. 1.5.1 and prior versions) where each argument is an
567 element in an array:
568  
569 1: character for terminator (optional), defaults to '*'.
570 2: character for unknown amino acid (optional), defaults to 'X'.
571 3: frame (optional), valid values are 0, 1, 2, defaults to 0.
572 4: codon table id (optional), defaults to 1.
573 5: complete coding sequence expected, defaults to 0 (false).
574 6: boolean, throw exception if not complete coding sequence
575 (true), defaults to warning (false)
576 7: codontable, a custom Bio::Tools::CodonTable object (optional).
577  
578 =cut
579  
580 222 ▶sub translate {
Subroutine translate: called CC=36 SCAR=42.8
Pod documented
581 222 my ($self,@args) = @_;
582 222 my ($terminator, $unknown, $frame, $codonTableId, $complete,
583 $complete_codons, $throw, $codonTable, $orf, $start_codon, $offset);
584  
585 ## new API with named parameters, post 1.5.1
586 222 ▶ if ($args[0] && $args[0] =~ /^-[A-Z]+/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[0] and $args[0] =~ /^-[A-Z]+/i) { } 3 219 222
Condition100%3/3
$args[0] and $args[0] =~ /^-[A-Z]+/i
!ll&&!rl&&r
21813
MC/DC100%2/2
$args[0] and $args[0] =~ /^-[A-Z]+/i
$args[0] $args[0] =~ /^-[A-Z]+/i
Truth table100%3/3
A and B
A= $args[0]B= $args[0] =~ /^-[A-Z]+/i
ABresult
0X0
100
111
587 3 ($terminator, $unknown, $frame, $codonTableId, $complete,
588 $complete_codons, $throw,$codonTable, $orf, $start_codon, $offset) =
589 $self->_rearrange([qw(TERMINATOR
590 UNKNOWN
591 FRAME
592 CODONTABLE_ID
593 COMPLETE
594 COMPLETE_CODONS
595 THROW
596 CODONTABLE
597 ORF
598 START
599 OFFSET)], @args);
600 ## old API, 1.5.1 and preceding versions
601 } else {
602 219 ($terminator, $unknown, $frame, $codonTableId,
603 $complete, $throw, $codonTable, $offset) = @args;
604 }
605
606 ## Initialize termination codon, unknown codon, codon table id, frame
607 222 ▶ $terminator = '*' unless (defined($terminator) and $terminator ne '');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $terminator and $terminator ne "" 221 1 222
Condition66%2/3
defined $terminator and $terminator ne ""
!ll&&!rl&&r
22101
MC/DC50%1/2
defined $terminator and $terminator ne ""
defined $terminator $terminator ne ""
Truth table66%2/3
A and B
A= defined $terminatorB= $terminator ne ""
ABresult
0X0
100
111
608 222 ▶ $unknown = "X" unless (defined($unknown) and $unknown ne '');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $unknown and $unknown ne "" 221 1 222
Condition66%2/3
defined $unknown and $unknown ne ""
!ll&&!rl&&r
22101
MC/DC50%1/2
defined $unknown and $unknown ne ""
defined $unknown $unknown ne ""
Truth table66%2/3
A and B
A= defined $unknownB= $unknown ne ""
ABresult
0X0
100
111
609 222 ▶ $frame = 0 unless (defined($frame) and $frame ne '');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $frame and $frame ne "" 207 15 222
Condition66%2/3
defined $frame and $frame ne ""
!ll&&!rl&&r
207015
MC/DC50%1/2
defined $frame and $frame ne ""
defined $frame $frame ne ""
Truth table66%2/3
A and B
A= defined $frameB= $frame ne ""
ABresult
0X0
100
111
610 222 ▶ $codonTableId = 1 unless (defined($codonTableId) and $codonTableId ne '');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $codonTableId and $codonTableId ne "" 197 25 222
Condition66%2/3
defined $codonTableId and $codonTableId ne ""
!ll&&!rl&&r
197025
MC/DC50%1/2
defined $codonTableId and $codonTableId ne ""
defined $codonTableId $codonTableId ne ""
Truth table66%2/3
A and B
A= defined $codonTableIdB= $codonTableId ne ""
ABresult
0X0
100
111
611 222 ▶ $complete_codons ||= $complete || 0;
Condition100%5/5
$complete_codons ||= $complete || 0
l!l&&r!l&&!r
32217
$complete || 0
l!l
2217
MC/DC100%2/2
$complete_codons ||= $complete || 0
$complete_codons $complete
Truth table100%3/3
A ||= B
A= $complete_codonsB= $complete
ABresult
1X1
011
000
612
613 ## Get a CodonTable, error if custom CodonTable is invalid
614 222 ▶ if ($codonTable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($codonTable) { } 1 221 222
615 1 ▶ $self->throw("Need a Bio::Tools::CodonTable object, not ". $codonTable)
Branch: 1 branch
BranchTrueFalseTotal
unless $codonTable->isa("Bio::Tools::CodonTable") 0 1 1
616 unless $codonTable->isa('Bio::Tools::CodonTable');
617 } else {
618
619 # shouldn't this be cached? Seems wasteful to have a new instance
620 # every time...
621 221 $codonTable = Bio::Tools::CodonTable->new( -id => $codonTableId);
622 }
623  
624 ## Error if alphabet is "protein"
625 222 ▶ $self->throw("Can't translate an amino acid sequence.") if
Branch: 1 branch
BranchTrueFalseTotal
if $self->alphabet =~ /protein/i 0 222 222
626 ($self->alphabet =~ /protein/i);
627  
628 ## Error if -start parameter isn't a valid codon
629 222 ▶ if ($start_codon) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_codon) 0 222 222
630 0 ▶ $self->throw("Invalid start codon: $start_codon.") if
Branch: 1 branch
BranchTrueFalseTotal
unless $start_codon =~ /^[A-Z]{3}$/i 0 0 0
631 ( $start_codon !~ /^[A-Z]{3}$/i );
632 }
633  
634 222 my $seq;
635 222 ▶ if ($offset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset) { } 0 222 222
636 0 ▶ $self->throw("Offset must be 1, 2, or 3.") if
Branch: 1 branch
BranchTrueFalseTotal
unless $offset =~ /^[123]$/ 0 0 0
637 ( $offset !~ /^[123]$/ );
638 0 my ($start, $end) = ($offset, $self->length);
639 0 ($seq) = $self->subseq($start, $end);
640 } else {
641 222 ($seq) = $self->seq();
642 }
643  
644 ## ignore frame if an ORF is supposed to be found
645 222 ▶ if ( $orf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orf) { } 0 222 222
646 0 ▶ my ($orf_region) = $self->_find_orfs_nucleotide( $seq, $codonTable, $start_codon, $orf eq 'longest' ? 0 : 'first_only' );
Branch: 1 branch
BranchTrueFalseTotal
$orf eq 'longest' ? : 0 0 0
647 0 $seq = $self->_orf_sequence( $seq, $orf_region );
648 } else {
649 ## use frame, error if frame is not 0, 1 or 2
650 222 ▶ $self->throw("Valid values for frame are 0, 1, or 2, not $frame.")
Branch: 1 branch
BranchTrueFalseTotal
unless $frame == 0 or $frame == 1 or $frame == 2 0 222 222
Condition83%5/6
$frame == 0 or $frame == 1 or $frame == 2
l!l&&r!l&&!r
21750
$frame == 0 or $frame == 1
l!l&&r!l&&!r
21255
MC/DC0%0/3
$frame == 0 or $frame == 1 or $frame == 2
$frame == 0 $frame == 1 $frame == 2
Truth table75%3/4
A or B or C
A= $frame == 0B= $frame == 1C= $frame == 2
ABCresult
1XX1
01X1
0011
0000
651 unless ($frame == 0 or $frame == 1 or $frame == 2);
652 222 $seq = substr($seq,$frame);
653 }
654  
655 ## Translate it
656 222 my $output = $codonTable->translate($seq, $complete_codons);
657 # Use user-input terminator/unknown
658 222 $output =~ s/\*/$terminator/g;
659 222 $output =~ s/X/$unknown/g;
660  
661 ## Only if we are expecting to translate a complete coding region
662 222 ▶ if ($complete) {
Branch: 1 branch
BranchTrueFalseTotal
if ($complete) 2 220 222
663 2 my $id = $self->display_id;
664 # remove the terminator character
665 2 ▶ if( substr($output,-1,1) eq $terminator ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($output, -1, 1) eq $terminator) { } 2 0 2
666 2 chop $output;
667 } else {
668 0 ▶ $throw && $self->throw("Seq [$id]: Not using a valid terminator codon!");
Branch: 1 branch
BranchTrueFalseTotal
$throw and $self->throw("Seq [$id]: Not using a valid terminator codon!") 0 0 0
669 0 $self->warn("Seq [$id]: Not using a valid terminator codon!");
670 }
671 # test if there are terminator characters inside the protein sequence!
672 2 ▶ if ($output =~ /\Q$terminator\E/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ /\Q$terminator\E/) 1 1 2
673 1 ▶ $id ||= '';
Condition50%1/2
$id ||= ""
l!l
10
MC/DC0%0/1
$id ||= ""
$id
Truth table50%1/2
A
A= $id
Aresult
11
00
674 1 ▶ $throw && $self->throw("Seq [$id]: Terminator codon inside CDS!");
Branch: 1 branch
BranchTrueFalseTotal
$throw and $self->throw("Seq [$id]: Terminator codon inside CDS!") 1 0 1
675 0 $self->warn("Seq [$id]: Terminator codon inside CDS!");
676 }
677 # if the initiator codon is not ATG, the amino acid needs to be changed to M
678 1 ▶ if ( substr($output,0,1) ne 'M' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($output, 0, 1) ne "M") 0 1 1
679 0 ▶ if ($codonTable->is_start_codon(substr($seq, 0, 3)) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($codonTable->is_start_codon(substr($seq, 0, 3))) { } 0 0 0
elsif ($throw) { } 0 0 0
680 0 $output = 'M'. substr($output,1);
681 } elsif ($throw) {
682 0 $self->throw("Seq [$id]: Not using a valid initiator codon!");
683 } else {
684 0 $self->warn("Seq [$id]: Not using a valid initiator codon!");
685 }
686 }
687 }
688  
689 # Create a new fresh object if $self is 'Bio::Seq::LargePrimarySeq'
690 # or 'Bio::Seq::LargeSeq', if not take advantage of
691 # Bio::Root::clone to get an object copy
692 221 my $out;
693 221 ▶ if ( $self->isa('Bio::Seq::LargePrimarySeq')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Bio::Seq::LargePrimarySeq') or $self->isa('Bio::Seq::LargeSeq')) { } 3 218 221
Condition100%3/3
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
l!l&&r!l&&!r
12218
MC/DC100%2/2
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
$self->isa("Bio::Seq::LargePrimarySeq") $self->isa("Bio::Seq::LargeSeq")
Truth table100%3/3
A or B
A= $self->isa("Bio::Seq::LargePrimarySeq")B= $self->isa("Bio::Seq::LargeSeq")
ABresult
1X1
011
000
694 or $self->isa('Bio::Seq::LargeSeq')
695 ) {
696 3 my ($seqclass, $opts) = $self->_setup_class;
697 3 $out = $seqclass->new(
698 -seq => $output,
699 -is_circular => $self->is_circular,
700 -display_id => $self->display_id,
701 -accession_number => $self->accession_number,
702 -alphabet => 'protein',
703 -desc => $self->desc,
704 -verbose => $self->verbose,
705 %$opts,
706 );
707 } else {
708 218 $out = $self->clone;
709 218 $out->seq($output);
710 218 $out->alphabet('protein');
711 }
712 221 return $out;
713 }
714  
715  
716 =head2 transcribe()
717  
718 Title : transcribe
719 Usage : $xseq = $seq->transcribe
720 Function: Convert base T to base U
721 Returns : PrimarySeqI object of alphabet 'rna' or
722 undef if $seq->alphabet ne 'dna'
723 Args :
724  
725 =cut
726  
727 2 ▶sub transcribe {
Subroutine transcribe: called CC=5 SCAR=16.9
Pod documented
728 2 my $self = shift;
729 2 ▶ return unless $self->alphabet eq 'dna';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->alphabet eq "dna" 1 1 2
730 1 my $s = $self->seq;
731 1 $s =~ tr/tT/uU/;
732 1 ▶ my $desc = $self->desc || '';
Condition50%1/2
$self->desc || ''
l!l
01
MC/DC0%0/1
$self->desc || ''
$self->desc
Truth table50%1/2
A
A= $self->desc
Aresult
11
00
733  
734 # Create a new fresh object if $self is 'Bio::Seq::LargePrimarySeq'
735 # or 'Bio::Seq::LargeSeq', if not take advantage of
736 # Bio::Root::clone to get an object copy
737 1 my $out;
738 1 ▶ if ( $self->isa('Bio::Seq::LargePrimarySeq')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Bio::Seq::LargePrimarySeq') or $self->isa('Bio::Seq::LargeSeq')) { } 0 1 1
Condition33%1/3
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
$self->isa("Bio::Seq::LargePrimarySeq") $self->isa("Bio::Seq::LargeSeq")
Truth table33%1/3
A or B
A= $self->isa("Bio::Seq::LargePrimarySeq")B= $self->isa("Bio::Seq::LargeSeq")
ABresult
1X1
011
000
739 or $self->isa('Bio::Seq::LargeSeq')
740 ) {
741 0 my ($seqclass, $opts) = $self->_setup_class;
742 0 $out = $seqclass->new(
743 -seq => $s,
744 -is_circular => $self->is_circular,
745 -display_id => $self->display_id,
746 -accession_number => $self->accession_number,
747 -alphabet => 'rna',
748 -desc => "${desc}[TRANSCRIBED]",
749 -verbose => $self->verbose,
750 %$opts,
751 );
752 } else {
753 1 $out = $self->clone;
754 1 $out->seq($s);
755 1 $out->alphabet('rna');
756 1 $out->desc($desc . "[TRANSCRIBED]");
757 }
758 1 return $out;
759 }
760  
761  
762 =head2 rev_transcribe()
763  
764 Title : rev_transcribe
765 Usage : $rtseq = $seq->rev_transcribe
766 Function: Convert base U to base T
767 Returns : PrimarySeqI object of alphabet 'dna' or
768 undef if $seq->alphabet ne 'rna'
769 Args :
770  
771 =cut
772  
773 1 ▶sub rev_transcribe {
Subroutine rev_transcribe: called CC=5 SCAR=17.4
Pod documented
774 1 my $self = shift;
775 1 ▶ return unless $self->alphabet eq 'rna';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->alphabet eq "rna" 0 1 1
776 1 my $s = $self->seq;
777 1 $s =~ tr/uU/tT/;
778 1 ▶ my $desc = $self->desc || '';
Condition50%1/2
$self->desc || ''
l!l
10
MC/DC0%0/1
$self->desc || ''
$self->desc
Truth table50%1/2
A
A= $self->desc
Aresult
11
00
779  
780 # Create a new fresh object if $self is 'Bio::Seq::LargePrimarySeq'
781 # or 'Bio::Seq::LargeSeq', if not take advantage of
782 # Bio::Root::clone to get an object copy
783 1 my $out;
784 1 ▶ if ( $self->isa('Bio::Seq::LargePrimarySeq')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Bio::Seq::LargePrimarySeq') or $self->isa('Bio::Seq::LargeSeq')) { } 0 1 1
Condition33%1/3
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->isa("Bio::Seq::LargePrimarySeq") or $self->isa("Bio::Seq::LargeSeq")
$self->isa("Bio::Seq::LargePrimarySeq") $self->isa("Bio::Seq::LargeSeq")
Truth table33%1/3
A or B
A= $self->isa("Bio::Seq::LargePrimarySeq")B= $self->isa("Bio::Seq::LargeSeq")
ABresult
1X1
011
000
785 or $self->isa('Bio::Seq::LargeSeq')
786 ) {
787 0 my ($seqclass, $opts) = $self->_setup_class;
788 0 $out = $seqclass->new(
789 -seq => $s,
790 -is_circular => $self->is_circular,
791 -display_id => $self->display_id,
792 -accession_number => $self->accession_number,
793 -alphabet => 'dna',
794 -desc => $self->desc . "[REVERSE TRANSCRIBED]",
795 -verbose => $self->verbose,
796 %$opts,
797 );
798 } else {
799 1 $out = $self->clone;
800 1 $out->seq($s);
801 1 $out->alphabet('dna');
802 1 $out->desc($desc . "[REVERSE TRANSCRIBED]");
803 }
804 1 return $out;
805 }
806  
807  
808 =head2 id
809  
810 Title : id
811 Usage : $id = $seq->id()
812 Function: ID of the sequence. This should normally be (and actually is in
813 the implementation provided here) just a synonym for display_id().
814 Returns : A string.
815 Args :
816  
817 =cut
818  
819 1 ▶sub id {
Subroutine id: called CC=1 SCAR=0.0
Pod documented
820 1 my ($self)= @_;
821 1 return $self->display_id();
822 }
823  
824  
825 =head2 length
826  
827 Title : length
828 Usage : $len = $seq->length()
829 Function:
830 Returns : Integer representing the length of the sequence.
831 Args :
832  
833 =cut
834  
835 0 ▶sub length {
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
836 0 my ($self)= @_;
837 0 $self->throw_not_implemented();
838 }
839  
840  
841 =head2 desc
842  
843 Title : desc
844 Usage : $seq->desc($newval);
845 $description = $seq->desc();
846 Function: Get/set description text for a seq object
847 Returns : Value of desc
848 Args : newvalue (optional)
849  
850 =cut
851  
852 0 ▶sub desc {
Subroutine desc: not called CC=1 SCAR=6.9
Pod documented
853 0 shift->throw_not_implemented();
854 }
855  
856  
857 =head2 is_circular
858  
859 Title : is_circular
860 Usage : if( $obj->is_circular) { # Do something }
861 Function: Returns true if the molecule is circular
862 Returns : Boolean value
863 Args : none
864  
865 =cut
866  
867 0 ▶sub is_circular {
Subroutine is_circular: not called CC=1 SCAR=6.9
Pod documented
868 0 shift->throw_not_implemented;
869 }
870  
871  
872 =head1 Private functions
873  
874 These are some private functions for the PrimarySeqI interface. You do not
875 need to implement these functions
876  
877 =head2 _find_orfs_nucleotide
878  
879 Title : _find_orfs_nucleotide
880 Usage :
881 Function: Finds ORF starting at 1st initiation codon in nucleotide sequence.
882 The ORF is not required to have a termination codon.
883 Example :
884 Returns : a list of string coordinates of ORF locations (0-based half-open),
885 sorted descending by length (so that the longest is first)
886 as: [ start, end, frame, length ], [ start, end, frame, length ], ...
887 Args : Nucleotide sequence,
888 CodonTable object,
889 (optional) alternative initiation codon (e.g. 'ATA'),
890 (optional) boolean that, if true, stops after finding the
891 first available ORF
892  
893 =cut
894  
895 0 ▶sub _find_orfs_nucleotide {
Subroutine _find_orfs_nucleotide: not called CC=11 SCAR=48.8
896 0 my ( $self, $sequence, $codon_table, $start_codon, $first_only ) = @_;
897 0 $sequence = uc $sequence;
898 0 ▶ $start_codon = uc $start_codon if $start_codon;
Branch: 1 branch
BranchTrueFalseTotal
if $start_codon 0 0 0
899  
900 my $is_start = $start_codon
901 0 ▶ ? sub { shift eq $start_codon }
Subroutine __ANON__: not called CC=1 SCAR=6.9
902 0 ▶ : sub { $codon_table->is_start_codon( shift ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$start_codon ? : 0 0 0
903  
904 # stores the begin index of the currently-running ORF in each
905 # reading frame
906 0 my @current_orf_start = (-1,-1,-1);
907  
908 #< stores coordinates of longest observed orf (so far) in each
909 # reading frame
910 0 my @orfs;
911  
912 # go through each base of the sequence, and each reading frame for each base
913 0 my $seqlen = CORE::length $sequence;
914 0 my @start_frame_order;
915 0 ▶ for( my $j = 0; $j <= $seqlen-3; $j++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $seqlen - 3) 0 0 0
916 0 my $frame = $j % 3;
917  
918 0 my $this_codon = substr( $sequence, $j, 3 );
919  
920 # if in an orf and this is either a stop codon or the last in-frame codon in the string
921 0 ▶ if ( $current_orf_start[$frame] >= 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($current_orf_start[$frame] >= 0) { } 0 0 0
elsif (&$is_start($this_codon)) { } 0 0 0
922 0 ▶ if ( $codon_table->is_ter_codon( $this_codon ) ||( my $is_last_codon_in_frame = ($j >= $seqlen-5)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($codon_table->is_ter_codon($this_codon) or my $is_last_codon_in_frame = $j >= $seqlen - 5) 0 0 0
Condition0%0/3
$codon_table->is_ter_codon($this_codon) or my $is_last_codon_in_frame = $j >= $seqlen - 5
l!l&&r!l&&!r
000
MC/DC0%0/2
$codon_table->is_ter_codon($this_codon) or my $is_last_codon_in_frame = $j >= $seqlen - 5
$codon_table->is_ter_codon($this_codon) my $is_last_codon_in_frame = $j >= $seqlen - 5
Truth table0%0/3
A or B
A= $codon_table->is_ter_codon($this_codon)B= my $is_last_codon_in_frame = $j >= $seqlen - 5
ABresult
1X1
011
000
923 # record ORF start, end (half-open), length, and frame
924 0 my @this_orf = ( $current_orf_start[$frame], $j+3, undef, $frame );
925 0 my $this_orf_length = $this_orf[2] = ( $this_orf[1] - $this_orf[0] );
926  
927 0 ▶ if ($first_only && $frame == $start_frame_order[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_only and $frame == $start_frame_order[0]) 0 0 0
Condition0%0/3
$first_only and $frame == $start_frame_order[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$first_only and $frame == $start_frame_order[0]
$first_only $frame == $start_frame_order[0]
Truth table0%0/3
A and B
A= $first_onlyB= $frame == $start_frame_order[0]
ABresult
0X0
100
111
928 0 ▶ $self->warn( "Translating partial ORF "
Branch: 1 branch
BranchTrueFalseTotal
if $is_last_codon_in_frame 0 0 0
929 .$self->_truncate_seq( $self->_orf_sequence( $sequence, \@this_orf ))
930 .' from end of nucleotide sequence'
931 ) if $is_last_codon_in_frame;
932 0 return \@this_orf;
933 }
934 0 push @orfs, \@this_orf;
935 0 $current_orf_start[$frame] = -1;
936 }
937 }
938 # if this is a start codon
939 elsif ( $is_start->($this_codon) ) {
940 0 $current_orf_start[$frame] = $j;
941 0 push @start_frame_order, $frame;
942 }
943 }
944  
945 0 return sort { $b->[2] <=> $a->[2] } @orfs;
946 }
947  
948  
949 0 ▶sub _truncate_seq {
Subroutine _truncate_seq: not called CC=2 SCAR=17.9
950 0 my ($self, $seq) = @_;
951 0 ▶ return CORE::length($seq) > 200 ? substr($seq,0,50).'...'.substr($seq,-50) : $seq;
Branch: 1 branch
BranchTrueFalseTotal
CORE::length $seq > 200 ? : 0 0 0
952 }
953  
954  
955 0 ▶sub _orf_sequence {
Subroutine _orf_sequence: not called CC=2 SCAR=17.9
956 0 my ($self, $seq, $orf ) = @_;
957 0 ▶ return '' unless $orf;
Branch: 1 branch
BranchTrueFalseTotal
unless $orf 0 0 0
958 0 return substr( $seq, $orf->[0], $orf->[2] )
959 }
960  
961  
962 =head2 _attempt_to_load_Seq
963  
964 Title : _attempt_to_load_Seq
965 Usage :
966 Function:
967 Example :
968 Returns :
969 Args :
970  
971 =cut
972  
973 0 ▶sub _attempt_to_load_Seq {
Subroutine _attempt_to_load_Seq: not called CC=3 SCAR=24.8
974 0 my ($self) = @_;
975  
976 0 ▶ if( $main::{'Bio::PrimarySeq'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::main::{'Bio::PrimarySeq'}) { } 0 0 0
977 0 return 1;
978 } else {
979 0 eval {
980 0 require Bio::PrimarySeq;
981 };
982 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
983 0 my $text = "Bio::PrimarySeq could not be loaded for [$self]\n".
984 "This indicates that you are using Bio::PrimarySeqI ".
985 "without Bio::PrimarySeq loaded or without providing a ".
986 "complete implementation.\nThe most likely problem is that there ".
987 "has been a misconfiguration of the bioperl environment\n".
988 "Actual exception:\n\n";
989 0 $self->throw("$text$@\n");
990 0 return 0;
991 }
992 0 return 1;
993 }
994 }
995  
996  
997 11 ▶sub _setup_class {
Subroutine _setup_class: called CC=3 SCAR=12.3
998 # Return name of class and setup some default parameters
999 11 my ($self) = @_;
1000 11 my $seqclass;
1001 11 ▶ if ($self->can_call_new()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can_call_new) { } 11 0 11
1002 11 $seqclass = ref($self);
1003 } else {
1004 0 $seqclass = 'Bio::PrimarySeq';
1005 0 $self->_attempt_to_load_Seq();
1006 }
1007 11 my %opts;
1008 11 ▶ if ($seqclass eq 'Bio::PrimarySeq') {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqclass eq "Bio::PrimarySeq") 0 11 11
1009 # Since sequence is in a Seq object, it has already been validated.
1010 # We do not need to validate its trunc(), revcom(), etc
1011 0 $opts{ -direct } = 1;
1012 }
1013 11 return $seqclass, \%opts;
1014 }
1015  
1016  
1017 340 1;
« Bio/SearchIO/sim4.pm ↑ Summary Bio/Tools/ipcress.pm »