line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::Output::GroupsMultifastaProtein; |
2
|
|
|
|
|
|
|
$Bio::Roary::Output::GroupsMultifastaProtein::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Take a multifasta nucleotide file and output it as proteins. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
90346
|
use Moose; |
|
2
|
|
|
|
|
412860
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
13227
|
use Bio::SeqIO; |
|
2
|
|
|
|
|
65215
|
|
|
2
|
|
|
|
|
72
|
|
8
|
2
|
|
|
2
|
|
16
|
use File::Path qw(make_path); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
121
|
|
9
|
2
|
|
|
2
|
|
16
|
use File::Basename; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
142
|
|
10
|
2
|
|
|
2
|
|
256
|
use Bio::Roary::Exceptions; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
11
|
2
|
|
|
2
|
|
583
|
use Bio::Roary::AnalyseGroups; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
703
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'nucleotide_fasta_file' => ( is => 'ro', isa => 'Str', required => 1 ); |
14
|
|
|
|
|
|
|
has 'output_filename' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_filename' ); |
15
|
|
|
|
|
|
|
has '_suffix' => ( is => 'ro', isa => 'Str', default => '.faa' ); |
16
|
|
|
|
|
|
|
has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_output_filename |
19
|
|
|
|
|
|
|
{ |
20
|
1
|
|
|
1
|
|
4
|
my ($self) = @_; |
21
|
1
|
|
|
|
|
37
|
my ( $filename, $directories, $suffix ) = fileparse($self->nucleotide_fasta_file, qr/\.[^.]*/); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
52
|
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
|
|
|
|
|
|
|
{ |
29
|
1
|
|
|
1
|
|
4
|
my ($self) = @_; |
30
|
1
|
|
|
|
|
64
|
my $input_fasta_file_obj = Bio::SeqIO->new(-file => $self->nucleotide_fasta_file, -format => 'Fasta' ); |
31
|
1
|
|
|
|
|
45079
|
my $output_protein_file_obj = Bio::SeqIO->new(-file =>">".$self->output_filename, -format => 'Fasta', -alphabet => 'protein' ); |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
1380
|
my %protein_sequence_objs; |
34
|
1
|
|
|
|
|
6
|
while (my $seq = $input_fasta_file_obj->next_seq){ |
35
|
8
|
|
|
|
|
16920
|
$protein_sequence_objs{$seq->display_id} = $seq->translate(-codontable_id => $self->translation_table ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
2000
|
for my $sequence_name ( sort keys %protein_sequence_objs) |
39
|
|
|
|
|
|
|
{ |
40
|
8
|
|
|
|
|
1567
|
$output_protein_file_obj->write_seq($protein_sequence_objs{$sequence_name}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
215
|
return 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub convert_nucleotide_to_protein |
47
|
|
|
|
|
|
|
{ |
48
|
1
|
|
|
1
|
0
|
4
|
my ($self) = @_; |
49
|
1
|
|
|
|
|
5
|
$self->_fastatranslate(); |
50
|
1
|
|
|
|
|
431
|
1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
2
|
|
21
|
no Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
54
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=pod |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=encoding UTF-8 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 NAME |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Bio::Roary::Output::GroupsMultifastaProtein - Take a multifasta nucleotide file and output it as proteins. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 VERSION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
version 3.11.0 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Take a multifasta nucleotide file and output it as proteins. |
75
|
|
|
|
|
|
|
use Bio::Roary::Output::GroupsMultifastaProtein; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $obj = Bio::Roary::Output::GroupsMultifastaProtein->new( |
78
|
|
|
|
|
|
|
nucleotide_fasta_file => 'example.fa' |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
$obj->convert_nucleotide_to_protein(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software, licensed under: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |