| 1 | package Bio::Roary::External::IterativeCdhit; | ||||||||||
| 2 | 1 | $Bio::Roary::External::IterativeCdhit::VERSION = '3.13.0'; | |||||||||
| 3 | # ABSTRACT: Iteratively run CDhit | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | with 'Bio::Roary::JobRunner::Role'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | has 'output_cd_hit_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 10 | 1 | has 'output_combined_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 11 | 1 | has 'number_of_input_files' => ( is => 'ro', isa => 'Int', required => 1 ); | |||||||||
| 12 | 1 | has 'output_filtered_clustered_fasta' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 13 | 1 | has 'exec' => ( is => 'ro', isa => 'Str', default => 'iterative_cdhit' ); | |||||||||
| 14 | 1 | has '_max_cpus' => ( is => 'ro', isa => 'Int', default => 40 ); | |||||||||
| 15 | # Overload Role | ||||||||||
| 16 | 1 | has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' ); | |||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub _build_memory_in_mb { | ||||||||
|
Subroutine
_build_memory_in_mb: not called CC=3 SCAR=24.8
| |||||||||||
| 19 | 0 | my ($self) = @_; | |||||||||
| 20 | 0 | my $filename = $self->output_combined_filename; | |||||||||
| 21 | 0 | my $memory_required = 2000; | |||||||||
| 22 | 0 | ▶ | if ( -e $filename ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | $memory_required = 2000 if ( $memory_required < 2000 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | return $memory_required; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub _build__max_available_memory_in_mb { | ||||||||
|
Subroutine
_build__max_available_memory_in_mb: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 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 | 0 | ▶ | sub _command_to_run { | ||||||||
|
Subroutine
_command_to_run: not called CC=2 SCAR=17.9
| |||||||||||
| 43 | 0 | my ($self) = @_; | |||||||||
| 44 | 0 | ▶ | my $cpus = ($self->cpus > $self->_max_cpus) ? $self->_max_cpus : $self->cpus; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | 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 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 74 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 75 | |||||||||||
| 76 | 1 | 1; | |||||||||
| 77 | |||||||||||
| 78 | __END__ | ||||||||||