12
12
# https://github.com/tjparnell/HCI-Scripts/
13
13
14
14
use strict;
15
+ use English qw( -no_match_vars) ;
15
16
use Getopt::Long qw( :config no_ignore_case) ;
16
17
use File::Basename qw( fileparse) ;
17
18
use Bio::UMIScripts::FastqHelper qw(
28
29
name_append_umi_from_fastq_read
29
30
) ;
30
31
31
- my $VERSION = 3.01 ;
32
+ our $VERSION = 3.02 ;
32
33
33
34
# ###### Documentation
34
35
my $description = <<END ;
@@ -217,29 +218,29 @@ END
217
218
if ($read_file2 and not $sam_format ) {
218
219
# open two separate output handles
219
220
$outfile = $read_file1 ;
220
- $outfile =~ s /\. (txt|fq| fastq)/ .umi.$1 / ;
221
+ $outfile =~ s /\. (txt | fq | fastq) / .umi.$1 / x ;
221
222
$out_fh1 = write_fastq_filehandle($outfile , $cpu );
222
223
my $outfile2 = $read_file2 ;
223
- $outfile2 =~ s /\. (txt|fq| fastq)/ .umi.$1 / ;
224
+ $outfile2 =~ s /\. (txt | fq | fastq) / .umi.$1 / x ;
224
225
$out_fh2 = write_fastq_filehandle($outfile2 , $cpu );
225
226
}
226
227
elsif (not $read_file2 and not $sam_format ) {
227
228
# just one file output
228
229
$outfile = $read_file1 ;
229
- $outfile =~ s /\. (txt|fq| fastq)/ .umi.$1 / ;
230
+ $outfile =~ s /\. (txt | fq | fastq) / .umi.$1 / x ;
230
231
$out_fh1 = write_fastq_filehandle($outfile , $cpu );
231
232
}
232
233
elsif ($read_file2 and $sam_format ) {
233
234
# open one bam output handle for both
234
235
$outfile = $read_file1 ;
235
- $outfile =~ s /\. (?:txt|fq| fastq)(?:\. gz)?$/ .bam/ ;
236
+ $outfile =~ s /\. (?: txt | fq | fastq) (?: \. gz)? $/ .bam/ x ;
236
237
$out_fh1 = write_bam_filehandle($outfile , $cpu );
237
238
$out_fh2 = $out_fh2 ;
238
239
}
239
240
elsif (not $read_file2 and $sam_format ) {
240
241
# just one file output
241
242
$outfile = $read_file1 ;
242
- $outfile =~ s /\. (?:fq| fastq)(?:\. gz)?$/ .bam/ ;
243
+ $outfile =~ s /\. (?: fq | fastq) (?: \. gz)? $/ .bam/ x ;
243
244
$out_fh1 = write_bam_filehandle($outfile , $cpu );
244
245
}
245
246
else {
280
281
281
282
# ## Write sam header as necessary
282
283
if ($sam_format ) {
283
- my $cl = " $0 --read1 $read_file1 " ;
284
+ my $cl = " $PROGRAM_NAME --read1 $read_file1 " ;
284
285
$cl .= " --read2 $read_file2 " if $read_file2 ;
285
286
$cl .= " --out $outfile " if $outfile ;
286
287
$cl .= " --umi $umi_location " ;
@@ -401,7 +402,7 @@ sub process_single_end_sam {
401
402
while (my $read = get_fastq_read($in_fh1 )) {
402
403
403
404
# extract UMI sequence
404
- my $umi = &$extract_umi ($read , $umi1_length , $fixed1 );
405
+ my $umi = &{ $extract_umi } ($read , $umi1_length , $fixed1 );
405
406
if ($umi ) {
406
407
my $tag = umi_sam_tags_from_fastq_read($umi );
407
408
$out_fh1 -> print ( $read -> sam_string($flag1 , $tag ) );
@@ -418,7 +419,7 @@ sub process_single_end_name_append {
418
419
while (my $read = get_fastq_read($in_fh1 )) {
419
420
420
421
# extract UMI sequence
421
- my $umi = &$extract_umi ($read , $umi1_length , $fixed1 );
422
+ my $umi = &{ $extract_umi } ($read , $umi1_length , $fixed1 );
422
423
if ($umi ) {
423
424
name_append_umi_from_fastq_read($read , $umi );
424
425
$out_fh1 -> print ( $read -> fastq_string );
@@ -435,7 +436,7 @@ sub process_single_end_fastq_tag {
435
436
while (my $read = get_fastq_read($in_fh1 )) {
436
437
437
438
# extract UMI sequence
438
- my $umi = &$extract_umi ($read , $umi1_length , $fixed1 );
439
+ my $umi = &{ $extract_umi } ($read , $umi1_length , $fixed1 );
439
440
if ($umi ) {
440
441
my $tag = umi_sam_tags_from_fastq_read($umi );
441
442
$out_fh1 -> print ( $read -> fastq_string($tag ) );
@@ -461,7 +462,7 @@ sub process_paired_end_with_one_umi_sam {
461
462
}
462
463
463
464
# extract UMI sequence
464
- my $umi = &$extract_umi ($umi_location == 1 ? $read1 : $read2 ,
465
+ my $umi = &{ $extract_umi } ($umi_location == 1 ? $read1 : $read2 ,
465
466
$umi1_length , $fixed1 );
466
467
if ($umi ) {
467
468
my $tag = umi_sam_tags_from_fastq_read($umi );
@@ -489,7 +490,7 @@ sub process_paired_end_with_one_umi_name_append {
489
490
}
490
491
491
492
# extract UMI sequence
492
- my $umi = &$extract_umi ($umi_location == 1 ? $read1 : $read2 ,
493
+ my $umi = &{ $extract_umi } ($umi_location == 1 ? $read1 : $read2 ,
493
494
$umi1_length , $fixed1 );
494
495
if ($umi ) {
495
496
name_append_umi_from_fastq_read($read1 , $umi );
@@ -518,7 +519,7 @@ sub process_paired_end_with_one_umi_fastq_tag {
518
519
}
519
520
520
521
# extract UMI sequence
521
- my $umi = &$extract_umi ($umi_location == 1 ? $read1 : $read2 ,
522
+ my $umi = &{ $extract_umi } ($umi_location == 1 ? $read1 : $read2 ,
522
523
$umi1_length , $fixed1 );
523
524
if ($umi ) {
524
525
my $tag = umi_sam_tags_from_fastq_read($umi );
@@ -548,8 +549,8 @@ sub process_paired_end_with_two_umi_sam {
548
549
}
549
550
550
551
# extract UMI sequence
551
- my $umi1 = &$extract_umi ($read1 , $umi1_length , $fixed1 );
552
- my $umi2 = &$extract_umi ($read2 , $umi2_length , $fixed2 );
552
+ my $umi1 = &{ $extract_umi } ($read1 , $umi1_length , $fixed1 );
553
+ my $umi2 = &{ $extract_umi } ($read2 , $umi2_length , $fixed2 );
553
554
if ($umi1 and $umi2 ) {
554
555
# both found, both good
555
556
my $umi = $umi1 -> concatenate_reads($umi2 );
@@ -583,8 +584,8 @@ sub process_paired_end_with_two_umi_name_append {
583
584
}
584
585
585
586
# extract UMI sequence
586
- my $umi1 = &$extract_umi ($read1 , $umi1_length , $fixed1 );
587
- my $umi2 = &$extract_umi ($read2 , $umi2_length , $fixed2 );
587
+ my $umi1 = &{ $extract_umi } ($read1 , $umi1_length , $fixed1 );
588
+ my $umi2 = &{ $extract_umi } ($read2 , $umi2_length , $fixed2 );
588
589
if ($umi1 and $umi2 ) {
589
590
# both found, both good
590
591
my $umi = $umi1 -> concatenate_reads($umi2 );
@@ -619,8 +620,8 @@ sub process_paired_end_with_two_umi_fastq_tag {
619
620
}
620
621
621
622
# extract UMI sequence
622
- my $umi1 = &$extract_umi ($read1 , $umi1_length , $fixed1 );
623
- my $umi2 = &$extract_umi ($read2 , $umi2_length , $fixed2 );
623
+ my $umi1 = &{ $extract_umi } ($read1 , $umi1_length , $fixed1 );
624
+ my $umi2 = &{ $extract_umi } ($read2 , $umi2_length , $fixed2 );
624
625
if ($umi1 and $umi2 ) {
625
626
# both found, both good
626
627
my $umi = $umi1 -> concatenate_reads($umi2 );
0 commit comments