line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::External::GeneAlignmentFromNucleotides; |
2
|
|
|
|
|
|
|
$Bio::Roary::External::GeneAlignmentFromNucleotides::VERSION = '3.10.2'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Take in multi-FASTA files of nucleotides and align each file with PRANK or MAFFT |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
with 'Bio::Roary::JobRunner::Role'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); |
10
|
|
|
|
|
|
|
has 'exec' => ( is => 'ro', isa => 'Str', default => 'protein_alignment_from_nucleotides' ); |
11
|
|
|
|
|
|
|
has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 ); |
12
|
|
|
|
|
|
|
has 'core_definition' => ( is => 'ro', isa => 'Num', default => 1 ); |
13
|
|
|
|
|
|
|
has 'mafft' => ( is => 'ro', isa => 'Bool', default => 0 ); |
14
|
|
|
|
|
|
|
has 'dont_delete_files' => ( is => 'rw', isa => 'Bool', default => 0 ); |
15
|
|
|
|
|
|
|
has 'allow_paralogs' => ( is => 'rw', isa => 'Bool', default => 0 ); |
16
|
|
|
|
|
|
|
has 'num_input_files' => ( is => 'ro', isa => 'Int', required => 1); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Overload Role` |
19
|
|
|
|
|
|
|
has 'memory_in_mb' => ( is => 'rw', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' ); |
20
|
|
|
|
|
|
|
has '_min_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 1500 ); |
21
|
|
|
|
|
|
|
has '_max_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 60000 ); |
22
|
|
|
|
|
|
|
has '_queue' => ( is => 'rw', isa => 'Str', default => 'normal' ); |
23
|
|
|
|
|
|
|
has '_files_per_chunk' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__files_per_chunk' ); |
24
|
|
|
|
|
|
|
has '_core_alignment_cmd' => ( is => 'rw', isa => 'Str', lazy_build => 1 ); |
25
|
|
|
|
|
|
|
has '_dependancy_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 15000 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _build__files_per_chunk |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
30
|
0
|
|
|
|
|
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_memory_in_mb { |
34
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $largest_file_size = 1; |
37
|
0
|
|
|
|
|
|
for my $file (@{$self->fasta_files}) |
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
|
|
|
my $file_size = -s $file; |
40
|
0
|
0
|
|
|
|
|
if($file_size > $largest_file_size) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
|
$largest_file_size = $file_size; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $approx_sequence_length_of_largest_file = $largest_file_size/ $self->num_input_files; |
47
|
0
|
|
|
|
|
|
my $memory_required = int((($approx_sequence_length_of_largest_file*$approx_sequence_length_of_largest_file)/1000000)*2 + $self->_min_memory_in_mb); |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$memory_required = $self->_max_memory_in_mb if($memory_required > $self->_max_memory_in_mb); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $memory_required; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _command_to_run { |
55
|
0
|
|
|
0
|
|
|
my ( $self, $fasta_files) = @_; |
56
|
0
|
|
|
|
|
|
my $verbose = ""; |
57
|
0
|
0
|
|
|
|
|
if($self->verbose) |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
|
$verbose = ' -v '; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
my $mafft_str = ""; |
62
|
0
|
0
|
|
|
|
|
$mafft_str = ' --mafft ' if($self->mafft); |
63
|
0
|
|
|
|
|
|
return $self->exec." ".$verbose.$mafft_str.join( " ", @{$fasta_files} ); |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _build__core_alignment_cmd { |
67
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $core_cmd = "pan_genome_core_alignment"; |
70
|
0
|
0
|
|
|
|
|
$core_cmd .= " -cd " . ($self->core_definition*100) if ( defined $self->core_definition ); |
71
|
0
|
0
|
0
|
|
|
|
$core_cmd .= " --dont_delete_files " if ( defined $self->dont_delete_files && $self->dont_delete_files == 1 ); |
72
|
0
|
0
|
0
|
|
|
|
$core_cmd .= " --allow_paralogs " if ( defined $self->allow_paralogs && $self->allow_paralogs == 1 ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $core_cmd; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub run { |
78
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
79
|
0
|
|
|
|
|
|
my @commands_to_run; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my @files_chunk; |
82
|
0
|
|
|
|
|
|
for my $fasta_file ( @{ $self->fasta_files } ) { |
|
0
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
push(@files_chunk,$fasta_file); |
84
|
0
|
0
|
|
|
|
|
if(@files_chunk == $self->_files_per_chunk ) |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
push(@commands_to_run, $self->_command_to_run(\@files_chunk)); |
87
|
0
|
|
|
|
|
|
$self->logger->info( "Running command: " . $self->_command_to_run(\@files_chunk) ); |
88
|
0
|
|
|
|
|
|
@files_chunk = (); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if(@files_chunk > 0) |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
|
|
|
push(@commands_to_run, $self->_command_to_run(\@files_chunk)); |
95
|
0
|
|
|
|
|
|
$self->logger->info( "Running command: " . $self->_command_to_run(\@files_chunk) ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $job_runner_obj = $self->_job_runner_class->new( |
99
|
|
|
|
|
|
|
commands_to_run => \@commands_to_run, |
100
|
|
|
|
|
|
|
memory_in_mb => $self->memory_in_mb, |
101
|
|
|
|
|
|
|
queue => $self->_queue, |
102
|
|
|
|
|
|
|
dont_wait => 1, |
103
|
|
|
|
|
|
|
cpus => $self->cpus |
104
|
|
|
|
|
|
|
); |
105
|
0
|
|
|
|
|
|
$job_runner_obj->run(); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$job_runner_obj->memory_in_mb($self->_dependancy_memory_in_mb); |
108
|
0
|
|
|
|
|
|
$self->logger->info( "Running command: " . $self->_core_alignment_cmd() ); |
109
|
0
|
|
|
|
|
|
$job_runner_obj->submit_dependancy_job($self->_core_alignment_cmd); |
110
|
0
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
1
|
|
7711
|
no Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
114
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=pod |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=encoding UTF-8 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Bio::Roary::External::GeneAlignmentFromNucleotides - Take in multi-FASTA files of nucleotides and align each file with PRANK or MAFFT |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 VERSION |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
version 3.10.2 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Take in multi-FASTA files of nucleotides and align each file with PRANK or MAFFT |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use Bio::Roary::External::GeneAlignmentFromNucleotides; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $seg = Bio::Roary::External::GeneAlignmentFromNucleotides->new( |
138
|
|
|
|
|
|
|
fasta_files => [], |
139
|
|
|
|
|
|
|
); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$seg->run(); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 METHODS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 output_file |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns the path to the results file |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is free software, licensed under: |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |