blib/lib/Bio/Gonzales/Seq/IO/Fasta.pm

filter: Statementstmt 90.3% 56 / 62 Branchbran 66.6% 12 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 82.1% 78 / 95 CC 11 SCAR 13.3
CC
11
Cov
83%
BUILD
5.9
next_seq
5.0
__ANON__
3.6
CRAP 3.8
« blib/lib/Bio/Gonzales/Range/Cluster.pm ↑ Summary blib/lib/Bio/Gonzales/Graphics/Glyph/colorfulBox.pm »
1 package Bio::Gonzales::Seq::IO::Fasta;
2  
3  
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 with 'Bio::Gonzales::Util::Role::FileIO';
9  
10 3 ▶use Bio::Gonzales::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Bio::Gonzales::Util::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 our $VERSION = '0.058'; # VERSION
16  
17 around BUILDARGS => sub {
18 5 ▶ my $orig = shift;
Subroutine __ANON__: called CC=3 SCAR=12.7
19 5 my $class = shift;
20  
21 5 ▶ if ( @_ == 1 && Bio::Gonzales::Util::File::is_fh( $_[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and Bio::Gonzales::Util::File::is_fh($_[0])) { } 5 0 5
Condition33%1/3
@_ == 1 and Bio::Gonzales::Util::File::is_fh($_[0])
!ll&&!rl&&r
005
MC/DC0%0/2
@_ == 1 and Bio::Gonzales::Util::File::is_fh($_[0])
@_ == 1 Bio::Gonzales::Util::File::is_fh($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= Bio::Gonzales::Util::File::is_fh($_[0])
ABresult
0X0
100
111
22 5 return $class->$orig( fh => $_[0] );
23 } else {
24 0 return $class->$orig(@_);
25 }
26 3 };
27  
28 sub BUILD {
29 5 ▶ my ($self) = @_;
Subroutine BUILD: called CC=5 SCAR=17.8
30  
31 5 my $fhi = $self->_fhi;
32  
33 5 my $line;
34 5 ▶ while ( $line = $fhi->() ) { last if $line =~ /\S/ } # not supposed to have blanks, but...
Branch: 2 branches
BranchTrueFalseTotal
if ($line = &$fhi()) 5 0 5
if $line =~ /\S/ 5 0 5
35  
36 5 my $firstline = $line;
37  
38 5 ▶ if ( not defined $firstline ) { carp "FASTA file is empty\n"; return $self }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $firstline) 0 5 5
39  
40 5 ▶ if ( $firstline !~ s/^>\s*// ) { confess "Not FASTA formatted: >>$firstline<<\n"; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($firstline =~ s/^>\s*//) 0 5 5
41  
42 5 push @{ $self->_cached_records }, $firstline;
43 }
44  
45 3 my $i = 0;
46  
47 sub next_seq {
48 60 ▶ my ($self) = @_;
Subroutine next_seq: called CC=5 SCAR=16.1
Pod undocumented
49  
50 60 my $fhi = $self->_fhi;
51 60 my $def = $fhi->();
52 60 ▶ unless ($def) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($def) 5 55 60
53 5 $self->close;
54 5 return;
55 }
56  
57 55 my @seq;
58 55 my $lines_read = 0;
59 55 ▶ while ( defined( my $line = $fhi->() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = &$fhi())) 109 5 114
60 109 $lines_read++;
61 109 ▶ if ( $line =~ s/^>\s*// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/^>\s*//) 50 59 109
62 50 push @{ $self->_cached_records }, $line;
63 50 last;
64 }
65 59 push @seq, $line;
66 }
67 55 ▶ if ( $lines_read == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lines_read == 0) 0 55 55
68 0 $self->close;
69 0 return;
70  
71 }
72  
73 55 my ( $id, $delim, $desc ) = split( /(\s+)/, $def, 2 );
74 55 my $entry = Bio::Gonzales::Seq->new( id => $id, delim => $delim, desc => $desc, seq => \@seq );
75 55 return $entry;
76 }
77  
78 3 1;
« blib/lib/Bio/Gonzales/Range/Cluster.pm ↑ Summary blib/lib/Bio/Gonzales/Graphics/Glyph/colorfulBox.pm »