« lib/Bio/AssemblyImprovement/Scaffold/SSpace/TempDirectoryRole.pm
↑ Summary
lib/Bio/AssemblyImprovement/FillGaps/GapFiller/Main.pm »
| 1 | package Bio::AssemblyImprovement::Assemble::SGA::IndexAndCorrectReads; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Performs SGA error correction on the reads | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Cwd 'abs_path'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use Cwd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 3 | with 'Bio::AssemblyImprovement::Scaffold::SSpace::TempDirectoryRole'; | |||||||||
| 12 | 3 | with 'Bio::AssemblyImprovement::Util::UnzipFileIfNeededRole'; | |||||||||
| 13 | 3 | with 'Bio::AssemblyImprovement::Util::ZipFileRole'; | |||||||||
| 14 | |||||||||||
| 15 | 3 | has 'input_filename' => ( is => 'ro', isa => 'Str', required => 1); | |||||||||
| 16 | 3 | has 'algorithm' => ( is => 'ro', isa => 'Str', default => 'ropebwt'); # BWT construction algorithm: sais or ropebwt | |||||||||
| 17 | 3 | has 'threads' => ( is => 'ro', isa => 'Num', default => 1); # Use this many threads for computation | |||||||||
| 18 | 3 | has 'kmer_threshold' => ( is => 'ro', isa => 'Num', default=> 5); # Attempt to correct kmers that are seen less than this many times | |||||||||
| 19 | 3 | has 'kmer_length' => ( is => 'ro', isa => 'Num', default=> 41); # Since our coverage is usually high, we use 41. If not, 31 is OK. | |||||||||
| 20 | 3 | has 'output_filename' => ( is => 'rw', isa => 'Str', default => '_sga_error_corrected.fastq' ); | |||||||||
| 21 | 3 | has 'sga_exec' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||
| 22 | 3 | has 'debug' => ( is => 'ro', isa => 'Bool', default => 0); | |||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 2 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 2 | my ($self) = @_; | |||||||||
| 27 | 2 | my $input_filename = $self->_gunzip_file_if_needed( $self->input_filename, $self->_temp_directory ); | |||||||||
| 28 | |||||||||||
| 29 | 2 | my $original_cwd = getcwd(); | |||||||||
| 30 | |||||||||||
| 31 | # Change to temporary directory for all intermediate steps | ||||||||||
| 32 | 2 | chdir( $self->_temp_directory ); | |||||||||
| 33 | |||||||||||
| 34 | 2 | my $stdout_of_program = ''; | |||||||||
| 35 | 2 | ▶ | $stdout_of_program = "> /dev/null 2>&1" if($self->debug == 0); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | # Run the command to create the index | ||||||||||
| 38 | 2 | system( | |||||||||
| 39 | join( | ||||||||||
| 40 | ' ', | ||||||||||
| 41 | ( | ||||||||||
| 42 | $self->sga_exec, 'index', | ||||||||||
| 43 | '-a', $self->algorithm, | ||||||||||
| 44 | '-t', $self->threads, | ||||||||||
| 45 | '--no-reverse', | ||||||||||
| 46 | $input_filename, | ||||||||||
| 47 | $stdout_of_program | ||||||||||
| 48 | ) | ||||||||||
| 49 | ) | ||||||||||
| 50 | ); | ||||||||||
| 51 | |||||||||||
| 52 | # Run the command to correct the read errors | ||||||||||
| 53 | 2 | system( | |||||||||
| 54 | join( | ||||||||||
| 55 | ' ', | ||||||||||
| 56 | ( | ||||||||||
| 57 | $self->sga_exec, 'correct', | ||||||||||
| 58 | '-k', $self->kmer_length, | ||||||||||
| 59 | #'--discard', #Do not do discard. It creates orphan reads and does not make much of a difference with velvet | ||||||||||
| 60 | #'--learn', #Do not try to learn the kmer threshold. After normalisation, coverage may drop to below 20 in which case learning will not work | ||||||||||
| 61 | '-x', $self->kmer_threshold, | ||||||||||
| 62 | '-t', $self->threads, | ||||||||||
| 63 | '-o', $self->output_filename, | ||||||||||
| 64 | $input_filename, | ||||||||||
| 65 | $stdout_of_program | ||||||||||
| 66 | ) | ||||||||||
| 67 | ) | ||||||||||
| 68 | ); | ||||||||||
| 69 | |||||||||||
| 70 | # change back to original cwd | ||||||||||
| 71 | 2 | chdir($original_cwd); | |||||||||
| 72 | 2 | return $self; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 2 | ▶ | sub _output_filename { | ||||||||
|
Subroutine
_output_filename: called CC=1 SCAR=0.0
| |||||||||||
| 76 | 2 | my ($self) = @_; | |||||||||
| 77 | 2 | return join ('/', $self->_temp_directory, $self->output_filename); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | |||||||||||
| 81 | 3 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 82 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 83 | 3 | 1; | |||||||||
| 84 | |||||||||||
| 85 | __END__ | ||||||||||