« lib/Bio/AssemblyImprovement/Circlator/Main.pm
↑ Summary
lib/Bio/AssemblyImprovement/Util/FastqTools.pm »
| 1 | package Bio::AssemblyImprovement::Quiver::Main; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Wrapper around the quiver call | ||||||||||
| 4 | |||||||||||
| 5 | # =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | # =cut | ||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use File::Copy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use File::Path qw(make_path remove_tree); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Cwd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | has 'reference' => ( is => 'ro', isa => 'Str', required => 1); | |||||||||
| 15 | 2 | has 'bax_files' => ( is => 'ro', isa => 'Str', required => 1); | |||||||||
| 16 | 2 | has 'quiver_exec' => ( is => 'ro', isa => 'Str', required => 0, default => '/software/pathogen/internal/prod/bin/pacbio_smrtanalysis' ); | |||||||||
| 17 | 2 | has 'threads' => ( is => 'ro', isa => 'Int', required => 0, default => 6 ); #the quiver default is 16 which can lead to long PEND times on the farm. 6 has been enough so far | |||||||||
| 18 | 2 | has 'memory' => ( is => 'ro', isa => 'Int', required => 0, default => 8 ); | |||||||||
| 19 | 2 | has 'no_bsub' => ( is => 'ro', isa => 'Bool', default => 1); | |||||||||
| 20 | 2 | has 'working_directory'=> ( is => 'ro', isa => 'Str', required => 0, default => getcwd()); | |||||||||
| 21 | 2 | has 'output_directory' => ( is => 'ro', isa => 'Str', default => 'quiver'); | |||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=7 SCAR=20.2
Pod
undocumented
| |||||||||||
| 25 | 1 | my ($self) = @_; | |||||||||
| 26 | |||||||||||
| 27 | 1 | my $no_bsub_option = ""; | |||||||||
| 28 | 1 | ▶ | if ($self->no_bsub) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | $no_bsub_option = "--no_bsub"; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # remember cwd if different from working directory | ||||||||||
| 33 | 1 | my $cwd = getcwd(); | |||||||||
| 34 | 1 | chdir ($self->working_directory); | |||||||||
| 35 | 1 | my $temp_dir = "tmp_quiver"; | |||||||||
| 36 | 1 | ▶ | remove_tree($temp_dir) if(-d $temp_dir); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 1 | ▶ | remove_tree($self->output_directory) if(-d $self->output_directory); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 1 | my $cmd = join( | |||||||||
| 40 | ' ', | ||||||||||
| 41 | ( | ||||||||||
| 42 | $self->quiver_exec, | ||||||||||
| 43 | '--threads', $self->threads, | ||||||||||
| 44 | '--memory', $self->memory, | ||||||||||
| 45 | $no_bsub_option, | ||||||||||
| 46 | '--reference', $self->reference, | ||||||||||
| 47 | 'RS_Resequencing', | ||||||||||
| 48 | $temp_dir, | ||||||||||
| 49 | $self->bax_files, | ||||||||||
| 50 | ) | ||||||||||
| 51 | ); | ||||||||||
| 52 | |||||||||||
| 53 | 1 | ▶ | if (system($cmd)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | die "Error running Quiver with:\n$cmd"; | |||||||||
| 55 | } | ||||||||||
| 56 | 1 | ▶ | if(! -e $temp_dir."/consensus.fasta"){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | die "No consensus.fasta file. Error running Quiver with:\n$cmd"; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | # Keep some files, delete the rest | ||||||||||
| 61 | # consensus.fasta, run-assembly.sh, All_output/input.xml, All_output/settings.xml | ||||||||||
| 62 | 1 | ▶ | if(! -d $self->output_directory){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 1 | make_path($self->output_directory); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 1 | move (join('/', $temp_dir, 'consensus.fasta'), join('/', $self->output_directory, 'quiver.final.fasta')); | |||||||||
| 67 | 1 | move (join('/', $temp_dir, 'aligned_reads.bam'), join('/', $self->output_directory, 'quiver.aligned_reads.bam')); | |||||||||
| 68 | 1 | move (join('/', $temp_dir, 'aligned_reads.bam.bai'), join('/', $self->output_directory, 'quiver.aligned_reads.bam.bai')); | |||||||||
| 69 | 1 | move (join('/', $temp_dir, 'run-assembly.sh'), join('/', $self->output_directory, 'quiver.run-assembly.sh')); | |||||||||
| 70 | 1 | move (join('/', $temp_dir, 'All_output', 'input.xml'), join('/', $self->output_directory, 'quiver.input.xml')); | |||||||||
| 71 | 1 | move (join('/', $temp_dir, 'All_output', 'settings.xml'), join('/', $self->output_directory, 'quiver.settings.xml')); | |||||||||
| 72 | |||||||||||
| 73 | 1 | remove_tree($temp_dir); | |||||||||
| 74 | 1 | chdir ($cwd); | |||||||||
| 75 | # TODO: check the status of bsub.o file and if it failed because the memory was low, then resubmit with more - try twice | ||||||||||
| 76 | |||||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | 2 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 81 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 82 | 2 | 1; | |||||||||
| 83 | |||||||||||
| 84 | __END__ | ||||||||||