| 1 | package Bio::Tradis::CommandLine::TradisAnalysis; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Bio::Tradis::CommandLine::TradisAnalysis::VERSION = '1.4.5'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Perform full tradis analysis | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Cwd qw(abs_path cwd); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Bio::Tradis::RunTradis; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | has 'fastqfile' => ( is => 'rw', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | has 'tag' => ( is => 'rw', isa => 'Maybe[Str]', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | has 'mismatch' => ( is => 'rw', isa => 'Int', required => 0, default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | has 'tagdirection' => | |||||||||||||||||||||||||||||||||||||||||
| 18 | ( is => 'rw', isa => 'Str', required => 0, default => '3' ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | has 'reference' => ( is => 'rw', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | has 'help' => ( is => 'rw', isa => 'Bool', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | has 'mapping_score' => | |||||||||||||||||||||||||||||||||||||||||
| 22 | ( is => 'rw', isa => 'Int', required => 0, default => 30 ); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | has 'min_seed_len' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | has 'smalt' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | has 'smalt_k' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | has 'smalt_s' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | has 'smalt_y' => ( is => 'rw', isa => 'Maybe[Num]', required => 0, default => 0.96 ); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | has 'smalt_r' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => -1 ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | has 'smalt_n' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | has 'essentiality' => ( is => 'rw', isa => 'Bool', required => 0, default => 0); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | has 'samtools_exec' => ( is => 'rw', isa => 'Str', default => 'samtools' ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | has '_output_directory' => ( | |||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | builder => '_build__output_directory' | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | has '_stats_handle' => ( | |||||||||||||||||||||||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | isa => 'FileHandle', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | builder => '_build__stats_handle' | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=23 SCAR=40.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | $fastqfile, $tag, $td, $mismatch, $ref,$smalt_n, $essentiality, $min_seed_len, $smalt, | |||||||||||||||||||||||||||||||||||||||||
| 56 | $map_score, $smalt_k, $smalt_s, $smalt_y, $smalt_r, $help, $verbose,$samtools_exec | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | GetOptionsFromArray( | |||||||||||||||||||||||||||||||||||||||||
| 60 | $self->args, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'f|fastqfile=s' => \$fastqfile, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 't|tag=s' => \$tag, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 'td|tagdirection=i' => \$td, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 'mm|mismatch=i' => \$mismatch, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 'r|reference=s' => \$ref, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 'm|mapping_score=i' => \$map_score, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 'k|min_seed_len=i' => \$min_seed_len, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 's|smalt' => \$smalt, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 'sk|smalt_k=i' => \$smalt_k, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 'ss|smalt_s=i' => \$smalt_s, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 'sy|smalt_y=f' => \$smalt_y, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 'n|smalt_n=i' => \$smalt_n, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 'sr|smalt_r=i' => \$smalt_r, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 'v|verbose' => \$verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 'samtools_exec=s' => \$samtools_exec, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 'e|essentiality' => \$essentiality, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'h|help' => \$help | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | #Essentiality analysis requires different defaults. | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | if(!defined($smalt_r) && !defined($map_score) && defined($essentiality)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $smalt_r || defined $map_score and defined $essentiality
defined $smalt_r || defined $map_score
MC/DC0%0/3
not defined $smalt_r || defined $map_score and defined $essentiality
defined $smalt_r
defined $map_score
defined $essentiality
Truth table25%1/4
not(A || B) and C
A= defined $smalt_rB= defined $map_scoreC= defined $essentiality
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | $self->essentiality($essentiality) if ( defined($essentiality)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $smalt_r = 0; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $map_score = 0; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | $self->fastqfile( abs_path($fastqfile) ) if ( defined($fastqfile) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | $self->tag( uc($tag) ) if ( defined($tag) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | $self->tagdirection($td) if ( defined($td) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | $self->mismatch($mismatch) if ( defined($mismatch) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | $self->reference( abs_path($ref) ) if ( defined($ref) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | $self->mapping_score($map_score) if ( defined($map_score) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | $self->min_seed_len($min_seed_len) if ( defined($min_seed_len) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | $self->smalt($smalt) if ( defined($smalt) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $self->smalt_k($smalt_k) if ( defined($smalt_k) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | $self->smalt_s($smalt_s) if ( defined($smalt_s) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | $self->smalt_y($smalt_y) if ( defined($smalt_y) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | $self->smalt_r($smalt_r) if ( defined($smalt_r) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | $self->smalt_n($smalt_n) if ( defined($smalt_n) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | $self->help($help) if ( defined($help) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | $self->verbose($verbose) if ( defined($verbose)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | $self->samtools_exec($samtools_exec) if ( defined($samtools_exec) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # print usage text if required parameters are not present | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | ( $fastqfile ) or die "--fastqfile required/n" . $self->usage_text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | ( $ref ) or die "--reference required\n" . $self->usage_text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=9 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | if ( defined( $self->help ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | #if ( scalar( @{ $self->args } ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->usage_text; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | #parse list of files and run pipeline for each one if they all exist | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | my $fq = $self->fastqfile; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | open( FILES, "<", $fq ) or die "Cannot find $fq"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | my @filelist = <FILES>; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | my $file_dir = $self->get_file_dir; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | #check files exist before running | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my $line_no = 0; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | my $full_path; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | foreach my $f1 (@filelist) { | |||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | chomp($f1); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $line_no++; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( $f1 =~ /^\// ) { $full_path = $f1; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | else { $full_path = "$file_dir/$f1"; } | |||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | unless ( -e $full_path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | die "File $full_path does not exist ($fq, line $line_no)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | #if all files exist, continue with analysis | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | my $at_least_one_good_fastq = 0; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | foreach my $f2 (@filelist) { | |||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | chomp($f2); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( $f2 =~ /^\// ) { $full_path = $f2; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | else { $full_path = "$file_dir/$f2"; } | |||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my $analysis = Bio::Tradis::RunTradis->new( | |||||||||||||||||||||||||||||||||||||||||
| 147 | fastqfile => $full_path, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | tag => $self->tag, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | tagdirection => $self->tagdirection, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | mismatch => $self->mismatch, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | reference => $self->reference, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | mapping_score => $self->mapping_score, | ||||||||||||||||||||||||||||||||||||||||||
| 153 | output_directory => $self->_output_directory, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | _stats_handle => $self->_stats_handle, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | min_seed_len => $self->min_seed_len, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | smalt => $self->smalt, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | smalt_k => $self->smalt_k, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | smalt_s => $self->smalt_s, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | smalt_y => $self->smalt_y, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | smalt_r => $self->smalt_r, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | smalt_n => $self->smalt_n, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | verbose => $self->verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | samtools_exec => $self->samtools_exec | ||||||||||||||||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $analysis->run_tradis; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $at_least_one_good_fastq = 1; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $tag = $self->tag; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | warn "There was a problem filtering '$full_path' by '$tag'; it looks like the tag was not found in any read\n"; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ( ! $at_least_one_good_fastq ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | Bio::Tradis::Exception::TagFilterError->throw( error => "None of the input files contained the specified tag. Please check that your inputs are valid fastq files and that at least one read in one of them starts with the specified tag\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->_tidy_stats; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | close(FILES); | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | #$self->_combine_plots; | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub _build__output_directory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__output_directory: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | sub _stats_filename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stats_filename: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my $dir = $self->get_file_dir; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | my $output_directory = $self->_output_directory; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $stats_filename = $self->fastqfile; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $stats_filename =~ s/$dir\///; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $stats_filename =~ s/[^\.]+$/stats/; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | return "$output_directory/$stats_filename"; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | sub _build__stats_handle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__stats_handle: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | my $stats_filename = $self->_stats_filename(); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | open( my $stats, ">", $stats_filename ); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | return $stats; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub _tidy_stats { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tidy_stats: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $output_directory = $self->_output_directory; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $stats_filename = $self->_stats_filename(); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | open( STATS, '<', $stats_filename ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | open( TMP, '>', "$output_directory/tmp.stats" ); | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $header = 0; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | while ( my $line = <STATS> ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $line =~ /^File/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ( $header == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | print TMP "$line"; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $header = 1; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | print TMP "$line"; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | close(TMP); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | close(STATS); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | system("mv $output_directory/tmp.stats $stats_filename"); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub _combine_plots { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_combine_plots: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $filelist = $self->fastqfile; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | sub get_file_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $fq = $self->fastqfile; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | my @dirs = split( '/', $fq ); | |||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | pop(@dirs); | |||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | return join( '/', @dirs ); | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub usage_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | print <<USAGE; | |||||||||||||||||||||||||||||||||||||||||
| 247 | Run a TraDIS analysis. This involves: | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 1: filtering the data with tags matching that passed via -t option | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 2: removing the tags from the sequences | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 3: mapping | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 4: creating an insertion site plot | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 5: creating a stats summary | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | Usage: bacteria_tradis [options] | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 257 | -f : text file listing fastq files with tradis tags attached | ||||||||||||||||||||||||||||||||||||||||||
| 258 | -t : tag to search for (optional. If not set runs bwa in tagless mode with no filtering.) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | -r : reference genome in fasta format (.fa) | ||||||||||||||||||||||||||||||||||||||||||
| 260 | -td : tag direction - 3 or 5 (optional. default = 3) | ||||||||||||||||||||||||||||||||||||||||||
| 261 | -mm : number of mismatches allowed when matching tag (optional. default = 0) | ||||||||||||||||||||||||||||||||||||||||||
| 262 | -m : mapping quality cutoff score (optional. default = 30) | ||||||||||||||||||||||||||||||||||||||||||
| 263 | -k : custom k-mer value (min seed length) (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 264 | --smalt : use smalt rather than bwa as the mapper | ||||||||||||||||||||||||||||||||||||||||||
| 265 | --smalt_k : custom k-mer value for SMALT mapping (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 266 | --smalt_s : custom step size for SMALT mapping (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 267 | --smalt_y : custom y parameter for SMALT (optional. default = 0.96) | ||||||||||||||||||||||||||||||||||||||||||
| 268 | --smalt_r : custom r parameter for SMALT (optional. default = -1) | ||||||||||||||||||||||||||||||||||||||||||
| 269 | -n : number of threads to use for SMALT and samtools sort (optional. default = 1) | ||||||||||||||||||||||||||||||||||||||||||
| 270 | -e : set defaults for essentiality experiment (smalt_r = 0, -m = 0) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | -v : verbose debugging output | ||||||||||||||||||||||||||||||||||||||||||
| 272 | USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | __END__ | ||||||||||||||||||||||||||||||||||||||||||