« 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 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 8 | with 'Bio::Gonzales::Util::Role::FileIO'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Bio::Gonzales::Seq; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Bio::Gonzales::Util::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | our $VERSION = '0.062'; # 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
Condition33%1/3
@_ == 1 and Bio::Gonzales::Util::File::is_fh($_[0])
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])
| |||||||||||||||||||||||||||||
| 22 | 5 | return $class->$orig( fh => $_[0] ); | |||||||||||||||||||||||||||
| 23 | } else { | ||||||||||||||||||||||||||||
| 24 | 0 | return $class->$orig(@_); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 8 | }; | |||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 5 | my $firstline = $line; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 5 | ▶ | if ( not defined $firstline ) { carp "FASTA file is empty\n"; return $self } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 5 | ▶ | if ( $firstline !~ s/^>\s*// ) { confess "Not FASTA formatted: >>$firstline<<\n"; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 5 | push @{ $self->_cached_records }, $firstline; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 8 | 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 60 | 109 | $lines_read++; | |||||||||||||||||||||||||||
| 61 | 109 | ▶ | if ( $line =~ s/^>\s*// ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 | 8 | 1; | |||||||||||||||||||||||||||