Bio/AlignIO.pm

filter: Statementstmt 88.3% 91 / 103 Branchbran 54.8% 34 / 62 Conditioncond 32.1% 9 / 28 MC/DCmcdc 11.7% 2 / 17 Subroutinesub 90.0% 18 / 20 Podpod 100% 7 / 7 totaltotal 67.9% 161 / 237 CC 42 SCAR 24.6
CC
42
Cov
69%
_guess_format
21.2
new
17.3
alphabet
13.1
CRAP 11.7
« Bio/SeqIO/raw.pm ↑ Summary Bio/Tools/Spidey/Results.pm »
1 #
2 # BioPerl module for Bio::AlignIO
3 #
4 # based on the Bio::SeqIO module
5 # by Ewan Birney <birney@ebi.ac.uk>
6 # and Lincoln Stein <lstein@cshl.org>
7 #
8 # Copyright Peter Schattner
9 #
10 # You may distribute this module under the same terms as perl itself
11 #
12 # History
13 # September, 2000 AlignIO written by Peter Schattner
14  
15 # POD documentation - main docs before the code
16  
17 =head1 NAME
18  
19 Bio::AlignIO - Handler for AlignIO Formats
20  
21 =head1 SYNOPSIS
22  
23 use Bio::AlignIO;
24  
25 $inputfilename = "testaln.fasta";
26 $in = Bio::AlignIO->new(-file => $inputfilename ,
27 -format => 'fasta');
28 $out = Bio::AlignIO->new(-file => ">out.aln.pfam" ,
29 -format => 'pfam');
30  
31 while ( my $aln = $in->next_aln() ) {
32 $out->write_aln($aln);
33 }
34  
35 # OR
36  
37 use Bio::AlignIO;
38  
39 open MYIN, '<', 'testaln.fasta' or die "Could not read file 'testaln.fasta': $!\n";
40 $in = Bio::AlignIO->newFh(-fh => \*MYIN,
41 -format => 'fasta');
42 open my $MYOUT, '>', 'testaln.pfam' or die "Could not write file 'testaln.pfam': $!\n";
43 $out = Bio::AlignIO->newFh(-fh => $MYOUT,
44 -format => 'pfam');
45  
46 # World's smallest Fasta<->pfam format converter:
47 print $out $_ while <$in>;
48  
49 =head1 DESCRIPTION
50  
51 L<Bio::AlignIO> is a handler module for the formats in the AlignIO set,
52 for example, L<Bio::AlignIO::fasta>. It is the officially sanctioned way
53 of getting at the alignment objects. The resulting alignment is a
54 L<Bio::Align::AlignI>-compliant object.
55  
56 The idea is that you request an object for a particular format.
57 All the objects have a notion of an internal file that is read
58 from or written to. A particular AlignIO object instance is configured
59 for either input or output, you can think of it as a stream object.
60  
61 Each object has functions:
62  
63 $stream->next_aln();
64  
65 And:
66  
67 $stream->write_aln($aln);
68  
69 Also:
70  
71 $stream->type() # returns 'INPUT' or 'OUTPUT'
72  
73 As an added bonus, you can recover a filehandle that is tied to the
74 AlignIO object, allowing you to use the standard E<lt>E<gt> and print
75 operations to read and write alignment objects:
76  
77 use Bio::AlignIO;
78  
79 # read from standard input
80 $stream = Bio::AlignIO->newFh(-format => 'Fasta');
81  
82 while ( $aln = <$stream> ) {
83 # do something with $aln
84 }
85  
86 And:
87  
88 print $stream $aln; # when stream is in output mode
89  
90 L<Bio::AlignIO> is patterned on the L<Bio::SeqIO> module and shares
91 most of its features. One significant difference is that
92 L<Bio::AlignIO> usually handles IO for only a single alignment at a time,
93 whereas L<Bio::SeqIO> handles IO for multiple sequences in a single stream.
94 The principal reason for this is that whereas simultaneously handling
95 multiple sequences is a common requirement, simultaneous handling of
96 multiple alignments is not. The only current exception is format
97 C<bl2seq> which parses results of the BLAST C<bl2seq> program and which
98 may produce several alignment pairs. This set of alignment pairs can
99 be read using multiple calls to L<next_aln>.
100  
101 =head1 CONSTRUCTORS
102  
103 =head2 Bio::AlignIO-E<gt>new()
104  
105 $seqIO = Bio::AlignIO->new(-file => 'filename', -format=>$format);
106 $seqIO = Bio::AlignIO->new(-fh => \*FILEHANDLE, -format=>$format);
107 $seqIO = Bio::AlignIO->new(-format => $format);
108 $seqIO = Bio::AlignIO->new(-fh => \*STDOUT, -format => $format);
109  
110 The L<new> class method constructs a new L<Bio::AlignIO> object.
111 The returned object can be used to retrieve or print alignment
112 objects. L<new> accepts the following parameters:
113  
114 =over 4
115  
116 =item -file
117  
118 A file path to be opened for reading or writing. The usual Perl
119 conventions apply:
120  
121 'file' # open file for reading
122 '>file' # open file for writing
123 '>>file' # open file for appending
124 '+<file' # open file read/write
125 'command |' # open a pipe from the command
126 '| command' # open a pipe to the command
127  
128 =item -fh
129  
130 You may provide new() with a previously-opened filehandle. For
131 example, to read from STDIN:
132  
133 $seqIO = Bio::AlignIO->new(-fh => \*STDIN);
134  
135 Note that you must pass filehandles as references to globs.
136  
137 If neither a filehandle nor a filename is specified, then the module
138 will read from the @ARGV array or STDIN, using the familiar E<lt>E<gt>
139 semantics.
140  
141 =item -format
142  
143 Specify the format of the file. Supported formats include:
144  
145 bl2seq Bl2seq Blast output
146 clustalw clustalw (.aln) format
147 emboss EMBOSS water and needle format
148 fasta FASTA format
149 maf Multiple Alignment Format
150 mase mase (seaview) format
151 mega MEGA format
152 meme MEME format
153 msf msf (GCG) format
154 nexus Swofford et al NEXUS format
155 pfam Pfam sequence alignment format
156 phylip Felsenstein PHYLIP format
157 prodom prodom (protein domain) format
158 psi PSI-BLAST format
159 selex selex (hmmer) format
160 stockholm stockholm format
161  
162 Currently only those formats which were implemented in L<Bio::SimpleAlign>
163 have been incorporated into L<Bio::AlignIO>. Specifically, C<mase>, C<stockholm>
164 and C<prodom> have only been implemented for input. See the specific module
165 (e.g. L<Bio::AlignIO::prodom>) for notes on supported versions.
166  
167 If no format is specified and a filename is given, then the module
168 will attempt to deduce it from the filename suffix. If this is unsuccessful,
169 C<fasta> format is assumed.
170  
171 The format name is case insensitive; C<FASTA>, C<Fasta> and C<fasta> are
172 all treated equivalently.
173  
174 =back
175  
176 =head2 Bio::AlignIO-E<gt>newFh()
177  
178 $fh = Bio::AlignIO->newFh(-fh => \*FILEHANDLE, -format=>$format);
179 # read from STDIN or use @ARGV:
180 $fh = Bio::AlignIO->newFh(-format => $format);
181  
182 This constructor behaves like L<new>, but returns a tied filehandle
183 rather than a L<Bio::AlignIO> object. You can read sequences from this
184 object using the familiar E<lt>E<gt> operator, and write to it using
185 L<print>. The usual array and $_ semantics work. For example, you can
186 read all sequence objects into an array like this:
187  
188 @sequences = <$fh>;
189  
190 Other operations, such as read(), sysread(), write(), close(), and printf()
191 are not supported.
192  
193 =over 1
194  
195 =item -flush
196  
197 By default, all files (or filehandles) opened for writing alignments
198 will be flushed after each write_aln() making the file immediately
199 usable. If you do not need this facility and would like to marginally
200 improve the efficiency of writing multiple sequences to the same file
201 (or filehandle), pass the -flush option '0' or any other value that
202 evaluates as defined but false:
203  
204 my $clustal = Bio::AlignIO->new( -file => "<prot.aln",
205 -format => "clustalw" );
206 my $msf = Bio::AlignIO->new(-file => ">prot.msf",
207 -format => "msf",
208 -flush => 0 ); # go as fast as we can!
209 while($seq = $clustal->next_aln) { $msf->write_aln($seq) }
210  
211 =back
212  
213 =head1 OBJECT METHODS
214  
215 See below for more detailed summaries. The main methods are:
216  
217 =head2 $alignment = $AlignIO-E<gt>next_aln()
218  
219 Fetch an alignment from a formatted file.
220  
221 =head2 $AlignIO-E<gt>write_aln($aln)
222  
223 Write the specified alignment to a file..
224  
225 =head2 TIEHANDLE(), READLINE(), PRINT()
226  
227 These provide the tie interface. See L<perltie> for more details.
228  
229 =head1 FEEDBACK
230  
231 =head2 Mailing Lists
232  
233 User feedback is an integral part of the evolution of this and other
234 Bioperl modules. Send your comments and suggestions preferably to one
235 of the Bioperl mailing lists. Your participation is much appreciated.
236  
237 bioperl-l@bioperl.org - General discussion
238 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
239  
240 =head2 Support
241  
242 Please direct usage questions or support issues to the mailing list:
243  
244 I<bioperl-l@bioperl.org>
245  
246 rather than to the module maintainer directly. Many experienced and
247 reponsive experts will be able look at the problem and quickly
248 address it. Please include a thorough description of the problem
249 with code and data examples if at all possible.
250  
251 =head2 Reporting Bugs
252  
253 Report bugs to the Bioperl bug tracking system to help us keep track
254 the bugs and their resolution. Bug reports can be submitted via the
255 web:
256  
257 https://github.com/bioperl/bioperl-live/issues
258  
259 =head1 AUTHOR - Peter Schattner
260  
261 Email: schattner@alum.mit.edu
262  
263 =head1 CONTRIBUTORS
264  
265 Jason Stajich, jason@bioperl.org
266  
267 =head1 APPENDIX
268  
269 The rest of the documentation details each of the object
270 methods. Internal methods are usually preceded with a _
271  
272 =cut
273  
274 # 'Let the code begin...
275  
276 package Bio::AlignIO;
277 53 $Bio::AlignIO::VERSION = '1.7.8';
278 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
279  
280 53 ▶use Bio::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
281 53 ▶use Bio::LocatableSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
282 53 ▶use Bio::SimpleAlign;
Subroutine BEGIN: called CC=1 SCAR=0.0
283 53 ▶use Bio::Tools::GuessSeqFormat;
Subroutine BEGIN: called CC=1 SCAR=0.0
284 53 ▶use base qw(Bio::Root::Root Bio::Root::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
285  
286 =head2 new
287  
288 Title : new
289 Usage : $stream = Bio::AlignIO->new(-file => $filename,
290 -format => 'Format')
291 Function: Returns a new seqstream
292 Returns : A Bio::AlignIO::Handler initialised with
293 the appropriate format
294 Args : -file => $filename
295 -format => format
296 -fh => filehandle to attach to
297 -displayname_flat => 1 [optional]
298 to force the displayname to not show start/end
299 information
300  
301 =cut
302  
303 674 ▶sub new {
Subroutine new: called CC=12 SCAR=28.5
Pod documented
304 674 my ($caller,@args) = @_;
305 674 ▶ my $class = ref($caller) || $caller;
Condition33%1/3
ref $caller || $caller
l!l&&r!l&&!r
06740
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
306  
307 # or do we want to call SUPER on an object if $caller is an
308 # object?
309 674 ▶ if( $class =~ /Bio::AlignIO::(\S+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class =~ /Bio::AlignIO::(\S+)/) { } 337 337 674
310 337 my ($self) = $class->SUPER::new(@args);
311 337 $self->_initialize(@args);
312 337 return $self;
313 } else {
314  
315 337 my %param = @args;
316 337 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
317 my $format = $param{'-format'} ||
318 337 ▶ $class->_guess_format( $param{-file} || $ARGV[0] );
Condition66%4/6
$param{'-format'} || $class->_guess_format($param{'-file'} || $ARGV[0])
l!l&&r!l&&!r
33061
$param{'-file'} || $ARGV[0]
l!l&&r!l&&!r
700
MC/DC100%2/2
$param{'-format'} || $class->_guess_format($param{'-file'} || $ARGV[0])
$param{'-format'} $class->_guess_format($param{'-file'} || $ARGV[0])
MC/DC0%0/2
$param{'-file'} || $ARGV[0]
$param{'-file'} $ARGV[0]
Truth table100%3/3
A || B
A= $param{'-format'}B= $class->_guess_format($param{'-file'} || $ARGV[0])
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= $param{'-file'}B= $ARGV[0]
ABresult
1X1
011
000
319 337 ▶ unless ($format) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($format) 1 336 337
320 1 ▶ if ($param{-file}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($param{'-file'}) { } 1 0 1
elsif ($param{'-fh'}) { } 0 0 0
321 1 ▶ $format = Bio::Tools::GuessSeqFormat->new(-file => $param{-file}||$ARGV[0] )->guess;
Condition33%1/3
$param{'-file'} || $ARGV[0]
l!l&&r!l&&!r
100
MC/DC0%0/2
$param{'-file'} || $ARGV[0]
$param{'-file'} $ARGV[0]
Truth table33%1/3
A || B
A= $param{'-file'}B= $ARGV[0]
ABresult
1X1
011
000
322 }
323 elsif ($param{-fh}) {
324 0 ▶ $format = Bio::Tools::GuessSeqFormat->new(-fh => $param{-fh}||$ARGV[0] )->guess;
Condition0%0/3
$param{'-fh'} || $ARGV[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$param{'-fh'} || $ARGV[0]
$param{'-fh'} $ARGV[0]
Truth table0%0/3
A || B
A= $param{'-fh'}B= $ARGV[0]
ABresult
1X1
011
000
325 }
326 }
327 337 $format = "\L$format"; # normalize capitalization to lower case
328 337 ▶ $class->throw("Unknown format given or could not determine it [$format]")
Branch: 1 branch
BranchTrueFalseTotal
unless $format 0 337 337
329 unless $format;
330  
331 337 ▶ return unless( $class->_load_format_module($format) );
Branch: 1 branch
BranchTrueFalseTotal
unless $class->_load_format_module($format) 0 337 337
332 337 return "Bio::AlignIO::$format"->new(@args);
333 }
334 }
335  
336  
337 =head2 newFh
338  
339 Title : newFh
340 Usage : $fh = Bio::AlignIO->newFh(-file=>$filename,-format=>'Format')
341 Function: does a new() followed by an fh()
342 Example : $fh = Bio::AlignIO->newFh(-file=>$filename,-format=>'Format')
343 $sequence = <$fh>; # read a sequence object
344 print $fh $sequence; # write a sequence object
345 Returns : filehandle tied to the Bio::AlignIO::Fh class
346 Args :
347  
348 =cut
349  
350 256 ▶sub newFh {
Subroutine newFh: called CC=2 SCAR=7.1
Pod documented
351 256 my $class = shift;
352 256 ▶ return unless my $self = $class->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless my $self = $class->new(@_) 0 256 256
353 256 return $self->fh;
354 }
355  
356 =head2 fh
357  
358 Title : fh
359 Usage : $obj->fh
360 Function:
361 Example : $fh = $obj->fh; # make a tied filehandle
362 $sequence = <$fh>; # read a sequence object
363 print $fh $sequence; # write a sequence object
364 Returns : filehandle tied to the Bio::AlignIO::Fh class
365 Args :
366  
367 =cut
368  
369  
370 256 ▶sub fh {
Subroutine fh: called CC=2 SCAR=7.2
Pod documented
371 256 my $self = shift;
372 256 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
25600
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
373 256 my $s = Symbol::gensym;
374 256 tie $$s,$class,$self;
375 256 return $s;
376 }
377  
378  
379 =head2 format
380  
381 Title : format
382 Usage : $format = $stream->format()
383 Function: Get the alignment format
384 Returns : alignment format
385 Args : none
386  
387 =cut
388  
389 # format() method inherited from Bio::Root::IO
390  
391  
392 # _initialize is where the heavy stuff will happen when new is called
393  
394 337 ▶sub _initialize {
Subroutine _initialize: called CC=3 SCAR=11.2
395 337 my($self,@args) = @_;
396 337 my ($flat,$alphabet,$width) = $self->_rearrange([qw(DISPLAYNAME_FLAT ALPHABET WIDTH)],
397 @args);
398 337 ▶ $self->force_displayname_flat($flat) if defined $flat;
Branch: 1 branch
BranchTrueFalseTotal
if defined $flat 0 337 337
399 337 $self->alphabet($alphabet);
400 337 ▶ $self->width($width) if defined $width;
Branch: 1 branch
BranchTrueFalseTotal
if defined $width 0 337 337
401 337 $self->_initialize_io(@args);
402 337 1;
403 }
404  
405 =head2 _load_format_module
406  
407 Title : _load_format_module
408 Usage : *INTERNAL AlignIO stuff*
409 Function: Loads up (like use) a module at run time on demand
410 Example :
411 Returns :
412 Args :
413  
414 =cut
415  
416 337 ▶sub _load_format_module {
Subroutine _load_format_module: called CC=2 SCAR=7.3
417 337 my ($self,$format) = @_;
418 337 my $module = "Bio::AlignIO::" . $format;
419 337 my $ok;
420  
421 337 eval {
422 337 $ok = $self->_load_module($module);
423 };
424 337 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 337 337
425 0 print STDERR <<END;
426 $self: $format cannot be found
427 Exception $@
428 For more information about the AlignIO system please see the AlignIO docs.
429 This includes ways of checking for formats at compile time, not run time
430 END
431 ;
432 0 return;
433 }
434 337 return 1;
435 }
436  
437 =head2 next_aln
438  
439 Title : next_aln
440 Usage : $aln = stream->next_aln
441 Function: reads the next $aln object from the stream
442 Returns : a Bio::Align::AlignI compliant object
443 Args :
444  
445 =cut
446  
447 0 ▶sub next_aln {
Subroutine next_aln: not called CC=1 SCAR=6.9
Pod documented
448 0 my ($self,$aln) = @_;
449 0 $self->throw("Sorry, you cannot read from a generic Bio::AlignIO object.");
450 }
451  
452 =head2 write_aln
453  
454 Title : write_aln
455 Usage : $stream->write_aln($aln)
456 Function: writes the $aln object into the stream
457 Returns : 1 for success and 0 for error
458 Args : Bio::Seq object
459  
460 =cut
461  
462 0 ▶sub write_aln {
Subroutine write_aln: not called CC=1 SCAR=6.9
Pod documented
463 0 my ($self,$aln) = @_;
464 0 $self->throw("Sorry, you cannot write to a generic Bio::AlignIO object.");
465 }
466  
467 =head2 _guess_format
468  
469 Title : _guess_format
470 Usage : $obj->_guess_format($filename)
471 Function:
472 Example :
473 Returns : guessed format of filename (lower case)
474 Args :
475  
476 =cut
477  
478 7 ▶sub _guess_format {
Subroutine _guess_format: called CC=17 SCAR=30.6
479 7 my $class = shift;
480 7 ▶ return unless $_ = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ = shift() 0 7 7
481 7 ▶ return 'clustalw' if /\.aln$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.aln$/i 0 7 7
482 7 ▶ return 'emboss' if /\.(water|needle)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(water|needle)$/i 0 7 7
483 7 ▶ return 'metafasta' if /\.metafasta$/;
Branch: 1 branch
BranchTrueFalseTotal
if /\.metafasta$/ 1 6 7
484 6 ▶ return 'fasta' if /\.(fasta|fast|seq|fa|fsa|nt|aa)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(fasta|fast|seq|fa|fsa|nt|aa)$/i 0 6 6
485 6 ▶ return 'maf' if /\.maf/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.maf/i 2 4 6
486 4 ▶ return 'mega' if /\.(meg|mega)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(meg|mega)$/i 0 4 4
487 4 ▶ return 'meme' if /\.meme$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.meme$/i 0 4 4
488 4 ▶ return 'msf' if /\.(msf|pileup|gcg)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(msf|pileup|gcg)$/i 1 3 4
489 3 ▶ return 'nexus' if /\.(nexus|nex)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(nexus|nex)$/i 0 3 3
490 3 ▶ return 'pfam' if /\.(pfam|pfm)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(pfam|pfm)$/i 2 1 3
491 1 ▶ return 'phylip' if /\.(phylip|phlp|phyl|phy|ph)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(phylip|phlp|phyl|phy|ph)$/i 0 1 1
492 1 ▶ return 'psi' if /\.psi$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.psi$/i 0 1 1
493 1 ▶ return 'stockholm' if /\.stk$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.stk$/i 0 1 1
494 1 ▶ return 'selex' if /\.(selex|slx|selx|slex|sx)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.(selex|slx|selx|slex|sx)$/i 0 1 1
495 1 ▶ return 'xmfa' if /\.xmfa$/i;
Branch: 1 branch
BranchTrueFalseTotal
if /\.xmfa$/i 0 1 1
496 }
497  
498 593 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
499 593 my $self = shift;
500 593 $self->close();
501 }
502  
503 256 ▶sub TIEHANDLE {
Subroutine TIEHANDLE: called CC=1 SCAR=0.0
504 256 my $class = shift;
505 256 return bless {'alignio' => shift},$class;
506 }
507  
508 128 ▶sub READLINE {
Subroutine READLINE: called CC=4 SCAR=20.9
509 128 my $self = shift;
510 128 ▶ return $self->{'alignio'}->next_aln() || undef unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 128 0 128
Condition50%1/2
$self->{'alignio'}->next_aln || undef
l!l
1280
MC/DC0%0/1
$self->{'alignio'}->next_aln || undef
$self->{'alignio'}->next_aln
Truth table50%1/2
A
A= $self->{'alignio'}->next_aln
Aresult
11
00
511 0 my (@list,$obj);
512 0 ▶ push @list,$obj while $obj = $self->{'alignio'}->next_aln();
Branch: 1 branch
BranchTrueFalseTotal
$obj = $self->{"alignio"}->next_aln and do { push @list, $obj } 0 0 0
513 0 return @list;
514 }
515  
516 12 ▶sub PRINT {
Subroutine PRINT: called CC=1 SCAR=0.0
517 12 my $self = shift;
518 12 $self->{'alignio'}->write_aln(@_);
519 }
520  
521  
522 =head2 force_displayname_flat
523  
524 Title : force_displayname_flat
525 Usage : $obj->force_displayname_flat($newval)
526 Function:
527 Example :
528 Returns : value of force_displayname_flat (a scalar)
529 Args : on set, new value (a scalar or undef, optional)
530  
531  
532 =cut
533  
534 4 ▶sub force_displayname_flat{
Subroutine force_displayname_flat: called CC=3 SCAR=11.7
Pod documented
535 4 my $self = shift;
536 4 ▶ return $self->{'_force_displayname_flat'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
537 4 ▶ return $self->{'_force_displayname_flat'} || 0;
Condition50%1/2
$self->{'_force_displayname_flat'} || 0
l!l
04
MC/DC0%0/1
$self->{'_force_displayname_flat'} || 0
$self->{'_force_displayname_flat'}
Truth table50%1/2
A
A= $self->{'_force_displayname_flat'}
Aresult
11
00
538 }
539  
540 =head2 alphabet
541  
542 Title : alphabet
543 Usage : $obj->alphabet($newval)
544 Function: Get/Set alphabet for purpose of passing to Bio::LocatableSeq creation
545 Example : $obj->alphabet('dna');
546 Returns : value of alphabet (a scalar)
547 Args : on set, new value (a scalar or undef, optional)
548  
549  
550 =cut
551  
552 2205 ▶sub alphabet {
Subroutine alphabet: called CC=5 SCAR=25.7
Pod documented
553 2205 my $self = shift;
554 2205 my $value = shift;
555 2205 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 2205 2205
556 0 ▶ $self->throw("Invalid alphabet $value") unless $value eq 'rna' || $value eq 'protein' || $value eq 'dna';
Branch: 1 branch
BranchTrueFalseTotal
unless $value eq "rna" or $value eq "protein" or $value eq "dna" 0 0 0
Condition0%0/6
$value eq "rna" or $value eq "protein" or $value eq "dna"
l!l&&r!l&&!r
000
$value eq "rna" or $value eq "protein"
l!l&&r!l&&!r
000
MC/DC0%0/3
$value eq "rna" or $value eq "protein" or $value eq "dna"
$value eq "rna" $value eq "protein" $value eq "dna"
Truth table0%0/4
A or B or C
A= $value eq "rna"B= $value eq "protein"C= $value eq "dna"
ABCresult
1XX1
01X1
0011
0000
557 0 $self->{'_alphabet'} = $value;
558 }
559 2205 return $self->{'_alphabet'};
560 }
561  
562  
563 53 1;
« Bio/SeqIO/raw.pm ↑ Summary Bio/Tools/Spidey/Results.pm »