Bio/SeqIO/fasta.pm

filter: Statementstmt 73.8% 96 / 130 Branchbran 53.9% 41 / 76 Conditioncond 36.7% 18 / 49 MC/DCmcdc 19.3% 6 / 31 Subroutinesub 91.6% 11 / 12 Podpod 83.3% 5 / 6 totaltotal 58.2% 177 / 304 CC 59 SCAR 39.2
CC
59
Cov
61%
next_seq_fast
156.0
write_seq
54.8
next_seq
15.7
CRAP 50.2
« Bio/OntologyIO/simplehierarchy.pm ↑ Summary Bio/SearchIO/cross_match.pm »
1 # BioPerl module for Bio::SeqIO::fasta
2 #
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
4 #
5 # Cared for by Ewan Birney <birney@ebi.ac.uk>
6 # and Lincoln Stein <lstein@cshl.org>
7 #
8 # Copyright Ewan Birney & Lincoln Stein
9 #
10 # You may distribute this module under the same terms as perl itself
11 # _history
12 # October 18, 1999 Largely rewritten by Lincoln Stein
13  
14 # POD documentation - main docs before the code
15  
16 =head1 NAME
17  
18 Bio::SeqIO::fasta - fasta sequence input/output stream
19  
20 =head1 SYNOPSIS
21  
22 Do not use this module directly. Use it via the Bio::SeqIO class.
23  
24 =head1 DESCRIPTION
25  
26 This object can transform Bio::Seq objects to and from fasta flat
27 file databases.
28  
29 =head1 FEEDBACK
30  
31 =head2 Mailing Lists
32  
33 User feedback is an integral part of the evolution of this and other
34 Bioperl modules. Send your comments and suggestions preferably to one
35 of the Bioperl mailing lists. Your participation is much appreciated.
36  
37 bioperl-l@bioperl.org - General discussion
38 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
39  
40 =head2 Support
41  
42 Please direct usage questions or support issues to the mailing list:
43  
44 I<bioperl-l@bioperl.org>
45  
46 rather than to the module maintainer directly. Many experienced and
47 reponsive experts will be able look at the problem and quickly
48 address it. Please include a thorough description of the problem
49 with code and data examples if at all possible.
50  
51 =head2 Reporting Bugs
52  
53 Report bugs to the Bioperl bug tracking system to help us keep track
54 the bugs and their resolution. Bug reports can be submitted via the
55 web:
56  
57 https://github.com/bioperl/bioperl-live/issues
58  
59 =head1 AUTHORS - Ewan Birney & Lincoln Stein
60  
61 Email: birney@ebi.ac.uk
62 lstein@cshl.org
63  
64 =head1 CONTRIBUTORS
65  
66 Jason Stajich, jason-at-bioperl.org
67  
68 =head1 APPENDIX
69  
70 The rest of the documentation details each of the object
71 methods. Internal methods are usually preceded with a _
72  
73 =cut
74  
75 # Let the code begin...
76  
77 package Bio::SeqIO::fasta;
78 19 $Bio::SeqIO::fasta::VERSION = '1.7.8';
79 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 19 ▶use Bio::Seq::SeqFastaSpeedFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 19 ▶use parent qw(Bio::SeqIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 32 ▶sub _initialize {
Subroutine _initialize: called CC=4 SCAR=13.9
87 32 my ($self, @args) = @_;
88 32 $self->SUPER::_initialize(@args);
89  
90 ## Initialize fasta specific parameters
91 ## There are some problems with _rearrange. If there's no value for one of
92 ## the parameters, it will return an empty value (not undef). This means we
93 ## can't just merge two hashes since the empty values would override the
94 ## defaults anyway.
95 32 my (%defs) = (
96 "width" => 60,
97 "block" => "", # default is same as width
98 "preferred_id_type" => "display",
99 );
100 32 foreach my $param (keys %defs) {
101 $self->$param( $self->_rearrange([$param], @args) ||
102 96 ▶ $defs{$param});
Condition66%2/3
$self->_rearrange([$param], @args) || $defs{$param}
l!l&&r!l&&!r
06432
MC/DC50%1/2
$self->_rearrange([$param], @args) || $defs{$param}
$self->_rearrange([$param], @args) $defs{$param}
Truth table66%2/3
A || B
A= $self->_rearrange([$param], @args)B= $defs{$param}
ABresult
1X1
011
000
103 }
104  
105 32 ▶ unless ( defined $self->sequence_factory ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->sequence_factory) 31 1 32
106 31 $self->sequence_factory(Bio::Seq::SeqFastaSpeedFactory->new());
107 }
108 }
109  
110 =head2 next_seq
111  
112 Title : next_seq
113 Usage : $seq = $stream->next_seq()
114 Function: returns the next sequence in the stream
115 Returns : Bio::Seq object, or nothing if no more available
116 Args : NONE
117  
118 =cut
119  
120 67 ▶sub next_seq {
Subroutine next_seq: called CC=14 SCAR=27.5
Pod documented
121 67 my( $self ) = @_;
122 67 my $seq;
123 my $alphabet;
124 67 local $/ = "\n>";
125 67 ▶ return unless my $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $self->_readline 8 59 67
126  
127 # Replacing chomp for s///, since chomp is not working in some cases
128 59 $entry =~ s/\n$//;
129 59 $entry =~ s/\r$//;
130 59 ▶ if ($entry =~ m/\A\s*\Z/s) { # very first one
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /\A\s*\Z/s) 0 59 59
131 0 ▶ return unless $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry = $self->_readline 0 0 0
132 0 chomp($entry);
133 }
134  
135 # this just checks the initial input; beyond that, due to setting $/ above,
136 # the > is part of the record separator and is removed
137 59 ▶ $self->throw("The sequence does not appear to be FASTA format ".
Branch: 1 branch
BranchTrueFalseTotal
if $. == 1 and not $entry =~ /^>/ 1 58 59
Condition100%3/3
$. == 1 and not $entry =~ /^>/
!ll&&!rl&&r
35231
MC/DC100%2/2
$. == 1 and not $entry =~ /^>/
$. == 1 not $entry =~ /^>/
Truth table100%3/3
A and not(B)
A= $. == 1B= not $entry =~ /^>/
ABresult
0X0
100
111
138 "(lacks a descriptor line '>')") if $. == 1 && $entry !~ /^>/;
139  
140 58 $entry =~ s/^>//;
141  
142 58 my ($top,$sequence) = split(/\n/,$entry,2);
143 58 ▶ defined $sequence && $sequence =~ s/>//g;
Branch: 1 branch
BranchTrueFalseTotal
defined $sequence and $sequence =~ s/>//g 57 1 58
144 #my ($top,$sequence) = $entry =~ /^>?(.+?)\n+([^>]*)/s
145 # or $self->throw("Can't parse fasta entry");
146  
147 58 my ($id,$fulldesc);
148 58 ▶ if( $top =~ /^\s*(\S+)\s*(.*)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($top =~ /^\s*(\S+)\s*(.*)/) 58 0 58
149 58 ($id,$fulldesc) = ($1,$2);
150 }
151  
152 0 ▶ if (defined $id && $id eq '') {$id=$fulldesc;} # FIX incase no space
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id and $id eq "") 0 58 58
Condition33%1/3
defined $id and $id eq ""
!ll&&!rl&&r
0580
MC/DC0%0/2
defined $id and $id eq ""
defined $id $id eq ""
Truth table33%1/3
A and B
A= defined $idB= $id eq ""
ABresult
0X0
100
111
153 # between > and name \AE
154 58 ▶ defined $sequence && $sequence =~ tr/ \t\n\r//d; # Remove whitespace
Branch: 1 branch
BranchTrueFalseTotal
defined $sequence and $sequence =~ tr/\t\n\r //d 57 1 58
155  
156 # for empty sequences we need to know the mol.type
157 58 $alphabet = $self->alphabet();
158 58 ▶ if(defined $sequence && length($sequence) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sequence and length $sequence == 0) 2 56 58
Condition100%3/3
defined $sequence and length $sequence == 0
!ll&&!rl&&r
1552
MC/DC100%2/2
defined $sequence and length $sequence == 0
defined $sequence length $sequence == 0
Truth table100%3/3
A and B
A= defined $sequenceB= length $sequence == 0
ABresult
0X0
100
111
159 2 ▶ if(! defined($alphabet)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $alphabet) 2 0 2
160 # let's default to dna
161 2 $alphabet = "dna";
162 }
163 }# else {
164 # we don't need it really, so disable
165 # we want to keep this if SeqIO alphabet was set by user
166 # not sure if this could break something
167 #$alphabet = undef;
168 #}
169  
170 58 $seq = $self->sequence_factory->create(
171 -seq => $sequence,
172 -id => $id,
173 # Ewan's note - I don't think this healthy
174 # but obviously to taste.
175 #-primary_id => $id,
176 -desc => $fulldesc,
177 -alphabet => $alphabet,
178 -direct => 1,
179 );
180  
181 # if there wasn't one before, set the guessed type
182 #unless ( defined $alphabet ) {
183 # don't assume that all our seqs are the same as the first one found
184 #$self->alphabet($seq->alphabet());
185 #}
186 58 return $seq;
187  
188 }
189 =head2 next_seq_fast
190  
191 Title : next_seq_fast
192 Usage : $seq = $stream->next_seq_fast()
193 Function: returns the next sequence in the stream
194 Favors speed over perfection.
195 Returns : Bio::Seq object, or nothing if no more available
196 Args : NONE
197  
198 =cut
199  
200 0 ▶sub next_seq_fast {
Subroutine next_seq_fast: not called CC=12 SCAR=50.5
Pod undocumented
201 0 my( $self ) = @_;
202 0 my $seq;
203 my $alphabet;
204 0 local $/ = "\n>";
205 0 ▶ return unless my $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $self->_readline 0 0 0
206  
207 # Replacing chomp for s///, since chomp is not working in some cases
208 0 $entry =~ s/\n(?:\r)$//;
209 0 ▶ if ($entry =~ m/\A\s*\Z/s) { # very first one
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /\A\s*\Z/s) 0 0 0
210 0 ▶ return unless $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry = $self->_readline 0 0 0
211 0 chomp($entry);
212 }
213  
214 # this just checks the initial input; beyond that, due to setting $/ above,
215 # the > is part of the record separator and is removed
216 0 ▶ $self->throw("The sequence does not appear to be FASTA format ".
Branch: 1 branch
BranchTrueFalseTotal
if $. == 1 and not $entry =~ /^>/ 0 0 0
Condition0%0/3
$. == 1 and not $entry =~ /^>/
!ll&&!rl&&r
000
MC/DC0%0/2
$. == 1 and not $entry =~ /^>/
$. == 1 not $entry =~ /^>/
Truth table0%0/3
A and not(B)
A= $. == 1B= not $entry =~ /^>/
ABresult
0X0
100
111
217 "(lacks a descriptor line '>')") if $. == 1 && $entry !~ /^>/;
218  
219 0 $entry =~ s/\s*>\s*//g;
220 #$entry =~ tr/>//;
221  
222 0 my ($top,$sequence) = split(/\n/,$entry,2);
223 0 ▶ $sequence ||= "";
Condition0%0/2
$sequence ||= ""
l!l
00
MC/DC0%0/1
$sequence ||= ""
$sequence
Truth table0%0/2
A
A= $sequence
Aresult
11
00
224 0 $sequence =~ s/\s+//g;
225  
226 0 my ($id,$fulldesc) = split(/\S+/, $top, 2);
227 0 ▶ $id ||= $top;
Condition0%0/3
$id ||= $top
l!l&&r!l&&!r
000
MC/DC0%0/2
$id ||= $top
$id $top
Truth table0%0/3
A ||= B
A= $idB= $top
ABresult
1X1
011
000
228 0 ▶ $fulldesc ||= "";
Condition0%0/2
$fulldesc ||= ""
l!l
00
MC/DC0%0/1
$fulldesc ||= ""
$fulldesc
Truth table0%0/2
A
A= $fulldesc
Aresult
11
00
229  
230 # for empty sequences we need to know the mol.type
231 0 $alphabet = $self->alphabet();
232 0 ▶ if(defined $sequence && length($sequence) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sequence and length $sequence == 0) 0 0 0
Condition0%0/3
defined $sequence and length $sequence == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $sequence and length $sequence == 0
defined $sequence length $sequence == 0
Truth table0%0/3
A and B
A= defined $sequenceB= length $sequence == 0
ABresult
0X0
100
111
233 0 ▶ if(! defined($alphabet)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $alphabet) 0 0 0
234 # let's default to dna
235 0 $alphabet = "dna";
236 }
237 }
238  
239 0 $seq = $self->sequence_factory->create(
240 -seq => $sequence,
241 -id => $id,
242 # Ewan's note - I don't think this healthy
243 # but obviously to taste.
244 #-primary_id => $id,
245 -desc => $fulldesc,
246 -alphabet => $alphabet,
247 -direct => 1,
248 );
249  
250 0 return $seq;
251  
252 }
253  
254 =head2 write_seq
255  
256 Title : write_seq
257 Usage : $stream->write_seq(@seq)
258 Function: Writes the $seq object into the stream
259 Returns : 1 for success and 0 for error
260 Args : Array of 1 or more Bio::PrimarySeqI objects
261  
262 =cut
263  
264 7 ▶sub write_seq {
Subroutine write_seq: called CC=25 SCAR=40.0
Pod documented
265 7 my ($self,@seq) = @_;
266 7 my $width = $self->width;
267 7 my $block = $self->block;
268  
269 ## take a reference for single string (the sequence) and add the whitespace
270 7 ▶ local *format_str = sub {
Subroutine __ANON__: called CC=3 SCAR=12.5
271 7 my $str = $_[0];
272 7 my @lines = unpack ("(A$width)*", $$str);
273 7 ▶ if ($block >= $width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($block >= $width) { } 7 0 7
274 7 $$str = join ("\n", @lines)."\n";
275 } else {
276 0 $$str = "";
277 0 $$str .= join (" ", unpack ("(A$block)*", $_)) . "\n" foreach (@lines);
278 }
279 7 };
280  
281 7 foreach my $seq (@seq) {
282 7 ▶ $self->throw("Did not provide a valid Bio::PrimarySeqI object")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seq and ref $seq and $seq->isa("Bio::PrimarySeqI") 0 7 7
Condition33%2/6
defined $seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
007
defined $seq and ref $seq
!ll&&!rl&&r
007
MC/DC0%0/3
defined $seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
defined $seq ref $seq $seq->isa("Bio::PrimarySeqI")
Truth table25%1/4
A and B and C
A= defined $seqB= ref $seqC= $seq->isa("Bio::PrimarySeqI")
ABCresult
0XX0
10X0
1100
1111
283 unless defined $seq && ref($seq) && $seq->isa('Bio::PrimarySeqI');
284  
285 # Allow for different ids
286 7 my $top;
287 7 my $id_type = $self->preferred_id_type;
288 7 ▶ if( $id_type =~ /^acc/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($id_type =~ /^acc/i) { } 0 7 7
elsif ($id_type =~ /^displ/i) { } 7 0 7
elsif ($id_type =~ /^pri/i) { } 0 0 0
289 0 $top = $seq->accession_number();
290 0 ▶ if( $id_type =~ /vers/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id_type =~ /vers/i) 0 0 0
291 0 $top .= "." . $seq->version();
292 }
293 } elsif($id_type =~ /^displ/i ) {
294 7 ▶ $self->warn("No whitespace allowed in FASTA ID [". $seq->display_id. "]")
Branch: 1 branch
BranchTrueFalseTotal
if defined $seq->display_id and $seq->display_id =~ /\s/ 0 7 7
Condition33%1/3
defined $seq->display_id and $seq->display_id =~ /\s/
!ll&&!rl&&r
070
MC/DC0%0/2
defined $seq->display_id and $seq->display_id =~ /\s/
defined $seq->display_id $seq->display_id =~ /\s/
Truth table33%1/3
A and B
A= defined $seq->display_idB= $seq->display_id =~ /\s/
ABresult
0X0
100
111
295 if defined $seq->display_id && $seq->display_id =~ /\s/;
296 7 $top = $seq->display_id();
297 7 ▶ $top = '' unless defined $top;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $top 0 7 7
298 7 ▶ $self->warn("No whitespace allowed in FASTA ID [". $top. "]")
Branch: 1 branch
BranchTrueFalseTotal
if defined $top and $top =~ /\s/ 0 7 7
Condition33%1/3
defined $top and $top =~ /\s/
!ll&&!rl&&r
070
MC/DC0%0/2
defined $top and $top =~ /\s/
defined $top $top =~ /\s/
Truth table33%1/3
A and B
A= defined $topB= $top =~ /\s/
ABresult
0X0
100
111
299 if defined $top && $top =~ /\s/;
300 } elsif($id_type =~ /^pri/i ) {
301 0 $top = $seq->primary_id();
302 }
303  
304 7 ▶ if ($seq->can('desc') and my $desc = $seq->desc()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can("desc") and my $desc = $seq->desc) 6 1 7
Condition66%2/3
$seq->can("desc") and my $desc = $seq->desc
!ll&&!rl&&r
016
MC/DC50%1/2
$seq->can("desc") and my $desc = $seq->desc
$seq->can("desc") my $desc = $seq->desc
Truth table66%2/3
A and B
A= $seq->can("desc")B= my $desc = $seq->desc
ABresult
0X0
100
111
305 6 $desc =~ s/\n//g;
306 6 $top .= " $desc";
307 }
308  
309 7 ▶ if( $seq->isa('Bio::Seq::LargeSeqI') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->isa('Bio::Seq::LargeSeqI')) { } 1 6 7
310 1 $self->_print(">$top\n");
311 # for large seqs, don't call seq(), it defeats the
312 # purpose of the largeseq functionality. instead get
313 # chunks of the seq, $width at a time
314 1 my $buff_max = 2000;
315 1 my $buff_size = int($buff_max/$width)*$width; #< buffer is even multiple of widths
316 1 my $seq_length = $seq->length;
317 1 my $num_chunks = int($seq_length/$buff_size+1);
318 1 ▶ for( my $c = 0; $c < $num_chunks; $c++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c < $num_chunks) 1 1 2
319 1 my $buff_end = $buff_size*($c+1);
320 1 ▶ $buff_end = $seq_length if $buff_end > $seq_length;
Branch: 1 branch
BranchTrueFalseTotal
if $buff_end > $seq_length 1 0 1
321 1 my $buff = $seq->subseq($buff_size*$c+1,$buff_end);
322 1 ▶ if($buff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff) { } 1 0 1
323 1 format_str (\$buff);
324 1 $self->_print($buff);
325 } else {
326 0 $self->_print("\n");
327 }
328 }
329 } else {
330 6 my $str = $seq->seq;
331 6 ▶ if(defined $str && length($str) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $str and length $str > 0) { } 6 0 6
Condition33%1/3
defined $str and length $str > 0
!ll&&!rl&&r
006
MC/DC0%0/2
defined $str and length $str > 0
defined $str length $str > 0
Truth table33%1/3
A and B
A= defined $strB= length $str > 0
ABresult
0X0
100
111
332 6 format_str (\$str);
333 } else {
334 0 $str = "\n";
335 }
336 6 ▶ $self->_print (">",$top,"\n",$str) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print(">", $top, "\n", $str) or return 6 0 6
337 }
338 }
339  
340 7 ▶ $self->flush if $self->_flush_on_write && defined $self->_fh;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_flush_on_write and defined $self->_fh 7 0 7
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
!ll&&!rl&&r
007
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
ABresult
0X0
100
111
341 7 return 1;
342 }
343  
344 =head2 width
345  
346 Title : width
347 Usage : $obj->width($newval)
348 Function: Get/Set the line width for FASTA output (not counting whitespace).
349 Returns : value of width
350 Args : newvalue (optional)
351  
352 =cut
353  
354 78 ▶sub width {
Subroutine width: called CC=2 SCAR=6.9
Pod documented
355 78 my ($self,$value) = @_;
356 78 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 32 46 78
357 32 $self->{'width'} = $value;
358 }
359 78 return $self->{'width'};
360 }
361  
362 =head2 block
363  
364 Title : block
365 Usage : $obj->block($newval)
366 Function: Get/Set the length of each block for FASTA output. Sequence blocks
367 will be split with a space. Configuring block, to a value of 10 for
368 example, allows one to easily identify a position in a sequence by eye.
369 Default : same value used for width.
370 Returns : value of block
371 Args : newvalue (optional)
372  
373 =cut
374  
375 39 ▶sub block {
Subroutine block: called CC=3 SCAR=11.3
Pod documented
376 39 my ($self,$value) = @_;
377 39 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 32 7 39
378 32 $self->{'block'} = $value;
379 }
380 39 ▶ return $self->{'block'} || $self->width;
Condition33%1/3
$self->{'block'} || $self->width
l!l&&r!l&&!r
0390
MC/DC0%0/2
$self->{'block'} || $self->width
$self->{'block'} $self->width
Truth table33%1/3
A || B
A= $self->{'block'}B= $self->width
ABresult
1X1
011
000
381 }
382  
383 =head2 preferred_id_type
384  
385 Title : preferred_id_type
386 Usage : $obj->preferred_id_type('accession')
387 Function: Get/Set the preferred type of identifier to use in the ">ID" position
388 for FASTA output.
389 Returns : string, one of values defined in @Bio::SeqIO::fasta::SEQ_ID_TYPES.
390 Default : display
391 Args : string when setting. This must be one of values defined in
392 @Bio::SeqIO::fasta::SEQ_ID_TYPES. Allowable values:
393 accession, accession.version, display, primary
394 Throws : fatal exception if the supplied id type is not in @SEQ_ID_TYPES.
395  
396 =cut
397  
398 19 our @SEQ_ID_TYPES = qw(accession accession.version display primary);
399  
400 40 ▶sub preferred_id_type {
Subroutine preferred_id_type: called CC=3 SCAR=11.2
Pod documented
401 40 my ($self,$type) = @_;
402 40 ▶ if (defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 33 7 40
403 33 ▶ if( ! grep lc($type) eq $_, @SEQ_ID_TYPES) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep((lc $type eq $_), @Bio::SeqIO::fasta::SEQ_ID_TYPES)) 0 33 33
404 0 $self->throw(-class=>'Bio::Root::BadParameter',
405 -text=>"Invalid ID type \"$type\". Must be one of: @SEQ_ID_TYPES");
406 }
407 33 $self->{'_seq_id_type'} = lc($type);
408 }
409 40 $self->{'_seq_id_type'};
410 }
411  
412 19 1;
« Bio/OntologyIO/simplehierarchy.pm ↑ Summary Bio/SearchIO/cross_match.pm »