Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmterpstra committed Dec 17, 2015
2 parents 954d6d2 + 696731d commit 1280a8b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/NugeneMergeFastqFiles.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ sub main {
#open/check some resuired files

open(my $randomBcHandle,"-|",'gzip -dc '.$ARGV[0])
or die "Cannot read open randombarcode file ".$ARGV[0];
or die "Cannot read open randombarcode file ".$ARGV[0]."\n".$use;

if(! -e $ARGV[1]){
die "Outdir does not exist! ".$ARGV[1];
die "Outdir does not exist! ".$ARGV[1]."\n".$use;;
}


#open handles fastq files

open(my $fastq1Handle,"-|",'gzip -dc '.$ARGV[2])
Expand All @@ -28,7 +29,7 @@ sub main {
my $fastq2Handle;
my $fastq2OutHandle;

if(-e $ARGV[3]){
if(defined($ARGV[3]) && -e $ARGV[3]){

open($fastq2Handle,"-|",'gzip -dc '.$ARGV[3])
or die "Cannot read open fq2 file ".$ARGV[3];
Expand All @@ -43,7 +44,7 @@ sub main {


#if reading record fails from both fq files then end
while( (((( ! -e $ARGV[3] )|| (my $fq2 = ReadFastq(\$fastq2Handle) ))) && (my $fq1 = ReadFastq(\$fastq1Handle))) && (my $rfq = ReadFastq(\$randomBcHandle)) ){
while( ((((defined($ARGV[3]) && ! -e $ARGV[3] )|| (my $fq2 = ReadFastq(\$fastq2Handle) ))) && (my $fq1 = ReadFastq(\$fastq1Handle))) && (my $rfq = ReadFastq(\$randomBcHandle)) ){

warn $.if $. =~ /00000$/;
my $rbc = $rfq->[1];
Expand All @@ -52,13 +53,13 @@ sub main {
$fq1 = setFCID($fq1,$fcid."_".$rbc);
WriteFastq(\$fastq1OutHandle,$fq1);

if(-e $ARGV[3]){
if(defined($ARGV[3]) && -e $ARGV[3]){
$fq2 = setFCID($fq2,$fcid."_".$rbc);
WriteFastq(\$fastq2OutHandle,$fq2);
}

}
if( (((( -e $ARGV[3] ) && (my $fq2 = ReadFastq(\$fastq2Handle) ))) || (my $fq1 = ReadFastq(\$fastq1Handle))) || (my $rfq = ReadFastq(\$randomBcHandle)) ){
if( ((((defined($ARGV[3]) && -e $ARGV[3] ) && (my $fq2 = ReadFastq(\$fastq2Handle) ))) || (my $fq1 = ReadFastq(\$fastq1Handle))) || (my $rfq = ReadFastq(\$randomBcHandle)) ){

unlink(GetOutFileName($ARGV[1],$ARGV[3]))if(-e GetOutFileName($ARGV[1],$ARGV[2]));
unlink(GetOutFileName($ARGV[1],$ARGV[3]))if(-e GetOutFileName($ARGV[1],$ARGV[3]));
Expand Down

0 comments on commit 1280a8b

Please sign in to comment.