| 1 | package Bio::Roary::SequenceLengths; | ||||||||||
| 2 | 2 | $Bio::Roary::SequenceLengths::VERSION = '3.13.0'; | |||||||||
| 3 | # ABSTRACT: Take in a fasta file and create a hash with the length of each sequence | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Bio::SeqIO; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Bio::Roary::Exceptions; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | has 'fasta_file' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 11 | 2 | has 'sequence_lengths' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_sequence_lengths' ); | |||||||||
| 12 | 2 | has '_input_seqio' => ( is => 'ro', isa => 'Bio::SeqIO', lazy => 1, builder => '_build__input_seqio' ); | |||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub _build__input_seqio { | ||||||||
|
Subroutine
_build__input_seqio: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | my ($self) = @_; | |||||||||
| 16 | 1 | return Bio::SeqIO->new( -file => $self->fasta_file, -format => 'Fasta' ); | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub _build_sequence_lengths { | ||||||||
|
Subroutine
_build_sequence_lengths: called CC=2 SCAR=6.9
| |||||||||||
| 20 | 1 | my ($self) = @_; | |||||||||
| 21 | |||||||||||
| 22 | 1 | my %sequence_lengths; | |||||||||
| 23 | 1 | ▶ | while ( my $input_seq = $self->_input_seqio->next_seq() ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 6 | $sequence_lengths{ $input_seq->display_id } = $input_seq->length(); | |||||||||
| 25 | } | ||||||||||
| 26 | 1 | return \%sequence_lengths; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 2 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 31 | |||||||||||
| 32 | 2 | 1; | |||||||||
| 33 | |||||||||||
| 34 | __END__ | ||||||||||