line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::External::IterativeCdhit; |
2
|
|
|
|
|
|
|
$Bio::Roary::External::IterativeCdhit::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Iteratively run CDhit |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
with 'Bio::Roary::JobRunner::Role'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'output_cd_hit_filename' => ( is => 'ro', isa => 'Str', required => 1 ); |
10
|
|
|
|
|
|
|
has 'output_combined_filename' => ( is => 'ro', isa => 'Str', required => 1 ); |
11
|
|
|
|
|
|
|
has 'number_of_input_files' => ( is => 'ro', isa => 'Int', required => 1 ); |
12
|
|
|
|
|
|
|
has 'output_filtered_clustered_fasta' => ( is => 'ro', isa => 'Str', required => 1 ); |
13
|
|
|
|
|
|
|
has 'exec' => ( is => 'ro', isa => 'Str', default => 'iterative_cdhit' ); |
14
|
|
|
|
|
|
|
has '_max_cpus' => ( is => 'ro', isa => 'Int', default => 40 ); |
15
|
|
|
|
|
|
|
# Overload Role |
16
|
|
|
|
|
|
|
has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_memory_in_mb { |
19
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
20
|
0
|
|
|
|
|
|
my $filename = $self->output_combined_filename; |
21
|
0
|
|
|
|
|
|
my $memory_required = 2000; |
22
|
0
|
0
|
|
|
|
|
if ( -e $filename ) { |
23
|
0
|
|
|
|
|
|
$memory_required = -s $filename; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Convert to mb |
26
|
0
|
|
|
|
|
|
$memory_required = int( $memory_required / 1000000 ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Pentuple memory for worst case senario |
29
|
0
|
|
|
|
|
|
$memory_required *= 5; |
30
|
0
|
0
|
|
|
|
|
$memory_required = 2000 if ( $memory_required < 2000 ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $memory_required; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _build__max_available_memory_in_mb { |
37
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
38
|
0
|
|
|
|
|
|
my $memory_to_cdhit = int( $self->memory_in_mb * 0.9 ); |
39
|
0
|
|
|
|
|
|
return $memory_to_cdhit; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _command_to_run { |
43
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
44
|
0
|
0
|
|
|
|
|
my $cpus = ($self->cpus > $self->_max_cpus) ? $self->_max_cpus : $self->cpus; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return join( |
47
|
|
|
|
|
|
|
' ', |
48
|
|
|
|
|
|
|
( |
49
|
|
|
|
|
|
|
$self->exec, '-c', $self->output_cd_hit_filename, '-m', |
50
|
|
|
|
|
|
|
$self->output_combined_filename, '-n', $self->number_of_input_files, '--cpus', $cpus, '-f', |
51
|
|
|
|
|
|
|
$self->output_filtered_clustered_fasta |
52
|
|
|
|
|
|
|
) |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub run { |
57
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
58
|
0
|
|
|
|
|
|
my @commands_to_run; |
59
|
0
|
|
|
|
|
|
push( @commands_to_run, $self->_command_to_run ); |
60
|
0
|
|
|
|
|
|
$self->logger->info( "Running command: " . $self->_command_to_run() ); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $job_runner_obj = $self->_job_runner_class->new( |
63
|
|
|
|
|
|
|
commands_to_run => \@commands_to_run, |
64
|
|
|
|
|
|
|
memory_in_mb => $self->memory_in_mb, |
65
|
|
|
|
|
|
|
queue => $self->_queue, |
66
|
|
|
|
|
|
|
cpus => $self->cpus |
67
|
|
|
|
|
|
|
); |
68
|
0
|
|
|
|
|
|
$job_runner_obj->run(); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
1
|
|
5854
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
74
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Bio::Roary::External::IterativeCdhit - Iteratively run CDhit |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
version 3.11.0 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Iteratively run CDhit |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use Bio::Roary::External::IterativeCdhit; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $seg= Bio::Roary::External::IterativeCdhit->new( |
99
|
|
|
|
|
|
|
output_cd_hit_filename => '', |
100
|
|
|
|
|
|
|
output_combined_filename => '', |
101
|
|
|
|
|
|
|
number_of_input_files => 10, |
102
|
|
|
|
|
|
|
output_filtered_clustered_fasta => '', |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$seg->run(); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is free software, licensed under: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |