File Coverage

blib/lib/Bio/FASTASequence/File.pm
Criterion Covered Total %
statement 12 33 36.3
branch 0 8 0.0
condition 0 4 0.0
subroutine 4 8 50.0
pod 2 3 66.6
total 18 56 32.1


line stmt bran cond sub pod time code
1             package Bio::FASTASequence::File;
2              
3 1     1   8379 use 5.006001;
  1         4  
  1         39  
4 1     1   6 use strict;
  1         2  
  1         30  
5 1     1   5 use warnings;
  1         12  
  1         33  
6 1     1   865 use Bio::FASTASequence;
  1         3739  
  1         333  
7              
8             our $VERSION = '0.04';
9              
10              
11             # Preloaded methods go here.
12              
13             sub new{
14 0     0 1   my ($class,$filename) = @_;
15 0           my $self = {};
16 0   0       $self->{file} = $filename || '';
17 0 0         _parse_file($self) if($self->{file});
18 0           bless($self,$class);
19 0           return $self;
20             }# end new
21              
22             sub file{
23 0     0 1   my ($self,$file) = @_;
24 0   0       $self->{file} = $file || '';
25 0 0         _parse_file($self) if($self->{file});
26 0           return $self->{result};
27             }# end file
28              
29             sub get_result{
30 0     0 0   my ($self) = @_;
31 0           return $self->{result};
32             }# end get_parsed
33              
34             sub _parse_file{
35 0     0     my ($self) = @_;
36 0           local $/ = "\n>";
37 0 0         open(FH,$self->{file}) or die($self->{file}.": ".$!);
38 0           while(my $entry = ){
39 0 0         $entry = '>'.$entry unless($entry =~ /^>/);
40 0           $entry =~ s/>$//;
41 0           my $seq = Bio::FASTASequence->new($entry);
42 0           $self->{result}->{$seq->getAccessionNr()} = $seq;
43             }
44 0           close FH;
45             }
46              
47             1;
48             __END__