| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Roary::Output::GroupsMultifastaProtein; |
|
2
|
|
|
|
|
|
|
$Bio::Roary::Output::GroupsMultifastaProtein::VERSION = '3.10.2'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Take a multifasta nucleotide file and output it as proteins. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
81542
|
use Moose; |
|
|
2
|
|
|
|
|
366999
|
|
|
|
2
|
|
|
|
|
29
|
|
|
7
|
2
|
|
|
2
|
|
13317
|
use Bio::SeqIO; |
|
|
2
|
|
|
|
|
60700
|
|
|
|
2
|
|
|
|
|
64
|
|
|
8
|
2
|
|
|
2
|
|
13
|
use File::Path qw(make_path); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
89
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use File::Basename; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
107
|
|
|
10
|
2
|
|
|
2
|
|
245
|
use Bio::Roary::Exceptions; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
11
|
2
|
|
|
2
|
|
542
|
use Bio::Roary::AnalyseGroups; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
592
|
|
|
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
|
|
|
|
|
41
|
my ( $filename, $directories, $suffix ) = fileparse($self->nucleotide_fasta_file, qr/\.[^.]*/); |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
31
|
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
|
|
2
|
my ($self) = @_; |
|
30
|
1
|
|
|
|
|
32
|
my $input_fasta_file_obj = Bio::SeqIO->new(-file => $self->nucleotide_fasta_file, -format => 'Fasta' ); |
|
31
|
1
|
|
|
|
|
26890
|
my $output_protein_file_obj = Bio::SeqIO->new(-file =>">".$self->output_filename, -format => 'Fasta', -alphabet => 'protein' ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
781
|
my %protein_sequence_objs; |
|
34
|
1
|
|
|
|
|
4
|
while (my $seq = $input_fasta_file_obj->next_seq){ |
|
35
|
8
|
|
|
|
|
11424
|
$protein_sequence_objs{$seq->display_id} = $seq->translate(-codontable_id => $self->translation_table ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
1409
|
for my $sequence_name ( sort keys %protein_sequence_objs) |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
8
|
|
|
|
|
1140
|
$output_protein_file_obj->write_seq($protein_sequence_objs{$sequence_name}); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
137
|
return 1; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub convert_nucleotide_to_protein |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
|
49
|
1
|
|
|
|
|
3
|
$self->_fastatranslate(); |
|
50
|
1
|
|
|
|
|
230
|
1; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
|
2
|
|
18
|
no Moose; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
20
|
|
|
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.10.2 |
|
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 |