lib/Bio/Roary/Output/GroupsMultifastaProtein.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 98.2% 55 / 56 CC 3 SCAR 4.1
CC
3
Cov
100%
_fastatranslate
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« lib/Bio/Roary/Output/GroupsMultifastasNucleotide.pm ↑ Summary lib/Bio/Roary/Output/EMBLHeaderCommon.pm »
1 package Bio::Roary::Output::GroupsMultifastaProtein;
2 2 $Bio::Roary::Output::GroupsMultifastaProtein::VERSION = '3.13.0';
3 # ABSTRACT: Take a multifasta nucleotide file and output it as proteins.
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 File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Bio::Roary::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Bio::Roary::AnalyseGroups;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 has 'nucleotide_fasta_file' => ( is => 'ro', isa => 'Str', required => 1 );
14 2 has 'output_filename' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_filename' );
15 2 has '_suffix' => ( is => 'ro', isa => 'Str', default => '.faa' );
16 2 has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
17  
18 sub _build_output_filename
19 1 ▶{
Subroutine _build_output_filename: called CC=1 SCAR=0.0
20 1 my ($self) = @_;
21 1 my ( $filename, $directories, $suffix ) = fileparse($self->nucleotide_fasta_file, qr/\.[^.]*/);
22  
23 1 return join('',($directories, $filename.$self->_suffix));
24 }
25  
26 # Read all the sequences for a gene into memory to sort them - very small files so shouldnt be a problem
27 sub _fastatranslate
28 1 ▶{
Subroutine _fastatranslate: called CC=3 SCAR=11.0
29 1 my ($self) = @_;
30 1 my $input_fasta_file_obj = Bio::SeqIO->new(-file => $self->nucleotide_fasta_file, -format => 'Fasta' );
31 1 my $output_protein_file_obj = Bio::SeqIO->new(-file =>">".$self->output_filename, -format => 'Fasta', -alphabet => 'protein' );
32  
33 1 my %protein_sequence_objs;
34 1 ▶ while (my $seq = $input_fasta_file_obj->next_seq){
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $input_fasta_file_obj->next_seq) 8 1 9
35 8 $protein_sequence_objs{$seq->display_id} = $seq->translate(-codontable_id => $self->translation_table );
36 }
37  
38 1 for my $sequence_name ( sort keys %protein_sequence_objs)
39 {
40 8 $output_protein_file_obj->write_seq($protein_sequence_objs{$sequence_name});
41 }
42  
43 1 return 1;
44 }
45  
46 sub convert_nucleotide_to_protein
47 1 ▶{
Subroutine convert_nucleotide_to_protein: called CC=1 SCAR=0.0
Pod undocumented
48 1 my ($self) = @_;
49 1 $self->_fastatranslate();
50 1 1;
51 }
52  
53 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 __PACKAGE__->meta->make_immutable;
55  
56 2 1;
57  
58 __END__
« lib/Bio/Roary/Output/GroupsMultifastasNucleotide.pm ↑ Summary lib/Bio/Roary/Output/EMBLHeaderCommon.pm »