lib/Bio/Roary/Output/GroupMultifasta.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 91.9% 57 / 62 CC 6 SCAR 8.5
CC
6
Cov
92%
_lookup_sequence
4.2
create_file
3.0
BEGIN
1.0
CRAP 2.3
« lib/Bio/Roary/MergeMultifastaAlignments.pm ↑ Summary lib/Bio/Roary/LookupGeneFiles.pm »
1 package Bio::Roary::Output::GroupMultifasta;
2 2 $Bio::Roary::Output::GroupMultifasta::VERSION = '3.13.0';
3 # ABSTRACT: Take in a group and create a multifasta file
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 2 ▶use Bio::Roary::AnalyseGroups;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 has 'group_name' => ( is => 'ro', isa => 'Str', required => 1 );
12 2 has 'analyse_groups' => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups', required => 1 );
13 2 has 'output_filename_base' => ( is => 'ro', isa => 'Str', default => 'output_groups' );
14 2 has '_genes' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__genes' );
15 2 has '_output_seq_io' => ( is => 'ro', lazy => 1, builder => '_build__output_seq_io' );
16  
17 12 ▶sub _build__output_seq_io {
Subroutine _build__output_seq_io: called CC=1 SCAR=0.0
18 12 my ($self) = @_;
19 12 my $output_name = $self->output_filename_base . '_' . $self->group_name;
20 12 $output_name =~ s!\W!_!g;
21 12 $output_name .= '.fa';
22 12 return Bio::SeqIO->new( -file => ">" . $output_name, -format => 'Fasta' );
23 }
24  
25 12 ▶sub _build__genes {
Subroutine _build__genes: called CC=1 SCAR=0.0
26 12 my ($self) = @_;
27 12 return $self->analyse_groups->_groups_to_genes->{ $self->group_name };
28 }
29  
30 24 ▶sub _lookup_sequence {
Subroutine _lookup_sequence: called CC=4 SCAR=14.3
31 24 my ( $self, $gene, $filename ) = @_;
32 24 ▶ return undef if(! defined($filename));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 24 24
33 24 my $fasta_obj = Bio::SeqIO->new( -file => $filename, -format => 'Fasta' );
34 24 ▶ while ( my $seq = $fasta_obj->next_seq() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $fasta_obj->next_seq) 66 0 66
35 66 ▶ next unless ( $seq->display_id eq $gene );
Branch: 1 branch
BranchTrueFalseTotal
unless $seq->display_id eq $gene 42 24 66
36 24 return $seq;
37 }
38 0 return undef;
39 }
40  
41 12 ▶sub create_file {
Subroutine create_file: called CC=3 SCAR=11.0
Pod undocumented
42 12 my ($self) = @_;
43 12 for my $gene ( @{ $self->_genes } ) {
44 24 my $seq = $self->_lookup_sequence( $gene, $self->analyse_groups->_genes_to_file->{$gene} );
45 24 ▶ next unless ( defined($seq) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seq 0 24 24
46 24 $self->_output_seq_io->write_seq($seq);
47 }
48  
49 12 1;
50 }
51  
52 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 2 __PACKAGE__->meta->make_immutable;
54  
55 2 1;
56  
57 __END__
« lib/Bio/Roary/MergeMultifastaAlignments.pm ↑ Summary lib/Bio/Roary/LookupGeneFiles.pm »