Skip to content

Commit

Permalink
Final resolution to #52
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranmraine committed Aug 3, 2015
1 parent 83b1396 commit 6cb4482
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
5 changes: 4 additions & 1 deletion bin/bwa_mem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use autodie qw(:all);
use FindBin qw($Bin);
use lib "$Bin/../lib";
use Cwd qw(abs_path);

use File::Path qw(remove_tree make_path);
use Getopt::Long;
Expand Down Expand Up @@ -130,7 +131,9 @@ sub setup {
make_path($logs) unless(-d $logs);

$opts{'tmp'} = $tmpdir;
$opts{'raw_files'} = \@ARGV;
for(@ARGV) {
push @{$opts{'raw_files'}}, abs_path($_);
}

my $max_split = PCAP::Bwa::mem_prepare(\%opts);

Expand Down
42 changes: 28 additions & 14 deletions lib/PCAP/Bwa.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ sub mem_mapmax {
opendir(my $dh, $folder);
while(my $file = readdir $dh) {
next if($file =~ m/^\./);
next if($file =~ m/^2\.[[:digit]]+/); # captured by 1.*
next if($file =~ m/^pairedfq2\.[[:digit:]]+/); # captured by 1.*
push @files, File::Spec->catfile($folder, $file);
}
closedir($dh);
Expand Down Expand Up @@ -139,21 +139,35 @@ sub split_in {
if($input->fastq) {
# paired fq input
if($input->paired_fq) {
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $PAIRED_FQ_LINE_MULT
, $input->in.'_1.'.$input->fastq
, File::Spec->catfile($split_folder, '1');
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $PAIRED_FQ_LINE_MULT
, $input->in.'_2.'.$input->fastq
, File::Spec->catfile($split_folder, '2');
my $fq1 = $input->in.'_1.'.$input->fastq;
my $fq2 = $input->in.'_2.'.$input->fastq;
if($input->fastq =~ m/[.]gz$/) {
symlink $fq1, File::Spec->catfile($split_folder, 'pairedfq1.0.'.$input->fastq);
symlink $fq2, File::Spec->catfile($split_folder, 'pairedfq2.0.'.$input->fastq);
}
else {
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $PAIRED_FQ_LINE_MULT
, $fq1
, File::Spec->catfile($split_folder, 'pairedfq1');
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $PAIRED_FQ_LINE_MULT
, $fq2
, File::Spec->catfile($split_folder, 'pairedfq2');
}
}
# interleaved FQ
else {
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $INTERLEAVED_FQ_LINE_MULT
, $input->in.'.'.$input->fastq
, File::Spec->catfile($split_folder, 'i');
my $fq_i = $input->in.'.'.$input->fastq;
if($input->fastq =~ m/[.]gz$/) {
symlink $fq_i, File::Spec->catfile($split_folder, 'i.'.$input->fastq);
}
else {
push @commands, sprintf 'split -a 3 -d -l %s %s %s.'
, $fragment_size * $MILLION * $INTERLEAVED_FQ_LINE_MULT
, $fq_i
, File::Spec->catfile($split_folder, 'i');
}
}
}
# if bam input
Expand Down Expand Up @@ -227,7 +241,7 @@ sub bwa_mem {
# uncoverable branch false
if($input->paired_fq) {
my $split2 = $split;
$split2 =~ s/1(\.[[:digit:]]+)$/2$1/;
$split2 =~ s/pairedfq1(\.[[:digit:]]+)/pairedfq2$1/;
$bwa .= ' '.$split;
$bwa .= ' '.$split2;
}
Expand Down

0 comments on commit 6cb4482

Please sign in to comment.