line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Gonzales::Seq::IO::Fasta; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
55
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
267
|
|
5
|
8
|
|
|
8
|
|
46
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
161
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
2813
|
use Mouse; |
|
8
|
|
|
|
|
127497
|
|
|
8
|
|
|
|
|
54
|
|
8
|
|
|
|
|
|
|
with 'Bio::Gonzales::Util::Role::FileIO'; |
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
8224
|
use Bio::Gonzales::Seq; |
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
296
|
|
11
|
8
|
|
|
8
|
|
1574
|
use Bio::Gonzales::Util::File; |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
671
|
|
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
60
|
use Carp; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
4795
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.083'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
around BUILDARGS => sub { |
18
|
|
|
|
|
|
|
my $orig = shift; |
19
|
|
|
|
|
|
|
my $class = shift; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if ( @_ == 1 && Bio::Gonzales::Util::File::is_fh( $_[0] ) ) { |
22
|
|
|
|
|
|
|
return $class->$orig( fh => $_[0] ); |
23
|
|
|
|
|
|
|
} else { |
24
|
|
|
|
|
|
|
return $class->$orig(@_); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub BUILD { |
29
|
|
|
|
|
|
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $fhi = $self->_fhi; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $line; |
34
|
|
|
|
|
|
|
while ( $line = $fhi->() ) { last if $line =~ /\S/ } # not supposed to have blanks, but... |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $firstline = $line; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ( not defined $firstline ) { carp "FASTA file is empty\n"; return $self } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
if ( $firstline !~ s/^>\s*// ) { confess "Not FASTA formatted: >>$firstline<<\n"; } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
push @{ $self->_cached_records }, $firstline; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $i = 0; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub next_seq { |
48
|
60
|
|
|
60
|
0
|
113
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
60
|
|
|
|
|
123
|
my $fhi = $self->_fhi; |
51
|
60
|
|
|
|
|
143
|
my $def = $fhi->(); |
52
|
60
|
100
|
|
|
|
128
|
unless (defined $def) { |
53
|
5
|
|
|
|
|
25
|
$self->close; |
54
|
5
|
|
|
|
|
17
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
55
|
|
|
|
|
80
|
my @seq; |
58
|
55
|
|
|
|
|
87
|
my $lines_read = 0; |
59
|
55
|
|
|
|
|
128
|
while ( defined( my $line = $fhi->() ) ) { |
60
|
109
|
|
|
|
|
161
|
$lines_read++; |
61
|
109
|
100
|
|
|
|
379
|
if ( $line =~ s/^>\s*// ) { |
62
|
50
|
|
|
|
|
80
|
push @{ $self->_cached_records }, $line; |
|
50
|
|
|
|
|
127
|
|
63
|
50
|
|
|
|
|
125
|
last; |
64
|
|
|
|
|
|
|
} |
65
|
59
|
|
|
|
|
181
|
push @seq, $line; |
66
|
|
|
|
|
|
|
} |
67
|
55
|
50
|
|
|
|
121
|
if ( $lines_read == 0 ) { |
68
|
0
|
|
|
|
|
0
|
$self->close; |
69
|
0
|
|
|
|
|
0
|
return; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
55
|
|
|
|
|
249
|
my ( $id, $delim, $desc ) = split( /(\s+)/, $def, 2 ); |
74
|
55
|
|
|
|
|
334
|
my $entry = Bio::Gonzales::Seq->new( id => $id, delim => $delim, desc => $desc, seq => \@seq ); |
75
|
55
|
|
|
|
|
398
|
return $entry; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |