« lib/Bio/AssemblyImprovement/Assemble/SGA/PreprocessReads.pm
↑ Summary
lib/Bio/AssemblyImprovement/Scaffold/SSpace/TempDirectoryRole.pm »
| 1 | package Bio::AssemblyImprovement::FillGaps::GapFiller::Iterative; | ||
| 2 | # ABSTRACT: Iteratively close gaps | ||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 2 | ▶ | use Cwd; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use File::Basename; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | ▶ | use File::Copy; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 2 | ▶ | use Bio::AssemblyImprovement::FillGaps::GapFiller::Main; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 2 | with 'Bio::AssemblyImprovement::Scaffold::SSpace::OutputFilenameRole'; | |
| 12 | 2 | with 'Bio::AssemblyImprovement::Scaffold::SSpace::TempDirectoryRole'; | |
| 13 | |||
| 14 | 2 | has 'input_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |
| 15 | 2 | has 'insert_size' => ( is => 'ro', isa => 'Int', required => 1 ); | |
| 16 | 2 | has 'gap_filler_exec' => ( is => 'ro', isa => 'Str', required => 1 ); | |
| 17 | 2 | has 'mappers' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_mappers' ); | |
| 18 | 2 | has 'merge_sizes' => ( is => 'ro', isa => 'ArrayRef[Int]', lazy => 1, builder => '_build_merge_sizes' ); | |
| 19 | 2 | has 'threads' => ( is => 'ro', isa => 'Int', default => 1 ); | |
| 20 | |||
| 21 | 2 | has 'output_base_directory' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_base_directory' ); | |
| 22 | 2 | has '_intermediate_filename' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__intermediate_filename' ); | |
| 23 | 2 | has 'debug' => ( is => 'ro', isa => 'Bool', default => 0); | |
| 24 | |||
| 25 | sub _build_output_base_directory | ||
| 26 | 1 | ▶ | { |
|
Subroutine
_build_output_base_directory: called CC=1 SCAR=0.0
| |||
| 27 | 1 | my ($self) = @_; | |
| 28 | 1 | return getcwd(); | |
| 29 | } | ||
| 30 | |||
| 31 | sub final_output_filename | ||
| 32 | 6 | ▶ | { |
|
Subroutine
final_output_filename: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 33 | 6 | my ($self) = @_; | |
| 34 | 6 | my ( $filename, $directories, $suffix ) = fileparse( $self->input_assembly, qr/\.[^.]*/ ); | |
| 35 | 6 | return $self->output_base_directory.'/' . $filename . "." . $self->_output_prefix . $suffix; | |
| 36 | } | ||
| 37 | |||
| 38 | 2 | ▶ | sub _build__intermediate_filename { |
|
Subroutine
_build__intermediate_filename: called CC=1 SCAR=0.0
| |||
| 39 | 2 | my ($self) = @_; | |
| 40 | 2 | my ( $filename, $directories, $suffix ) = fileparse( $self->input_assembly ); | |
| 41 | 2 | return join( '/', ( $self->_temp_directory, $filename ) ); | |
| 42 | } | ||
| 43 | |||
| 44 | 2 | ▶ | sub _build_merge_sizes { |
|
Subroutine
_build_merge_sizes: called CC=1 SCAR=0.0
| |||
| 45 | 2 | my ($self) = @_; | |
| 46 | 2 | return [ 90, 70, 50, 30, 20, 10]; | |
| 47 | } | ||
| 48 | |||
| 49 | sub _build_mappers | ||
| 50 | 2 | ▶ | { |
|
Subroutine
_build_mappers: called CC=1 SCAR=0.0
| |||
| 51 | 2 | my($self) = @_; | |
| 52 | 2 | return ['bwa','bowtie']; | |
| 53 | } | ||
| 54 | |||
| 55 | 24 | ▶ | sub _single_scaffolding_iteration { |
|
Subroutine
_single_scaffolding_iteration: called CC=1 SCAR=0.0
| |||
| 56 | 24 | my ( $self, $merge_size, $mapper ) = @_; | |
| 57 | |||
| 58 | 24 | my $scaffold = Bio::AssemblyImprovement::FillGaps::GapFiller::Main->new( | |
| 59 | input_files => $self->input_files, | ||
| 60 | input_assembly => $self->_intermediate_filename, | ||
| 61 | insert_size => $self->insert_size, | ||
| 62 | merge_size => $merge_size, | ||
| 63 | gap_filler_exec => $self->gap_filler_exec, | ||
| 64 | debug => $self->debug, | ||
| 65 | mapper => $mapper, | ||
| 66 | threads => $self->threads, | ||
| 67 | _output_prefix => $self->_output_prefix, | ||
| 68 | )->run; | ||
| 69 | 24 | move( $scaffold->output_filename, $self->_intermediate_filename ); | |
| 70 | 24 | return $self; | |
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | 2 | ▶ | sub run { |
|
Subroutine
run: called CC=3 SCAR=11.0
Pod
documented
| |||
| 75 | 2 | my ($self) = @_; | |
| 76 | 2 | $self->output_base_directory(); | |
| 77 | 2 | my $original_cwd = getcwd(); | |
| 78 | 2 | chdir( $self->_temp_directory ); | |
| 79 | |||
| 80 | 2 | copy( $self->input_assembly, $self->_intermediate_filename ); | |
| 81 | |||
| 82 | 2 | for my $merge_size ( @{ $self->merge_sizes } ) { | |
| 83 | 12 | for my $mapper (@{$self->mappers}) | |
| 84 | { | ||
| 85 | 24 | $self->_single_scaffolding_iteration($merge_size, $mapper); | |
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | 2 | chdir($original_cwd); | |
| 90 | 2 | move( $self->_intermediate_filename, $self->final_output_filename ); | |
| 91 | 2 | return $self; | |
| 92 | } | ||
| 93 | |||
| 94 | 2 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 95 | 2 | __PACKAGE__->meta->make_immutable; | |
| 96 | 2 | 1; | |
| 97 | |||
| 98 | __END__ | ||