File Coverage

lib/Bio/Roary/SequenceLengths.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Bio::Roary::SequenceLengths;
2             $Bio::Roary::SequenceLengths::VERSION = '3.10.1';
3             # ABSTRACT: Take in a fasta file and create a hash with the length of each sequence
4              
5              
6 2     2   570482 use Moose;
  2         396305  
  2         14  
7 2     2   13304 use Bio::SeqIO;
  2         112814  
  2         81  
8 2     2   680 use Bio::Roary::Exceptions;
  2         7  
  2         345  
9              
10             has 'fasta_file' => ( is => 'ro', isa => 'Str', required => 1 );
11             has 'sequence_lengths' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_sequence_lengths' );
12             has '_input_seqio' => ( is => 'ro', isa => 'Bio::SeqIO', lazy => 1, builder => '_build__input_seqio' );
13              
14             sub _build__input_seqio {
15 1     1   2 my ($self) = @_;
16 1         21 return Bio::SeqIO->new( -file => $self->fasta_file, -format => 'Fasta' );
17             }
18              
19             sub _build_sequence_lengths {
20 1     1   2 my ($self) = @_;
21              
22 1         1 my %sequence_lengths;
23 1         23 while ( my $input_seq = $self->_input_seqio->next_seq() ) {
24 6         863 $sequence_lengths{ $input_seq->display_id } = $input_seq->length();
25             }
26 1         46 return \%sequence_lengths;
27             }
28              
29 2     2   30 no Moose;
  2         3  
  2         20  
30             __PACKAGE__->meta->make_immutable;
31              
32             1;
33              
34             __END__
35              
36             =pod
37              
38             =encoding UTF-8
39              
40             =head1 NAME
41              
42             Bio::Roary::SequenceLengths - Take in a fasta file and create a hash with the length of each sequence
43              
44             =head1 VERSION
45              
46             version 3.10.1
47              
48             =head1 SYNOPSIS
49              
50             Add labels to the groups
51             use Bio::Roary::SequenceLengths;
52              
53             my $obj = Bio::Roary::SequenceLengths->new(
54             fasta_file => 'abc.fa',
55             );
56             $obj->sequence_lengths;
57              
58             =head1 AUTHOR
59              
60             Andrew J. Page <ap13@sanger.ac.uk>
61              
62             =head1 COPYRIGHT AND LICENSE
63              
64             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
65              
66             This is free software, licensed under:
67              
68             The GNU General Public License, Version 3, June 2007
69              
70             =cut