lib/Bio/AssemblyImprovement/Circlator/Main.pm

filter: Statementstmt 98.2% 55 / 56 Branchbran 55.0% 11 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 83.5% 76 / 91 CC 13 SCAR 20.3
CC
13
Cov
85%
run
13.1
_filter_out_non_existant_files
3.0
BEGIN
1.0
CRAP 7.6
« lib/Bio/AssemblyImprovement/Util/GetReadLengthsRole.pm ↑ Summary lib/Bio/AssemblyImprovement/Quiver/Main.pm »
1 package Bio::AssemblyImprovement::Circlator::Main;
2  
3 # ABSTRACT: Wrapper around circlator
4  
5 # =head1 SYNOPSIS
6  
7 # =cut
8  
9 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use File::Path qw(make_path remove_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 has 'assembly' => ( is => 'ro', isa => 'Str', required => 1 );
15 2 has 'corrected_reads' => ( is => 'ro', isa => 'Str', required => 1 );
16 2 has 'output_directory' => ( is => 'ro', isa => 'Str', required => 0, default => "circularised" );
17 2 has 'working_directory'=> ( is => 'ro', isa => 'Str', required => 0, default => getcwd());
18 2 has 'circlator_exec' => ( is => 'ro', isa => 'Str', required => 0, default => "/software/pathogen/external/bin/circlator");
19  
20  
21 12 ▶sub _get_number_in_filename {
Subroutine _get_number_in_filename: called CC=1 SCAR=0.0
22 12 my ($self, $name) = @_;
23 12 $name =~ /\S+\/04.merge.merge.iter.(\d+).reads.log/;
24 12 return $1;
25 }
26  
27 2 ▶sub run {
Subroutine run: called CC=11 SCAR=25.8
Pod undocumented
28 2 my ($self) = @_;
29  
30 # remember cwd if different from working directory
31 2 my $cwd = getcwd();
32 2 chdir ($self->working_directory);
33 2 my $temp_dir = "tmp_circularised";
34 2 ▶ remove_tree($temp_dir) if(-d $temp_dir);
Branch: 1 branch
BranchTrueFalseTotal
if -d $temp_dir 0 2 2
35 2 ▶ remove_tree($self->output_directory) if(-d $self->output_directory);
Branch: 1 branch
BranchTrueFalseTotal
if -d $self->output_directory 0 2 2
36
37 2 my $cmd = join(
38 ' ',
39 (
40 $self->circlator_exec,
41 'all',
42 $self->assembly,
43 $self->corrected_reads,
44 $temp_dir,
45 )
46 );
47
48 2 ▶ if(system($cmd)){
Branch: 1 branch
BranchTrueFalseTotal
if (system $cmd) 0 2 2
49 0 die "Failed to run circlator with $cmd";
50 # In this case, it is OK to die. When used in the pipeline, it should stop at this point and
51 # not carry on with the rest of the steps (quiver etc)
52 }
53
54 2 ▶ if(-e $temp_dir."/06.fixstart.fasta" and -e $temp_dir."/06.fixstart.ALL_FINISHED"){
Branch: 1 branch
BranchTrueFalseTotal
if (-e $temp_dir . '/06.fixstart.fasta' and -e $temp_dir . '/06.fixstart.ALL_FINISHED') 2 0 2
Condition33%1/3
-e $temp_dir . '/06.fixstart.fasta' and -e $temp_dir . '/06.fixstart.ALL_FINISHED'
!ll&&!rl&&r
002
MC/DC0%0/2
-e $temp_dir . '/06.fixstart.fasta' and -e $temp_dir . '/06.fixstart.ALL_FINISHED'
-e $temp_dir . '/06.fixstart.fasta' -e $temp_dir . '/06.fixstart.ALL_FINISHED'
Truth table33%1/3
A and B
A= -e $temp_dir . '/06.fixstart.fasta'B= -e $temp_dir . '/06.fixstart.ALL_FINISHED'
ABresult
0X0
100
111
55 # rename, cat logs, clear up output
56 2 ▶ if(! -d $self->output_directory){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $self->output_directory) 2 0 2
57 2 make_path($self->output_directory);
58 }
59 2 ▶ system("mv $temp_dir/00.info.txt ".$self->output_directory."/circlator.info.txt") and warn "Could not move $temp_dir/00.info.txt to ".$self->output_directory."/circlator.info.txt";
Branch: 1 branch
BranchTrueFalseTotal
system "mv $temp_dir/00.info.txt " . $self->output_directory . '/circlator.info.txt' and warn "Could not move $temp_dir/00.info.txt to " . $self->output_directory . '/circlator.info.txt' 0 2 2
60 2 ▶ system("mv $temp_dir/06.fixstart.fasta ".$self->output_directory."/circlator.final.fasta") and die "Could not move $temp_dir/06.fixstart.fasta to ".$self->output_directory."/circlator.final.fasta";
Branch: 1 branch
BranchTrueFalseTotal
system "mv $temp_dir/06.fixstart.fasta " . $self->output_directory . '/circlator.final.fasta' and die "Could not move $temp_dir/06.fixstart.fasta to " . $self->output_directory . '/circlator.final.fasta' 0 2 2
61
62 1 ▶ my @iterative_merge_files = sort {$self->_get_number_in_filename($a) <=> $self->_get_number_in_filename($b)} glob("$temp_dir/04.merge.merge.iter.*.reads.log"); #cannot rely on glob's lexical sorting
Subroutine BEGIN: called CC=1 SCAR=0.0
63
64 2 my @log_files = ("$temp_dir/02.bam2reads.log",
65 @iterative_merge_files,
66 "$temp_dir/04.merge.merge.iterations.log",
67 "$temp_dir/04.merge.merge.log",
68 "$temp_dir/04.merge.circularise_details.log",
69 "$temp_dir/04.merge.circularise.log",
70 "$temp_dir/05.clean.log",
71 "$temp_dir/06.fixstart.log",
72 );
73 2 my $filtered_log_files = $self->_filter_out_non_existant_files(\@log_files);
74 2 ▶ system("cat ".join(" ", @{$filtered_log_files})." > ".$self->output_directory."/circlator.log") and warn "Could not cat circlator log files to ".$self->output_directory."/circlator.log";
Branch: 1 branch
BranchTrueFalseTotal
system 'cat ' . join(" ", @{$filtered_log_files;}) . ' > ' . $self->output_directory . '/circlator.log' and warn 'Could not cat circlator log files to ' . $self->output_directory . '/circlator.log' 0 2 2
75  
76 2 ▶ remove_tree($temp_dir) if(-d $temp_dir);
Branch: 1 branch
BranchTrueFalseTotal
if -d $temp_dir 2 0 2
77 }
78
79 2 chdir ($cwd);
80 }
81  
82 sub _filter_out_non_existant_files
83 2 ▶{
Subroutine _filter_out_non_existant_files: called CC=3 SCAR=11.0
84 2 my($self, $files) = @_;
85 2 my @filtered_files;
86 2 for my $file(@{$files})
87 {
88 20 ▶ push(@filtered_files, $file) if(-e $file);
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 19 1 20
89 }
90 2 return \@filtered_files;
91 }
92  
93 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 2 __PACKAGE__->meta->make_immutable;
95 2 1;
96  
97 __END__
« lib/Bio/AssemblyImprovement/Util/GetReadLengthsRole.pm ↑ Summary lib/Bio/AssemblyImprovement/Quiver/Main.pm »