line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::External::Cdhit; |
2
|
|
|
|
|
|
|
$Bio::Roary::External::Cdhit::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Wrapper to run cd-hit |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
82430
|
use Moose; |
|
4
|
|
|
|
|
364694
|
|
|
4
|
|
|
|
|
18
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Bio::Roary::JobRunner::Role'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'input_file' => ( is => 'ro', isa => 'Str', required => 1 ); |
11
|
|
|
|
|
|
|
has 'output_base' => ( is => 'ro', isa => 'Str', default => 'output' ); |
12
|
|
|
|
|
|
|
has 'exec' => ( is => 'ro', isa => 'Str', default => 'cd-hit' ); |
13
|
|
|
|
|
|
|
has 'alt_exec' => ( is => 'ro', isa => 'Str', default => 'cdhit' ); |
14
|
|
|
|
|
|
|
has '_max_available_memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__max_available_memory_in_mb' ); |
15
|
|
|
|
|
|
|
has '_use_most_similar_clustering' => ( is => 'ro', isa => 'Bool', default => 1 ); |
16
|
|
|
|
|
|
|
has '_length_difference_cutoff' => ( is => 'ro', isa => 'Num', default => 1 ); |
17
|
|
|
|
|
|
|
has '_sequence_identity_threshold' => ( is => 'ro', isa => 'Num', default => 1 ); |
18
|
|
|
|
|
|
|
has '_description_length' => ( is => 'ro', isa => 'Int', default => 256 ); |
19
|
|
|
|
|
|
|
has '_logging' => ( is => 'ro', isa => 'Str', default => '> /dev/null 2>&1' ); |
20
|
|
|
|
|
|
|
has '_max_cpus' => ( is => 'ro', isa => 'Int', default => 40 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Overload Role |
24
|
|
|
|
|
|
|
has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _build_memory_in_mb |
27
|
|
|
|
|
|
|
{ |
28
|
3
|
|
|
3
|
|
7
|
my ($self) = @_; |
29
|
3
|
|
|
|
|
53
|
my $filename = $self->input_file; |
30
|
3
|
|
|
|
|
5
|
my $memory_required = 2000; |
31
|
3
|
100
|
|
|
|
66
|
if(-e $filename) |
32
|
|
|
|
|
|
|
{ |
33
|
1
|
|
|
|
|
5
|
$memory_required = -s $filename; |
34
|
|
|
|
|
|
|
# Convert to mb |
35
|
1
|
|
|
|
|
4
|
$memory_required = int($memory_required/1000000); |
36
|
|
|
|
|
|
|
# Triple memory for worst case senario |
37
|
1
|
|
|
|
|
2
|
$memory_required *= 5; |
38
|
1
|
50
|
|
|
|
7
|
$memory_required = 2000 if($memory_required < 2000); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
66
|
return $memory_required; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _build__max_available_memory_in_mb |
45
|
|
|
|
|
|
|
{ |
46
|
3
|
|
|
3
|
|
6
|
my ($self) = @_; |
47
|
3
|
|
|
|
|
64
|
my $memory_to_cdhit = int($self->memory_in_mb *0.9); |
48
|
3
|
|
|
|
|
60
|
return $memory_to_cdhit; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub clusters_filename |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
54
|
0
|
|
|
|
|
0
|
return join('.',($self->output_base,'clstr')); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _command_to_run { |
58
|
6
|
|
|
6
|
|
10
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
138
|
my $executable = $self->_find_exe([$self->exec, $self->alt_exec]); |
61
|
|
|
|
|
|
|
|
62
|
6
|
100
|
|
|
|
121
|
my $cpus = ($self->cpus > $self->_max_cpus) ? $self->_max_cpus : $self->cpus; |
63
|
6
|
|
|
|
|
107
|
return join( |
64
|
|
|
|
|
|
|
' ', |
65
|
|
|
|
|
|
|
( |
66
|
|
|
|
|
|
|
$executable, '-i', $self->input_file, '-o', |
67
|
|
|
|
|
|
|
$self->output_base, '-T', $cpus, '-M', |
68
|
|
|
|
|
|
|
$self->_max_available_memory_in_mb, '-g', $self->_use_most_similar_clustering, '-s', |
69
|
|
|
|
|
|
|
$self->_length_difference_cutoff, '-d', $self->_description_length ,'-c', $self->_sequence_identity_threshold, |
70
|
|
|
|
|
|
|
$self->_logging |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub run { |
76
|
2
|
|
|
2
|
0
|
4
|
my ($self) = @_; |
77
|
2
|
|
|
|
|
2
|
my @commands_to_run; |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
6
|
push(@commands_to_run, $self->_command_to_run() ); |
80
|
2
|
|
|
|
|
37
|
$self->logger->info( "Running command: " . $self->_command_to_run() ); |
81
|
2
|
|
|
|
|
54
|
my $job_runner_obj = $self->_job_runner_class->new( commands_to_run => \@commands_to_run, memory_in_mb => $self->memory_in_mb, queue => $self->_queue, cpus => $self->cpus ); |
82
|
2
|
|
|
|
|
10
|
$job_runner_obj->run(); |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
155
|
1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
4
|
|
23942
|
no Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
18
|
|
88
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding UTF-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Bio::Roary::External::Cdhit - Wrapper to run cd-hit |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
version 3.11.0 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Wrapper to run cd-hit |
109
|
|
|
|
|
|
|
use Bio::Roary::External::Cdhit; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $obj = Bio::Roary::External::Cdhit->new( |
112
|
|
|
|
|
|
|
input_file => 'abc.fa', |
113
|
|
|
|
|
|
|
exec => 'cd-hit', |
114
|
|
|
|
|
|
|
output_base => 'efg', |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
$obj->run; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software, licensed under: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |